From ee267391a40d4836d2a88b530e252329887d8d01 Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 13 Nov 2026 12:40:31 -0500 Subject: [PATCH 1/5] fix(ui): match Frame tool shape tooltips and sides label --- crates/ui-egui/src/tools/frame_tool.rs | 2 + .../src/tools/frame_tool/labels_tests.rs | 95 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 crates/ui-egui/src/tools/frame_tool/labels_tests.rs diff --git a/crates/ui-egui/src/tools/frame_tool.rs b/crates/ui-egui/src/tools/frame_tool.rs index a3b43bc664..d0ace6b407 100644 --- a/crates/ui-egui/src/tools/frame_tool.rs +++ b/crates/ui-egui/src/tools/frame_tool.rs @@ -852,6 +852,8 @@ mod size_hud_tests; #[cfg(test)] mod space_move_tests; #[cfg(test)] +mod labels_tests; +#[cfg(test)] mod tests; /// Free Transform on the frame thumbnail edits the clipping geometry, leaving its image intact. diff --git a/crates/ui-egui/src/tools/frame_tool/labels_tests.rs b/crates/ui-egui/src/tools/frame_tool/labels_tests.rs new file mode 100644 index 0000000000..8951331807 --- /dev/null +++ b/crates/ui-egui/src/tools/frame_tool/labels_tests.rs @@ -0,0 +1,95 @@ +//! #13877: the Frame shape buttons use the measured tooltips, and Polygon shows a `#` caption. + +use egui::accesskit::Role; +use egui_kittest::Harness; +use egui_kittest::kittest::Queryable; +use serde_json::json; + +use crate::PhotocraftApp; +use crate::i18n::Lang; +use crate::state::Tool; + +const SHAPES: [(&str, &str); 5] = [ + ("rectangle", "Use the mouse to create a new rectangular Frame"), + ("ellipse", "Use the mouse to create a new elliptical Frame"), + ("triangle", "Use the mouse to create a new triangular Frame"), + ("polygon", "Use the mouse to create a new polygonal Frame"), + ("custom", "Use the mouse to create a new custom Frame"), +]; + +fn bar() -> Harness<'static, PhotocraftApp> { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 80, "height": 60})).unwrap(); + app.ui.tool = Tool::Frame; + let mut h = + Harness::builder().with_size(egui::vec2(900.0, 180.0)).with_context_setup(|ctx| PhotocraftApp::setup_context(ctx, Default::default())).build_ui_state( + |ui, app| { + let _language = crate::i18n::language_scope(Lang::EN); + ui.horizontal(|ui| super::options_bar(app, ui, Tool::Frame)); + }, + app, + ); + h.run_steps(4); + h +} + +fn drawn(h: &Harness<'_, PhotocraftApp>) -> Vec { + fn collect(shape: &egui::Shape, text: &mut Vec) { + match shape { + egui::Shape::Text(shape) => text.push(shape.galley.job.text.clone()), + egui::Shape::Vec(shapes) => shapes.iter().for_each(|shape| collect(shape, text)), + _ => {} + } + } + let mut text = Vec::new(); + for shape in &h.output().shapes { + collect(&shape.shape, &mut text); + } + text +} + +#[test] +fn shape_buttons_show_the_exact_tooltips_in_order_and_still_select_their_shapes() { + let mut h = bar(); + let lefts = SHAPES.map(|(_, tip)| h.get_by_role_and_label(Role::Button, tip).rect().left()); + assert!(lefts.windows(2).all(|w| w[0] < w[1]), "shape buttons remain in reference order"); + for (shape, tip) in SHAPES { + h.get_by_role_and_label(Role::Button, tip).hover(); + h.run_steps(60); + assert!(drawn(&h).iter().any(|text| text == tip), "hover must show {tip:?}: {:?}", drawn(&h)); + h.get_by_role_and_label(Role::Button, tip).click(); + h.run_steps(4); + assert_eq!(h.state().ui.frame_tool.shape, shape); + assert_eq!(h.state().ui.frame_tool.ellipse, shape == "ellipse"); + } +} + +#[test] +fn polygon_shows_the_hash_caption_and_keeps_the_default_and_accessible_name() { + let mut h = bar(); + h.state_mut().ui.frame_tool.shape = "polygon".into(); + h.run_steps(4); + let text = drawn(&h); + assert!(text.iter().any(|text| text == "#"), "polygon caption: {text:?}"); + assert!(!text.iter().any(|text| text == "Sides:"), "old caption: {text:?}"); + assert_eq!(h.state().ui.frame_tool.sides, 5); + assert!(text.iter().any(|text| text == "5"), "the field displays the default: {text:?}"); + assert!(h.query_by_role_and_label(Role::SpinButton, "Sides:").is_some(), "the field keeps its descriptive accessible name"); +} + +#[test] +fn polygon_sides_field_keeps_the_three_to_one_hundred_range() { + let mut h = bar(); + h.state_mut().ui.frame_tool.shape = "polygon".into(); + h.run_steps(4); + for (typed, expected) in [("1", 3), ("3", 3), ("100", 100), ("101", 100)] { + h.get_by_role_and_label(Role::SpinButton, "Sides:").click(); + h.run_steps(2); + h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A); + h.event(egui::Event::Text(typed.into())); + h.run_steps(2); + h.key_press(egui::Key::Enter); + h.run_steps(4); + assert_eq!(h.state().ui.frame_tool.sides, expected, "typed {typed}"); + } +} From 568d045193c8e585ad652ef5ef562b6a1e5b70d2 Mon Sep 17 00:00:00 2001 From: Ian Date: Wed, 25 Nov 2026 21:58:24 -0500 Subject: [PATCH 2/5] fix: align Frame tool tooltip wording --- crates/ui-egui/src/tools/frame_tool.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/tools/frame_tool.rs b/crates/ui-egui/src/tools/frame_tool.rs index d0ace6b407..842b4a0867 100644 --- a/crates/ui-egui/src/tools/frame_tool.rs +++ b/crates/ui-egui/src/tools/frame_tool.rs @@ -801,11 +801,11 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo } // An icon entry's label is its tooltip and accessible name. let entries: Vec> = [ - ("square", "rectangle", tl!("Create a new rectangular frame")), - ("circle", "ellipse", tl!("Create a new elliptical frame")), - ("triangle", "triangle", tl!("Create a new triangular frame")), - ("pentagon", "polygon", tl!("Create a new polygonal frame")), - ("shapes", "custom", tl!("Create a new custom frame")), + ("square", "rectangle", tl!("Use the mouse to create a new rectangular Frame")), + ("circle", "ellipse", tl!("Use the mouse to create a new elliptical Frame")), + ("triangle", "triangle", tl!("Use the mouse to create a new triangular Frame")), + ("pentagon", "polygon", tl!("Use the mouse to create a new polygonal Frame")), + ("shapes", "custom", tl!("Use the mouse to create a new custom Frame")), ] .into_iter() .map(|(icon, shape, label)| Entry::new(shape.to_string(), label).icon(IconId::new(icon))) From 05b2378cb3b9f25836d8c874b06d943f4857b657 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 26 Nov 2026 14:36:41 -0500 Subject: [PATCH 3/5] style: format frame tool test modules --- crates/ui-egui/src/tools/frame_tool.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/tools/frame_tool.rs b/crates/ui-egui/src/tools/frame_tool.rs index 842b4a0867..90e9d06912 100644 --- a/crates/ui-egui/src/tools/frame_tool.rs +++ b/crates/ui-egui/src/tools/frame_tool.rs @@ -844,6 +844,8 @@ mod cursor_tests; #[cfg(test)] mod escape_commit_tests; #[cfg(test)] +mod labels_tests; +#[cfg(test)] mod move_history_tests; #[cfg(test)] mod shift_square_tests; @@ -852,8 +854,6 @@ mod size_hud_tests; #[cfg(test)] mod space_move_tests; #[cfg(test)] -mod labels_tests; -#[cfg(test)] mod tests; /// Free Transform on the frame thumbnail edits the clipping geometry, leaving its image intact. From 20d721f3244371af1576bc620724f03e0647a0ed Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 26 Nov 2026 14:43:56 -0500 Subject: [PATCH 4/5] fix: keep frame label parity tests current --- crates/ui-egui/src/tools/frame_tool.rs | 2 +- .../src/tools/frame_tool/labels_tests.rs | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/tools/frame_tool.rs b/crates/ui-egui/src/tools/frame_tool.rs index 90e9d06912..740f90d6f5 100644 --- a/crates/ui-egui/src/tools/frame_tool.rs +++ b/crates/ui-egui/src/tools/frame_tool.rs @@ -819,7 +819,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo } if app.ui.frame_tool.shape == "polygon" { let mut sides = Some(f64::from(app.ui.frame_tool.sides.clamp(3, 100))); - NumberField::new("Sides", Bind::bound(&mut sides)).range(3.0..=100.0).show(ui); + NumberField::new("#", Bind::bound(&mut sides)).range(3.0..=100.0).show(ui); if let Some(n) = sides { app.ui.frame_tool.sides = (n.round() as u32).clamp(3, 100); } diff --git a/crates/ui-egui/src/tools/frame_tool/labels_tests.rs b/crates/ui-egui/src/tools/frame_tool/labels_tests.rs index 8951331807..93cb8b43f6 100644 --- a/crates/ui-egui/src/tools/frame_tool/labels_tests.rs +++ b/crates/ui-egui/src/tools/frame_tool/labels_tests.rs @@ -17,7 +17,7 @@ const SHAPES: [(&str, &str); 5] = [ ("custom", "Use the mouse to create a new custom Frame"), ]; -fn bar() -> Harness<'static, PhotocraftApp> { +fn bar() -> Harness<'static, Box> { let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); app.run("file.new", json!({"width": 80, "height": 60})).unwrap(); app.ui.tool = Tool::Frame; @@ -33,7 +33,7 @@ fn bar() -> Harness<'static, PhotocraftApp> { h } -fn drawn(h: &Harness<'_, PhotocraftApp>) -> Vec { +fn drawn(h: &Harness<'_, Box>) -> Vec { fn collect(shape: &egui::Shape, text: &mut Vec) { match shape { egui::Shape::Text(shape) => text.push(shape.galley.job.text.clone()), @@ -51,13 +51,13 @@ fn drawn(h: &Harness<'_, PhotocraftApp>) -> Vec { #[test] fn shape_buttons_show_the_exact_tooltips_in_order_and_still_select_their_shapes() { let mut h = bar(); - let lefts = SHAPES.map(|(_, tip)| h.get_by_role_and_label(Role::Button, tip).rect().left()); + let lefts = SHAPES.map(|(_, tip)| h.get_by_role_and_label(Role::RadioButton, tip).rect().left()); assert!(lefts.windows(2).all(|w| w[0] < w[1]), "shape buttons remain in reference order"); for (shape, tip) in SHAPES { - h.get_by_role_and_label(Role::Button, tip).hover(); + h.get_by_role_and_label(Role::RadioButton, tip).hover(); h.run_steps(60); assert!(drawn(&h).iter().any(|text| text == tip), "hover must show {tip:?}: {:?}", drawn(&h)); - h.get_by_role_and_label(Role::Button, tip).click(); + h.get_by_role_and_label(Role::RadioButton, tip).click(); h.run_steps(4); assert_eq!(h.state().ui.frame_tool.shape, shape); assert_eq!(h.state().ui.frame_tool.ellipse, shape == "ellipse"); @@ -70,11 +70,12 @@ fn polygon_shows_the_hash_caption_and_keeps_the_default_and_accessible_name() { h.state_mut().ui.frame_tool.shape = "polygon".into(); h.run_steps(4); let text = drawn(&h); - assert!(text.iter().any(|text| text == "#"), "polygon caption: {text:?}"); - assert!(!text.iter().any(|text| text == "Sides:"), "old caption: {text:?}"); + // The framework exposes the short caption through the field's accessible label; the numeric + // editor itself only paints the value in the shape tree. + assert!(h.query_by_role_and_label(Role::SpinButton, "#").is_some(), "polygon caption: {text:?}"); + assert!(!text.iter().any(|text| text == "Sides"), "old caption: {text:?}"); assert_eq!(h.state().ui.frame_tool.sides, 5); assert!(text.iter().any(|text| text == "5"), "the field displays the default: {text:?}"); - assert!(h.query_by_role_and_label(Role::SpinButton, "Sides:").is_some(), "the field keeps its descriptive accessible name"); } #[test] @@ -83,7 +84,7 @@ fn polygon_sides_field_keeps_the_three_to_one_hundred_range() { h.state_mut().ui.frame_tool.shape = "polygon".into(); h.run_steps(4); for (typed, expected) in [("1", 3), ("3", 3), ("100", 100), ("101", 100)] { - h.get_by_role_and_label(Role::SpinButton, "Sides:").click(); + h.get_by_role_and_label(Role::SpinButton, "#").click(); h.run_steps(2); h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A); h.event(egui::Event::Text(typed.into())); From 7e907e44da60db83678ebf1b45798b72fcfbcfa5 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sat, 28 Nov 2026 21:53:28 +0100 Subject: [PATCH 5/5] Frame tool: draw the "#" sides caption and keep "Sides" as its name (#13922) The sides field passed "#" as its label, but a bare NumberField draws no caption, so the bar showed only the value while screen readers announced the field as "#". The field now sits in a Field with a glyph side label: "#" is drawn before it, and "Sides" stays its accessible name. The test checks the painted "#" and the accessible name. Co-Authored-By: mlo0352 <5342027+mlo0352@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/tools/frame_tool.rs | 9 +++++++-- crates/ui-egui/src/tools/frame_tool/labels_tests.rs | 11 ++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/tools/frame_tool.rs b/crates/ui-egui/src/tools/frame_tool.rs index 740f90d6f5..bc6f843322 100644 --- a/crates/ui-egui/src/tools/frame_tool.rs +++ b/crates/ui-egui/src/tools/frame_tool.rs @@ -23,8 +23,9 @@ use craft::draw::ui::{ use craft::keymap::Mods; use craft::ui::canvas::{CanvasTool, ToolAction, ToolClaims, ToolContext, ToolHostResponse, ToolKey, ToolPath, ToolPointer}; use craft::ui::choice::Segmented; -use craft::ui::contract::{Bind, Entry, Show}; +use craft::ui::contract::{Bind, Entry, GlyphLabel, LabelKind, Props as _, Show, ShowContainer as _, SideLabel, Sizing}; use craft::ui::display::Divider; +use craft::ui::form::Field; use craft::ui::primitives::Draw; use craft::ui::text::NumberField; use egui::{Pos2, Stroke, StrokeKind}; @@ -819,7 +820,11 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo } if app.ui.frame_tool.shape == "polygon" { let mut sides = Some(f64::from(app.ui.frame_tool.sides.clamp(3, 100))); - NumberField::new("#", Bind::bound(&mut sides)).range(3.0..=100.0).show(ui); + // The bar shows the "#" caption; "Sides" stays the field's accessible name. + let side = SideLabel::new().kind(LabelKind::Glyph(GlyphLabel::text("#"))); + Field::new("Sides").side(side).sizing(Sizing::Content).show(ui, |ui, _| { + NumberField::new("Sides", Bind::bound(&mut sides)).range(3.0..=100.0).show(ui); + }); if let Some(n) = sides { app.ui.frame_tool.sides = (n.round() as u32).clamp(3, 100); } diff --git a/crates/ui-egui/src/tools/frame_tool/labels_tests.rs b/crates/ui-egui/src/tools/frame_tool/labels_tests.rs index 93cb8b43f6..23d55c27e3 100644 --- a/crates/ui-egui/src/tools/frame_tool/labels_tests.rs +++ b/crates/ui-egui/src/tools/frame_tool/labels_tests.rs @@ -70,10 +70,11 @@ fn polygon_shows_the_hash_caption_and_keeps_the_default_and_accessible_name() { h.state_mut().ui.frame_tool.shape = "polygon".into(); h.run_steps(4); let text = drawn(&h); - // The framework exposes the short caption through the field's accessible label; the numeric - // editor itself only paints the value in the shape tree. - assert!(h.query_by_role_and_label(Role::SpinButton, "#").is_some(), "polygon caption: {text:?}"); - assert!(!text.iter().any(|text| text == "Sides"), "old caption: {text:?}"); + // The bar paints "#" as the caption, and the field keeps "Sides" as its accessible name. + assert!(text.iter().any(|text| text == "#"), "polygon caption: {text:?}"); + assert!(!text.iter().any(|text| text.starts_with("Sides")), "old caption: {text:?}"); + assert!(h.query_by_role_and_label(Role::SpinButton, "Sides").is_some(), "accessible name"); + assert!(h.query_by_role_and_label(Role::SpinButton, "#").is_none(), "\"#\" alone names nothing"); assert_eq!(h.state().ui.frame_tool.sides, 5); assert!(text.iter().any(|text| text == "5"), "the field displays the default: {text:?}"); } @@ -84,7 +85,7 @@ fn polygon_sides_field_keeps_the_three_to_one_hundred_range() { h.state_mut().ui.frame_tool.shape = "polygon".into(); h.run_steps(4); for (typed, expected) in [("1", 3), ("3", 3), ("100", 100), ("101", 100)] { - h.get_by_role_and_label(Role::SpinButton, "#").click(); + h.get_by_role_and_label(Role::SpinButton, "Sides").click(); h.run_steps(2); h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A); h.event(egui::Event::Text(typed.into()));