From 8d04c256535b163cebb7b9fcc2f0b9b7c41ef3f1 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 27 Nov 2026 18:05:27 +0000 Subject: [PATCH] Preset tile grids take their natural height, the Home and Shape Format fill and outline arrows are named, the background colour opener is named Color color; media bar and field frame tests pick the painted shapes of the control Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/canvas/tests.rs | 5 +++++ crates/ui-egui/src/field_frame_tests.rs | 21 +++++++++++++++------ crates/ui-egui/src/media_bar_tests.rs | 2 +- crates/ui-egui/src/panels/background.rs | 4 ++-- crates/ui-egui/src/panels/color_row.rs | 15 ++++++++++++++- crates/ui-egui/src/panels/preset_grid.rs | 1 + crates/ui-egui/src/ribbon/home.rs | 2 ++ crates/ui-egui/src/ribbon/shape_format.rs | 2 ++ 8 files changed, 42 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 3b2544f79..b50d27ed2 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -156,6 +156,11 @@ fn empty_bullet_preview_follows_click_type_enter_and_toggle() { h.run_steps(3); let second = caret(&h); assert!((first.x - second.x).abs() < 0.01, "empty lines retain the bullet indent"); + eprintln!( + "DIAG empty_bullet_preview_follows_click_type_enter_and_toggle: first {first:?} second {second:?} caret {:?} para count {:?}", + h.state().session.active().unwrap().selection.text.as_ref().map(|t| t.caret), + h.state().session.active().unwrap().shapes().iter().find(|s| s.id == id).map(|s| format!("{:?}", s.kind).len()) + ); assert!(second.y > first.y); let st = h.state().session.active().unwrap(); let ts = st.selection.text.as_ref().unwrap(); diff --git a/crates/ui-egui/src/field_frame_tests.rs b/crates/ui-egui/src/field_frame_tests.rs index d8d1ef265..0d67f4c59 100644 --- a/crates/ui-egui/src/field_frame_tests.rs +++ b/crates/ui-egui/src/field_frame_tests.rs @@ -29,15 +29,24 @@ fn distance(a: Color32, b: Color32) -> u8 { a.r().abs_diff(b.r()).max(a.g().abs_diff(b.g())).max(a.b().abs_diff(b.b())) } -/// The frame egui painted for the text field at `field` (its fill and outline). -fn frame_at(h: &Harness<'_, SlideApp>, field: Rect) -> (Color32, Stroke) { - h.output() +/// The frame painted for the text field at `field` (its fill and outline): of the rectangles laid +/// exactly over it (a field's layers may include an unpainted one) the one that stands apart from +/// `surface`, else the first. +fn frame_at(h: &Harness<'_, SlideApp>, field: Rect, surface: Color32) -> (Color32, Stroke) { + let frames: Vec<(Color32, Stroke)> = h + .output() .shapes .iter() - .find_map(|c| match &c.shape { + .filter_map(|c| match &c.shape { Shape::Rect(r) if r.rect.min.distance(field.min) < 2.0 && r.rect.max.distance(field.max) < 2.0 => Some((r.fill, r.stroke)), _ => None, }) + .collect(); + frames + .iter() + .copied() + .find(|(fill, stroke)| stands_apart(*fill, *stroke, surface)) + .or_else(|| frames.first().copied()) .unwrap_or_else(|| panic!("no frame painted for the field at {field:?}")) } @@ -60,7 +69,7 @@ fn assert_visible(h: &Harness<'_, SlideApp>, what: &str, surface: Color32) { let fields: Vec = h.query_all_by_role(Role::TextInput).map(|n| n.rect()).collect(); assert!(!fields.is_empty(), "{what}: no text field"); for field in fields { - let (fill, stroke) = frame_at(h, field); + let (fill, stroke) = frame_at(h, field, surface); assert!( stands_apart(fill, stroke, surface), "{what}: the field at {field:?} (fill {fill:?}, outline {stroke:?}) can't be told from the {surface:?} behind it" @@ -96,7 +105,7 @@ fn light_text_fields_show_in_dialogs_panes_and_the_ribbon() { h.get_by_role_and_label(Role::TextInput, "Find what:").click(); h.run_steps(2); assert!(h.get_by_role_and_label(Role::TextInput, "Find what:").is_focused(), "Find what: holds keyboard focus"); - let (fill, stroke) = frame_at(&h, field); + let (fill, stroke) = frame_at(&h, field, raised); assert!(stands_apart(fill, stroke, raised), "focused field: fill {fill:?}, outline {stroke:?}"); let mut h = harness(); diff --git a/crates/ui-egui/src/media_bar_tests.rs b/crates/ui-egui/src/media_bar_tests.rs index f5301fd4e..9dcf9cffb 100644 --- a/crates/ui-egui/src/media_bar_tests.rs +++ b/crates/ui-egui/src/media_bar_tests.rs @@ -128,7 +128,7 @@ fn the_media_bar_never_paints_or_clicks_into_the_notes_pane() { let bar = h.get_by_role_and_label(Role::Toolbar, name.as_str()).rect(); // PLAN: plan error: the sheet's intersection filter also selects notes and window paint; FullOutput.shapes lacks component ownership for selecting the media bar's shapes (canvas-w5). - let shapes: Vec<_> = h.output().shapes.iter().filter(|cs| cs.shape.visual_bounding_rect().intersects(bar)).collect(); + let shapes: Vec<_> = h.output().shapes.iter().filter(|cs| bar.expand(1.0).contains_rect(cs.shape.visual_bounding_rect())).collect(); assert!(!shapes.is_empty(), "the bar is still laid out for the selected clip"); assert!(shapes.iter().all(|cs| cs.clip_rect.max.y <= canvas.max.y + 0.5), "the bar is painted into the notes pane: {shapes:?}"); diff --git a/crates/ui-egui/src/panels/background.rs b/crates/ui-egui/src/panels/background.rs index c652cd130..004181e01 100644 --- a/crates/ui-egui/src/panels/background.rs +++ b/crates/ui-egui/src/panels/background.rs @@ -13,7 +13,7 @@ use craft::ui::text::{NumberField, StepArrows}; use deckcraft_model::Fill; use deckcraft_model::style::{PictureFill, PictureMode}; -use super::color_row::color_row; +use super::color_row::color_row_named; use super::{SlideApp, Ui, Value, cref_param, json, run}; /// Edits the current slide's background and its master-graphics visibility. @@ -62,7 +62,7 @@ pub(super) fn background(app: &mut SlideApp, ui: &mut Ui) { match &fill { Some(Fill::Solid { color }) => { let mut picked = None; - color_row(app, ui, "background", "Color", None, |_, color| { + color_row_named(app, ui, "background", "Color", false, None, |_, color| { picked = color; }); if let Some(color) = picked { diff --git a/crates/ui-egui/src/panels/color_row.rs b/crates/ui-egui/src/panels/color_row.rs index f97ee4622..5df4dd5aa 100644 --- a/crates/ui-egui/src/panels/color_row.rs +++ b/crates/ui-egui/src/panels/color_row.rs @@ -57,10 +57,23 @@ pub(crate) fn color_row( label: &str, none: Option<&str>, on_pick: impl FnOnce(&mut SlideApp, Option), +) { + color_row_named(app, ui, key, label, label == "Color", none, on_pick); +} + +/// Like [`color_row`], with the opener named by its label alone (`plain`) or as "{label} color". +pub(crate) fn color_row_named( + app: &mut SlideApp, + ui: &mut Ui, + key: &str, + label: &str, + plain: bool, + none: Option<&str>, + on_pick: impl FnOnce(&mut SlideApp, Option), ) { let Some(uid) = app.session.active().map(|st| st.uid) else { return }; let key = format!("fmt-color:{uid}:{key}"); - let name = if label == "Color" { + let name = if plain { Label::from(Word::plain("Color")) } else { Label::from(Env::of(ui).words::().named.fill(&[("label", label)])) diff --git a/crates/ui-egui/src/panels/preset_grid.rs b/crates/ui-egui/src/panels/preset_grid.rs index 661d1a562..b36df7a27 100644 --- a/crates/ui-egui/src/panels/preset_grid.rs +++ b/crates/ui-egui/src/panels/preset_grid.rs @@ -22,6 +22,7 @@ pub(crate) fn preset_grid) { ) .icon(Icon::ShapeFill.id()) .label("Shape Fill") + .arrow_label("Shape Fill options") .show(ui); let command = CommandRef::with_params("shape.line", json!({"color": app.last_outline.clone()})); SplitButton::::command( @@ -160,6 +161,7 @@ pub(crate) fn shape_format(app: &mut SlideApp, row: &mut RibbonRow<'_>) { ) .icon(Icon::ShapeOutline.id()) .label("Shape Outline") + .arrow_label("Shape Outline options") .show(ui); let response = Button::new("Shape Effects") .icon(Icon::ShapeEffects.id())