From 01613f11c30b1a77b8a9bbea0cd965d7badab3ed Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 18 Nov 2026 14:18:02 +0000 Subject: [PATCH] canvas-w7: review fixes (review-2) --- crates/review/src/ui/balloons.rs | 17 +++++++++-------- crates/review/src/ui/balloons/stories.rs | 2 +- crates/review/src/ui/comments/row.rs | 14 +++++++++++++- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/crates/review/src/ui/balloons.rs b/crates/review/src/ui/balloons.rs index a6bc3bc28..6bdf9ae25 100644 --- a/crates/review/src/ui/balloons.rs +++ b/crates/review/src/ui/balloons.rs @@ -153,14 +153,15 @@ impl<'a> CommentBalloons<'a> { } else { pages.iter().map(|page| page.rect.right()).fold(f32::NEG_INFINITY, f32::max) + gap }; - let x_of = |page: &PlacedPage| match place { - BalloonPlace::Column => column, - BalloonPlace::Floating if rtl => (page.rect.left() - gap - width).max(room.left()), - BalloonPlace::Floating => { - let beside = page.rect.right() + gap; - // Without room beside the page the card floats over the page's edge, inside the room. - if beside + width <= room.right() { beside } else { (room.right() - width).max(room.left()) } - } + // A card always lies whole inside the room: without room beside the pages it floats over their edge, so + // its text is never cut off by the room's clip. + let x_of = |page: &PlacedPage| { + let preferred = match place { + BalloonPlace::Column => column, + BalloonPlace::Floating if rtl => page.rect.left() - gap - width, + BalloonPlace::Floating => page.rect.right() + gap, + }; + preferred.min(room.right() - width).max(room.left()) }; let count = order.len(); diff --git a/crates/review/src/ui/balloons/stories.rs b/crates/review/src/ui/balloons/stories.rs index be96c42d0..ac49d2453 100644 --- a/crates/review/src/ui/balloons/stories.rs +++ b/crates/review/src/ui/balloons/stories.rs @@ -85,7 +85,7 @@ fn balloons_long(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { #[story(CommentBalloons<'static>, covers = [], drive = Drive::Never)] fn balloons_right_to_left(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { - let threads = [thread(1, "منى", "الهامش ضيق جدا في هذه الصفحة.", false)]; + let threads = [thread(1, "מיכל", "השוליים צרים מדי בעמוד הזה.", false)]; beside_page(ui, data, &threads, &[], None, BalloonPlace::Column) } diff --git a/crates/review/src/ui/comments/row.rs b/crates/review/src/ui/comments/row.rs index 17b9332c1..7a3db5970 100644 --- a/crates/review/src/ui/comments/row.rs +++ b/crates/review/src/ui/comments/row.rs @@ -7,7 +7,7 @@ use craft_theme::variant::Variant; use craft_ui::buttons::{Button, IconButton}; use craft_ui::contract::{Bind, Common, Component, Cx, MeasureCx, PaintUi, PartsCx, Props as _, Role, WordSetCx as _, clicked}; use craft_ui::controls::disclosure::DisclosureGlyph; -use craft_ui::primitives::{HAlign, IconSpec, PaintShape, TextRun, Wrap}; +use craft_ui::primitives::{HAlign, IconSpec, PaintShape, StrokeWidth, TextRun, Wrap}; use craft_ui::runtime::env::Label; use craft_ui::runtime::focus::{self, FocusTarget}; use craft_ui::style::{ComponentStyle, DataColor, Ink, StyleColor, StyleCx, TypeRole}; @@ -33,6 +33,10 @@ pub(crate) struct CommentRowStyle { faint: StyleColor, highlight: StyleColor, bar: StyleColor, + /// The surface of a balloon card. + card: StyleColor, + /// The border of a balloon card. + border: StyleColor, avatar: StyleColor, avatar_ink: StyleColor, /// The disc behind a card's kind icon. @@ -677,6 +681,8 @@ impl Component for CommentRow<'_> { faint: cx.color(color.text.faint), highlight: cx.color(color.state.selected), bar: cx.color(color.accent.solid), + card: cx.color(color.surface.raised), + border: cx.color(color.line.border), avatar: cx.color(color.accent.strong), avatar_ink: cx.color(color.text.on_strong), sunken: cx.color(color.surface.sunken), @@ -726,6 +732,12 @@ impl Component for CommentRow<'_> { let rtl = cx.env.direction().is_rtl(); let now = self.now; let age = |then: i64| age_text(&cx.env, then, now); + // A balloon card sits over the page, so it carries its own surface and border. + if self.actions == CardActions::Buttons { + let shape = PaintShape::Rect(rect, CornerRadius::ZERO); + ui.draw().fill(&shape, st.card); + ui.draw().stroke(&shape, StrokeWidth::Thin, st.border); + } if self.selected { ui.draw().fill(&PaintShape::Rect(rect, CornerRadius::ZERO), st.highlight); let bar = if rtl {