From 0dfc9d47eb74c56b2791ade6e7099f306b609564 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 23 Nov 2026 12:24:54 -0500 Subject: [PATCH] fw sync: the flat note Reply's edge takes the note's colour Trial a_flat_reply_edge_takes_the_notes_colour. Co-Authored-By: Claude --- crates/review/src/ui/thread/note_popup.rs | 42 +++++++++++++++++++---- crates/review/tests/it/note_popup.rs | 28 +++++++++++++++ 2 files changed, 63 insertions(+), 7 deletions(-) diff --git a/crates/review/src/ui/thread/note_popup.rs b/crates/review/src/ui/thread/note_popup.rs index f28639edd2..c5c9702b10 100644 --- a/crates/review/src/ui/thread/note_popup.rs +++ b/crates/review/src/ui/thread/note_popup.rs @@ -106,6 +106,9 @@ struct NoteBody<'a, 'm> { now: i64, /// The body's tint: the note's colour thinned with white to a third, as production's. tint_color: Color32, + /// The flat Reply's edge ([`NoteReplyLook::Flat`]): the note's colour thinned with white to seven tenths, as + /// production's panel edge. + edge_color: Color32, body: Option, reply: Option<(u64, String)>, } @@ -188,7 +191,17 @@ impl NoteBody<'_, '_> { Row::new().fill_width().align(RowAlign::End).show(ui, |ui, _| { let reply = Button::new(words.reply.clone()).size(ControlSize::Sm); let reply = if flat { reply.variant(Variant::Custom(FLAT_REPLY)) } else { reply }; - if clicked(&reply.show(ui)) { + let shown = reply.show(ui); + // The flat face's edge at rest is the note's colour, which no token holds: the variant leaves it clear + // and it is drawn here. Under the pointer (and so while pressed) the variant's own edge shows. + let response = &shown.response; + if flat && !response.hovered() { + let tokens = &Env::of(ui).tokens; + let (radius, width) = (UiTokens::corner(tokens.shape.radius.control), tokens.stroke.thin); + let edge = egui::Stroke::new(width, self.edge_color); + ui.painter().rect_stroke(response.rect, radius, edge, egui::StrokeKind::Inside); + } + if clicked(&shown) { self.drafts.replies.insert(id, (to, String::new())); } }); @@ -361,8 +374,17 @@ impl<'a> NotePopup<'a> { Overlay::floating().modeless().movable(allowed).resize_edges(grip).body_scroll(true).size_limits(NOTE_POPUP_LIMITS).placed(shown_at); let layer = NoteWindow::new(label, overlay, NoteLook { title, age, fill }, words.close.clone(), allowed, anchor, selected) .id_salt(("note-popup", id)); - let mut content = - NoteBody { id, messages, drafts, allowed, now, tint_color: Color32::from_rgb(pale(r), pale(g), pale(b)), body: None, reply: None }; + let mut content = NoteBody { + id, + messages, + drafts, + allowed, + now, + tint_color: Color32::from_rgb(pale(r), pale(g), pale(b)), + edge_color: Color32::from_rgb(edge_tone(r), edge_tone(g), edge_tone(b)), + body: None, + reply: None, + }; let shown = layer.show(ui, |ui, _| content.show(ui, &words, &view)); let NoteBody { drafts, mut body, reply, .. } = content; let out = shown.output; @@ -394,15 +416,16 @@ pub enum NoteReplyLook { /// The flat Reply face ([`NoteReplyLook::Flat`]). const FLAT_REPLY: CustomVariant = CustomVariant::new::("craft_review.flat-reply", flat_reply_look); -/// White at 60% over the note's tint, a control edge and control corners; the theme's state fills under the pointer -/// and the press. +/// White at 60% over the note's tint, an edge in the note's colour (drawn by the pop-up) and control corners; the +/// theme's state fills under the pointer and the press. fn flat_reply_look(tokens: &Tokens) -> VariantLook { let c = &tokens.color; let face = Rgba([255, 255, 255, 153]); let text = States::new(c.text.normal, c.text.normal, c.text.normal, c.text.disabled); - let edge = c.line.control_edge; + // The edge at rest is the note's colour, drawn by the pop-up (`NoteBody::reply_box`); clear here. + let clear = Rgba([255, 255, 255, 0]); VariantLook::new(States::new(face, c.state.hover, c.state.pressed, face), text) - .edge(States::new(edge, c.text.normal, c.text.normal, c.line.divider)) + .edge(States::new(clear, c.text.normal, c.text.normal, c.line.divider)) .radius(RadiusStep::Control) } @@ -430,6 +453,11 @@ fn changed(from: Rect, to: Rect) -> bool { (to.min - from.min).length() >= LEAST_CHANGE || (to.size() - from.size()).length() >= LEAST_CHANGE } +/// A channel of the note's colour thinned with white to seven tenths: the flat Reply's edge. +fn edge_tone(channel: u8) -> u8 { + ((u16::from(channel) * 7 + 255 * 3) / 10) as u8 +} + /// A channel of the note's colour thinned with white to a third. fn pale(channel: u8) -> u8 { ((u16::from(channel) + 2 * 255) / 3) as u8 diff --git a/crates/review/tests/it/note_popup.rs b/crates/review/tests/it/note_popup.rs index f780123194..e0e7686d4b 100644 --- a/crates/review/tests/it/note_popup.rs +++ b/crates/review/tests/it/note_popup.rs @@ -401,3 +401,31 @@ fn a_composer_with_fixed_rows_keeps_post_inside_its_card_near_the_bottom() { fixture.click(&post).settle(); assert!(posted.borrow().as_deref().is_some_and(|text| text.starts_with("word word")), "Post posted: {:?}", posted.borrow()); } + +/// Production's flat Reply takes its edge from the note's colour (thinned with white to seven tenths), not the light +/// palette's control edge: a blue note's Reply has a blue edge. +#[trial] +fn a_flat_reply_edge_takes_the_notes_colour() { + let mut drafts = NoteDrafts::default(); + let mut fixture = Fixture::new(move |ui| { + let rect = Rect::from_min_size(pos2(100.0, 100.0), vec2(320.0, 200.0)); + let _ = NotePopup::new(1, "Note", rect, &NOTE, &mut drafts).color(Some([10, 20, 200])).show(ui); + }); + fixture.root_value(craft_review::ui::NoteReplyLook::Flat); + fixture.room(vec2(1000.0, 800.0)).settle(); + let reply = fixture.by_label("Reply").expect("the pop-up shows Reply").rect; + fn strokes(shape: &egui::Shape, out: &mut Vec<(Rect, egui::Color32)>) { + match shape { + egui::Shape::Rect(rect) if rect.stroke.width > 0.0 => out.push((rect.rect, rect.stroke.color)), + egui::Shape::Vec(shapes) => shapes.iter().for_each(|shape| strokes(shape, out)), + _ => {} + } + } + let mut seen = Vec::new(); + for shape in fixture.frame_shapes() { + strokes(&shape, &mut seen); + } + let edge = egui::Color32::from_rgb(83, 90, 216); + let around = seen.iter().filter(|(rect, _)| (rect.center() - reply.center()).length() < 2.0).collect::>(); + assert!(around.iter().any(|(_, color)| *color == edge), "the Reply {reply:?} is edged in the note's colour {edge:?}: {around:?}"); +}