From 3c3e08e4f9cab2672451fdb85bb55375fb10c28b Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sat, 7 Nov 2026 15:19:06 -0600 Subject: [PATCH 1/6] Count tool options bar: every control from the start in the reference order, tooltips and greying, scrubby size captions (#11765) --- crates/ui-egui/src/color_swatch_tests.rs | 3 +- crates/ui-egui/src/tools/analysis_ui.rs | 90 ++++++---- .../src/tools/count_options_bar_tests.rs | 168 ++++++++++++++++++ crates/ui-egui/src/widgets.rs | 3 +- crates/ui-egui/src/widgets/fields.rs | 7 + 5 files changed, 236 insertions(+), 35 deletions(-) create mode 100644 crates/ui-egui/src/tools/count_options_bar_tests.rs diff --git a/crates/ui-egui/src/color_swatch_tests.rs b/crates/ui-egui/src/color_swatch_tests.rs index 6a88301859..89ef2514e7 100644 --- a/crates/ui-egui/src/color_swatch_tests.rs +++ b/crates/ui-egui/src/color_swatch_tests.rs @@ -94,7 +94,8 @@ fn note_and_count_colours_open_the_color_picker() { app.ui.tool = Tool::Count; app.run("count.newGroup", json!({})).unwrap(); }); - pick(&mut h, "Color"); + // The Count swatch is "Count group color", its picker "Color Picker (Count Color)" (#11765). + assert_eq!(pick(&mut h, "Count group color"), crate::color_picker_ui::title_for("Count Color")); let st = h.state().session.active().unwrap(); let m = &st.doc.measurement; let g = &m.count_groups[m.active_count_group]; diff --git a/crates/ui-egui/src/tools/analysis_ui.rs b/crates/ui-egui/src/tools/analysis_ui.rs index ed113909a6..f4e04f930d 100644 --- a/crates/ui-egui/src/tools/analysis_ui.rs +++ b/crates/ui-egui/src/tools/analysis_ui.rs @@ -539,48 +539,68 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo let m = &doc.measurement; ui.label(RichText::new(crate::i18n::fmt(tl!("Count: {n}"), &[("n", &m.count_total().to_string())])).color(t.text).size(11.0)); crate::widgets::vline(ui, 22.0); - if !m.count_groups.is_empty() { - let mut gi = m.active_count_group.min(m.count_groups.len() - 1); + // Every control from the start, in Photoshop's order (#11765): group, eye, folder, + // trash, Clear, colour, Marker Size, Label Size. With no group yet the swatch and the + // sizes show what the next new group gets; using them, or the eye, changes nothing + // until there is a group (not measured). + let group = (!m.count_groups.is_empty()).then(|| m.active_count_group.min(m.count_groups.len() - 1)); + let next = photocraft_doc::CountGroup::default(); + let g = group.map_or(&next, |gi| &m.count_groups[gi]); + if let Some(mut gi) = group { let opts: Vec<(usize, &str)> = m.count_groups.iter().enumerate().map(|(i, g)| (i, g.name.as_str())).collect(); - if crate::widgets::dropdown(ui, "count-group", tl!("Group"), &mut gi, &opts, 140.0) { + if crate::widgets::dropdown(ui, "count-group", tl!("Group"), &mut gi, &opts, 150.0) { let _ = app.run("count.setGroup", json!({"group": gi, "active": true})); } - let g = &m.count_groups[gi]; - let eye = if g.visible { "eye" } else { "eye-off" }; - if crate::icons::button(ui, eye, 22.0, false, tl!("Toggle count group visibility")).clicked() { - let _ = app.run("count.setGroup", json!({"group": gi, "visible": !g.visible})); - } - let rgb = g.color.to_rgb(); - // PhotoCraft's Color Picker (sRGB), as everywhere else (#2144). - if crate::widgets::color_swatch_button(ui, color32(rgb), tl!("Color")).clicked() { - crate::color_picker_ui::open_for_command( - app, - &crate::color_picker_ui::title_for(tl!("Color")), - rgb, - "count.setGroup", - json!({"group": gi}), - ); - } - if crate::icons::button(ui, "trash", 22.0, false, tl!("Delete count group")).clicked() { - let _ = app.run("count.deleteGroup", json!({"group": gi})); - } + } else { + ui.add_enabled_ui(false, |ui| crate::widgets::dropdown(ui, "count-group", tl!("Group"), &mut 0usize, &[(0, tl!("Count Group"))], 150.0)); + } + let eye = if g.visible { "eye" } else { "eye-off" }; + if crate::icons::button(ui, eye, 22.0, false, tl!("Toggle visibility of count group")).clicked() + && let Some(gi) = group + { + let _ = app.run("count.setGroup", json!({"group": gi, "visible": !g.visible})); } if crate::icons::button(ui, "folder-plus", 22.0, false, tl!("Create a new count group")).clicked() { let _ = app.run("count.newGroup", json!({})); } - if crate::widgets::secondary_button(ui, tl!("Clear"), 0.0).clicked() && m.count_total() > 0 { + // The last group can't be deleted from here (`count.deleteGroup` still can). + let trash = ui.add_enabled_ui(m.count_groups.len() >= 2, |ui| { + crate::icons::button(ui, "trash", 22.0, false, tl!("Delete the currently selected count group")) + }); + if trash.inner.clicked() + && let Some(gi) = group + { + let _ = app.run("count.deleteGroup", json!({"group": gi})); + } + // Clear acts on a visible current group with markers (`count.clear` itself is unchanged). + let clearable = group.is_some() && g.visible && !g.points.is_empty(); + if ui.add_enabled_ui(clearable, |ui| crate::widgets::secondary_button(ui, tl!("Clear"), 0.0)).inner.clicked() { let _ = app.run("count.clear", json!({})); } - if let Some(g) = m.count_groups.get(m.active_count_group) { - crate::widgets::vline(ui, 22.0); - let (mut ms, mut ls) = (g.marker_size as f32, g.label_size as f32); - ui.label(RichText::new(tl!("Marker Size")).color(t.text_dim).size(11.0)); - let a = crate::widgets::value_field(ui, &mut ms, 1.0..=10.0, "", 40.0).accessible_name(tl!("Marker Size")).changed(); - ui.label(RichText::new(tl!("Label Size")).color(t.text_dim).size(11.0)); - let b = crate::widgets::value_field(ui, &mut ls, 8.0..=72.0, "", 44.0).accessible_name(tl!("Label Size")).changed(); - if a || b { - let _ = app.run("count.setGroup", count_size_params(ms, ls)); - } + let rgb = g.color.to_rgb(); + // PhotoCraft's Color Picker (sRGB), as everywhere else (#2144). + if crate::widgets::color_swatch_button(ui, color32(rgb), tl!("Count group color")).on_hover_text(tl!("Count group color")).clicked() + && let Some(gi) = group + { + crate::color_picker_ui::open_for_command( + app, + &crate::color_picker_ui::title_for(tl!("Count Color")), + rgb, + "count.setGroup", + json!({"group": gi}), + ); + } + crate::widgets::vline(ui, 22.0); + let (mut ms, mut ls) = (g.marker_size as f32, g.label_size as f32); + // Scrubby captions with colons, as in Photoshop: the options bar's own caption, which + // scrubs the field after it when dragged. + let caption = |ui: &mut egui::Ui, text: &str| crate::panels::opt_label(ui, text); + caption(ui, "Marker Size:"); + let a = crate::widgets::value_field_whole(ui, &mut ms, 1.0..=10.0, "", 40.0).accessible_name(tl!("Marker Size")).changed(); + caption(ui, "Label Size:"); + let b = crate::widgets::value_field_whole(ui, &mut ls, 8.0..=72.0, "", 44.0).accessible_name(tl!("Label Size")).changed(); + if (a || b) && group.is_some() { + let _ = app.run("count.setGroup", count_size_params(ms, ls)); } true } @@ -1091,3 +1111,7 @@ pub fn note_keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool { #[cfg(test)] #[path = "note_delete_key_tests.rs"] mod note_delete_key_tests; + +#[cfg(test)] +#[path = "count_options_bar_tests.rs"] +mod count_options_bar_tests; diff --git a/crates/ui-egui/src/tools/count_options_bar_tests.rs b/crates/ui-egui/src/tools/count_options_bar_tests.rs new file mode 100644 index 0000000000..7582f8bda4 --- /dev/null +++ b/crates/ui-egui/src/tools/count_options_bar_tests.rs @@ -0,0 +1,168 @@ +//! #11765: the Count tool's options bar shows every control from the start, in Photoshop's order, +//! with its tooltips, and greys what can't act: the group dropdown until there is a group, the +//! trash with fewer than two groups, Clear while the current group is empty or hidden. + +use egui::vec2; +use egui_kittest::Harness; +use egui_kittest::kittest::{NodeT, Queryable}; +use serde_json::json; + +use crate::PhotocraftApp; +use crate::state::Tool; + +const EYE: &str = "Toggle visibility of count group"; +const FOLDER: &str = "Create a new count group"; +const TRASH: &str = "Delete the currently selected count group"; +const SWATCH: &str = "Count group color"; + +/// A 100 × 100 document with the Count tool and `groups` count groups (the first with a marker). +fn app(groups: usize) -> PhotocraftApp { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 100, "height": 100})).unwrap(); + app.ui.tool = Tool::Count; + if groups > 0 { + app.run("count.add", json!({"x": 10, "y": 10})).unwrap(); + } + for _ in 1..groups { + app.run("count.newGroup", json!({})).unwrap(); + } + if groups > 0 { + app.run("count.setGroup", json!({"group": 0, "active": true})).unwrap(); + } + app +} + +fn harness(app: PhotocraftApp) -> Harness<'static, PhotocraftApp> { + let mut h = Harness::builder().with_size(vec2(1400.0, 120.0)).build_ui_state( + |ui, app: &mut PhotocraftApp| { + if !ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { + return; + } + crate::panels::options_bar(app, ui); + }, + app, + ); + PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::Studio); + h.run_steps(4); + h +} + +fn disabled(h: &Harness<'static, PhotocraftApp>, label: &str) -> bool { + h.get_by_label(label).accesskit_node().is_disabled() +} + +fn combo_disabled(h: &Harness<'static, PhotocraftApp>) -> bool { + h.get_all_by_role(egui::accesskit::Role::ComboBox).next().expect("the group dropdown").accesskit_node().is_disabled() +} + +#[test] +fn the_controls_are_in_the_reference_order_in_every_state() { + for groups in [0, 1, 2] { + let h = harness(app(groups)); + let x = |label: &str| h.get_by_label(label).rect().left(); + let combo = h.get_all_by_role(egui::accesskit::Role::ComboBox).next().expect("the group dropdown").rect().left(); + let order = [combo, x(EYE), x(FOLDER), x(TRASH), x("Clear"), x(SWATCH), x("Marker Size:"), x("Label Size:")]; + assert!(order.windows(2).all(|w| w[0] < w[1]), "{groups} groups: left edges {order:?}"); + let count = h.get_all_by_label_contains("Count: ").next().expect("the Count: readout").rect().left(); + assert!(count < combo, "{groups} groups: the readout comes first"); + } +} + +#[test] +fn with_no_group_the_dropdown_trash_and_clear_are_greyed_and_the_next_groups_values_show() { + let h = harness(app(0)); + assert!(combo_disabled(&h), "the dropdown is greyed"); + let combo = h.get_all_by_role(egui::accesskit::Role::ComboBox).next().unwrap(); + let node = combo.accesskit_node(); + assert_eq!(node.value().as_deref(), Some("Count Group"), "with the placeholder"); + assert!(disabled(&h, TRASH) && disabled(&h, "Clear")); + assert!(!disabled(&h, EYE) && !disabled(&h, FOLDER)); + // The sizes the next new group gets today. + let next = photocraft_doc::CountGroup::default(); + assert!(h.query_by_value(&next.marker_size.to_string()).is_some(), "Marker Size {}", next.marker_size); + assert!(h.query_by_value(&next.label_size.to_string()).is_some(), "Label Size {}", next.label_size); +} + +#[test] +fn using_the_eye_with_no_group_changes_nothing() { + let mut h = harness(app(0)); + let steps = h.state().session.active().unwrap().history.past_len(); + h.get_by_label(EYE).click(); + h.run_steps(3); + let st = h.state().session.active().unwrap(); + assert!(st.doc.measurement.count_groups.is_empty()); + assert_eq!(st.history.past_len(), steps); +} + +#[test] +fn the_trash_needs_two_groups() { + assert!(disabled(&harness(app(1)), TRASH), "one group"); + let mut h = harness(app(2)); + assert!(!disabled(&h, TRASH), "two groups"); + h.get_by_label(TRASH).click(); + h.run_steps(3); + assert_eq!(h.state().session.active().unwrap().doc.measurement.count_groups.len(), 1); + assert!(disabled(&h, TRASH), "back to one group"); +} + +#[test] +fn clear_needs_a_visible_current_group_with_markers() { + let h = harness(app(1)); + assert!(!disabled(&h, "Clear"), "one marker, visible"); + let mut hidden = app(1); + hidden.run("count.setGroup", json!({"visible": false})).unwrap(); + assert!(disabled(&harness(hidden), "Clear"), "hidden"); + let mut empty = app(2); + empty.run("count.setGroup", json!({"group": 1, "active": true})).unwrap(); + assert!(disabled(&harness(empty), "Clear"), "the current group has no markers"); +} + +#[test] +fn the_swatch_opens_the_count_color_picker() { + let mut h = harness(app(1)); + h.get_by_label(SWATCH).click(); + h.run_steps(3); + let want = crate::color_picker_ui::title_for("Count Color"); + assert_eq!(want, "Color Picker (Count Color)"); + assert!(h.state().ui.dialogs.iter().any(|d| crate::dialogs::title(d) == want), "a picker titled {want}"); +} + +#[test] +fn the_size_captions_scrub_their_fields() { + let mut h = harness(app(1)); + // The visible caption, not the field it names (`get_by_label` returns the labelled field). + let from = h + .query_all(egui_kittest::kittest::by().label("Marker Size:").include_labels()) + .find(|n| n.accesskit_node().role() == egui::accesskit::Role::Label) + .expect("the Marker Size: caption") + .rect() + .center(); + // As the Brush options' scrub test drives a caption (options_hit_area_tests): hover, press, + // move in steps, release, letting each step settle. + h.hover_at(from); + h.run(); + h.drag_at(from); + h.run(); + for i in 1..=4 { + h.event(egui::Event::ModifiersChanged(egui::Modifiers::NONE)); + h.hover_at(from + vec2(12.0 * i as f32, 0.0)); + h.run(); + } + h.drop_at(from + vec2(48.0, 0.0)); + h.run_steps(2); + let g = &h.state().session.active().unwrap().doc.measurement.count_groups[0]; + assert!(g.marker_size > 1, "dragging the caption right raised Marker Size: {}", g.marker_size); + assert!(g.marker_size <= 10, "within its range"); +} + +#[test] +fn automation_delete_and_clear_work_as_today() { + // The greying is the options bar's: the commands still delete the last group and clear a + // hidden one. + let mut app = app(1); + app.run("count.setGroup", json!({"visible": false})).unwrap(); + app.run("count.clear", json!({})).unwrap(); + assert_eq!(app.session.active().unwrap().doc.measurement.count_total(), 0); + app.run("count.deleteGroup", json!({})).unwrap(); + assert!(app.session.active().unwrap().doc.measurement.count_groups.is_empty()); +} diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs index 3b4320dd0d..5cf0b1ca3b 100644 --- a/crates/ui-egui/src/widgets.rs +++ b/crates/ui-egui/src/widgets.rs @@ -50,7 +50,8 @@ pub(crate) use fields::compact_wrapping_value_field; #[cfg(test)] use fields::{FieldOpts, NUMERIC_INPUT_LIMIT, value_field_in}; pub use fields::{ - POPUP_ARROW_W, PopupFieldResponse, VALUE_FIELD_H, compact_value_field, elided_label, elided_label_sensed, popup_value_field, value_field, value_field_named, + POPUP_ARROW_W, PopupFieldResponse, VALUE_FIELD_H, compact_value_field, elided_label, elided_label_sensed, popup_value_field, value_field, + value_field_named, value_field_whole, }; pub(crate) use panel::body_margin; pub use panel::{ diff --git a/crates/ui-egui/src/widgets/fields.rs b/crates/ui-egui/src/widgets/fields.rs index c0030bd9c8..1cedd85244 100644 --- a/crates/ui-egui/src/widgets/fields.rs +++ b/crates/ui-egui/src/widgets/fields.rs @@ -12,6 +12,13 @@ pub fn value_field(ui: &mut Ui, value: &mut f32, range: std::ops::RangeInclusive value_field_in(ui, value, range, suffix, width, 0.0, FieldOpts::default(), None).0 } +/// A [`value_field`] for a whole number: no decimals, and the arrow keys and a scrub (of the field +/// or of its caption) move it a whole step at a time, whatever its range. A small range such as +/// 1–10 would otherwise scrub in hundredths, which a whole-number setting rounds away (#11765). +pub fn value_field_whole(ui: &mut Ui, value: &mut f32, range: std::ops::RangeInclusive, suffix: &str, width: f32) -> Response { + value_field_in(ui, value, range, suffix, width, 0.0, FieldOpts { decimals: Some(0), step_from_decimals: true, ..Default::default() }, None).0 +} + /// A [`value_field`] whose visible caption was drawn apart from it (an options-bar caption in a /// nested layout): `name` names the number when the caption's scrub link did not reach it. pub fn value_field_named(ui: &mut Ui, name: &str, value: &mut f32, range: std::ops::RangeInclusive, suffix: &str, width: f32) -> Response { From 20b989fb927b0ae921ddd7a59b828b8494230d95 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sat, 7 Nov 2026 16:05:05 -0600 Subject: [PATCH 2/6] Count size scrubs: one history step per drag (CodeRabbit review on crates/ui-egui/src/tools/analysis_ui.rs:603) A scrub of Marker Size or Label Size (the field or its caption) sent several count.setGroup commands without a coalesce key, so one drag took several Undo steps. Each drag now gets its own key, as the Gradient tool's Opacity does; typed and arrow-key edits stay one step each. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/tools/analysis_ui.rs | 22 +++++++++-- .../src/tools/count_options_bar_tests.rs | 37 +++++++++++++++++++ 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/tools/analysis_ui.rs b/crates/ui-egui/src/tools/analysis_ui.rs index f4e04f930d..4a3a743d5e 100644 --- a/crates/ui-egui/src/tools/analysis_ui.rs +++ b/crates/ui-egui/src/tools/analysis_ui.rs @@ -596,11 +596,25 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo // scrubs the field after it when dragged. let caption = |ui: &mut egui::Ui, text: &str| crate::panels::opt_label(ui, text); caption(ui, "Marker Size:"); - let a = crate::widgets::value_field_whole(ui, &mut ms, 1.0..=10.0, "", 40.0).accessible_name(tl!("Marker Size")).changed(); + let a = crate::widgets::value_field_whole(ui, &mut ms, 1.0..=10.0, "", 40.0).accessible_name(tl!("Marker Size")); caption(ui, "Label Size:"); - let b = crate::widgets::value_field_whole(ui, &mut ls, 8.0..=72.0, "", 44.0).accessible_name(tl!("Label Size")).changed(); - if (a || b) && group.is_some() { - let _ = app.run("count.setGroup", count_size_params(ms, ls)); + let b = crate::widgets::value_field_whole(ui, &mut ls, 8.0..=72.0, "", 44.0).accessible_name(tl!("Label Size")); + // One undo step per scrub (of a field or its caption), as the Gradient tool's Opacity. + let drag = |r: &egui::Response| { + let key = r.id.with("count-size-drag"); + if r.drag_started() { + let n = ui.ctx().cumulative_pass_nr(); + ui.data_mut(|d| d.insert_temp(key, n)); + } + if r.changed() && r.dragged() { ui.data(|d| d.get_temp::(key)).map(|n| format!("count-size:{}:{n}", key.value())) } else { None } + }; + let coalesce = drag(&a).or(drag(&b)); + if (a.changed() || b.changed()) && group.is_some() { + let mut p = count_size_params(ms, ls); + if let Some(k) = coalesce { + p["coalesce"] = json!(k); + } + let _ = app.run("count.setGroup", p); } true } diff --git a/crates/ui-egui/src/tools/count_options_bar_tests.rs b/crates/ui-egui/src/tools/count_options_bar_tests.rs index 7582f8bda4..73b52a58bf 100644 --- a/crates/ui-egui/src/tools/count_options_bar_tests.rs +++ b/crates/ui-egui/src/tools/count_options_bar_tests.rs @@ -155,6 +155,43 @@ fn the_size_captions_scrub_their_fields() { assert!(g.marker_size <= 10, "within its range"); } +/// Drags the visible "Marker Size:" caption `dx` points right in four moves. +fn scrub_marker_size(h: &mut Harness<'static, PhotocraftApp>, dx: f32) { + let from = h + .query_all(egui_kittest::kittest::by().label("Marker Size:").include_labels()) + .find(|n| n.accesskit_node().role() == egui::accesskit::Role::Label) + .expect("the Marker Size: caption") + .rect() + .center(); + h.hover_at(from); + h.run(); + h.drag_at(from); + h.run(); + for i in 1..=4 { + h.event(egui::Event::ModifiersChanged(egui::Modifiers::NONE)); + h.hover_at(from + vec2(dx / 4.0 * i as f32, 0.0)); + h.run(); + } + h.drop_at(from + vec2(dx, 0.0)); + h.run_steps(2); +} + +#[test] +fn one_size_scrub_is_one_history_step() { + let mut h = harness(app(1)); + let steps = |h: &Harness<'static, PhotocraftApp>| h.state().session.active().unwrap().history.past_len(); + let before = steps(&h); + scrub_marker_size(&mut h, 24.0); + let size = h.state().session.active().unwrap().doc.measurement.count_groups[0].marker_size; + assert!(size > 2, "the scrub moved Marker Size several steps: {size}"); + assert_eq!(steps(&h), before + 1, "one scrub, one Undo step"); + // Back left, as the first may have reached the top of the range. + scrub_marker_size(&mut h, -24.0); + let back = h.state().session.active().unwrap().doc.measurement.count_groups[0].marker_size; + assert!(back < size, "the second scrub moved it back: {size} -> {back}"); + assert_eq!(steps(&h), before + 2, "a second scrub is a step of its own"); +} + #[test] fn automation_delete_and_clear_work_as_today() { // The greying is the options bar's: the commands still delete the last group and clear a From 012b13387a94ce64a032b574283e76e48a929387 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sat, 7 Nov 2026 18:13:43 -0600 Subject: [PATCH 3/6] Count size captions: translate the names, then add the colon (eliets2 review on crates/ui-egui/src/tools/analysis_ui.rs, size captions) "Marker Size:" and "Label Size:" have no catalog entries, so the captions stayed English in every language; the catalogs translate "Marker Size" and "Label Size", which main showed. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/tools/analysis_ui.rs | 9 +++++---- .../src/tools/count_options_bar_tests.rs | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/tools/analysis_ui.rs b/crates/ui-egui/src/tools/analysis_ui.rs index 4a3a743d5e..748130486b 100644 --- a/crates/ui-egui/src/tools/analysis_ui.rs +++ b/crates/ui-egui/src/tools/analysis_ui.rs @@ -593,11 +593,12 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo crate::widgets::vline(ui, 22.0); let (mut ms, mut ls) = (g.marker_size as f32, g.label_size as f32); // Scrubby captions with colons, as in Photoshop: the options bar's own caption, which - // scrubs the field after it when dragged. - let caption = |ui: &mut egui::Ui, text: &str| crate::panels::opt_label(ui, text); - caption(ui, "Marker Size:"); + // scrubs the field after it when dragged. The catalogs translate the names without + // the colon (main's captions), so the colon follows the translation. + let caption = |ui: &mut egui::Ui, text: &str| crate::panels::opt_label(ui, &format!("{text}:")); + caption(ui, tl!("Marker Size")); let a = crate::widgets::value_field_whole(ui, &mut ms, 1.0..=10.0, "", 40.0).accessible_name(tl!("Marker Size")); - caption(ui, "Label Size:"); + caption(ui, tl!("Label Size")); let b = crate::widgets::value_field_whole(ui, &mut ls, 8.0..=72.0, "", 44.0).accessible_name(tl!("Label Size")); // One undo step per scrub (of a field or its caption), as the Gradient tool's Opacity. let drag = |r: &egui::Response| { diff --git a/crates/ui-egui/src/tools/count_options_bar_tests.rs b/crates/ui-egui/src/tools/count_options_bar_tests.rs index 73b52a58bf..837832b746 100644 --- a/crates/ui-egui/src/tools/count_options_bar_tests.rs +++ b/crates/ui-egui/src/tools/count_options_bar_tests.rs @@ -203,3 +203,21 @@ fn automation_delete_and_clear_work_as_today() { app.run("count.deleteGroup", json!({})).unwrap(); assert!(app.session.active().unwrap().doc.measurement.count_groups.is_empty()); } + +/// The visible caption node (a `Role::Label`) reading `text`, if any. +fn caption_node(h: &Harness<'static, PhotocraftApp>, text: &str) -> bool { + h.query_all(egui_kittest::kittest::by().label(text).include_labels()).any(|n| n.accesskit_node().role() == egui::accesskit::Role::Label) +} + +#[test] +fn the_size_captions_are_translated() { + // The catalogs translate "Marker Size" and "Label Size" (main's captions); the colon follows. + let _de = crate::i18n::language_scope(crate::i18n::Lang::from_code("de").expect("German")); + let h = harness(app(1)); + for (english, key) in [("Marker Size:", "Marker Size"), ("Label Size:", "Label Size")] { + let want = format!("{}:", crate::i18n::t(key)); + assert_ne!(want, english, "German has a translation of {key}"); + assert!(caption_node(&h, &want), "the caption reads {want}"); + assert!(!caption_node(&h, english), "not the English {english}"); + } +} From 79785f60e2b67af1d79f0305a55a5ef8dd8cab3f Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sat, 7 Nov 2026 18:14:51 -0600 Subject: [PATCH 4/6] Count size fields: named by their visible captions (eliets2 review on crates/ui-egui/src/tools/analysis_ui.rs, size field names) The explicit "Marker Size" / "Label Size" names overrode the caption link, so a screen reader read a name that differed from the "Marker Size:" / "Label Size:" shown. The scrubby caption already names its field. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/tools/analysis_ui.rs | 5 +++-- crates/ui-egui/src/tools/count_options_bar_tests.rs | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/tools/analysis_ui.rs b/crates/ui-egui/src/tools/analysis_ui.rs index 748130486b..045e3a7803 100644 --- a/crates/ui-egui/src/tools/analysis_ui.rs +++ b/crates/ui-egui/src/tools/analysis_ui.rs @@ -596,10 +596,11 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo // scrubs the field after it when dragged. The catalogs translate the names without // the colon (main's captions), so the colon follows the translation. let caption = |ui: &mut egui::Ui, text: &str| crate::panels::opt_label(ui, &format!("{text}:")); + // Each caption names its field (the scrub link), so a screen reader reads what is shown. caption(ui, tl!("Marker Size")); - let a = crate::widgets::value_field_whole(ui, &mut ms, 1.0..=10.0, "", 40.0).accessible_name(tl!("Marker Size")); + let a = crate::widgets::value_field_whole(ui, &mut ms, 1.0..=10.0, "", 40.0); caption(ui, tl!("Label Size")); - let b = crate::widgets::value_field_whole(ui, &mut ls, 8.0..=72.0, "", 44.0).accessible_name(tl!("Label Size")); + let b = crate::widgets::value_field_whole(ui, &mut ls, 8.0..=72.0, "", 44.0); // One undo step per scrub (of a field or its caption), as the Gradient tool's Opacity. let drag = |r: &egui::Response| { let key = r.id.with("count-size-drag"); diff --git a/crates/ui-egui/src/tools/count_options_bar_tests.rs b/crates/ui-egui/src/tools/count_options_bar_tests.rs index 837832b746..35f1455c50 100644 --- a/crates/ui-egui/src/tools/count_options_bar_tests.rs +++ b/crates/ui-egui/src/tools/count_options_bar_tests.rs @@ -221,3 +221,12 @@ fn the_size_captions_are_translated() { assert!(!caption_node(&h, english), "not the English {english}"); } } + +#[test] +fn the_size_fields_are_named_by_their_visible_captions() { + let h = harness(app(1)); + for caption in ["Marker Size:", "Label Size:"] { + let fields = h.query_all(egui_kittest::kittest::by().label(caption).predicate(|n| n.role() != egui::accesskit::Role::Label)).count(); + assert_eq!(fields, 1, "one field named {caption}, as its caption reads"); + } +} From 0aad9475ab48a5caa7b7ca00965495ba4bdb0665 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sat, 7 Nov 2026 21:33:00 -0600 Subject: [PATCH 5/6] Count size caption test: a missing German row may show the English (CodeRabbit review on crates/ui-egui/src/tools/count_options_bar_tests.rs:221) docs/contributing.md: tests never require a string to be translated. The test asserted that German has a row for "Marker Size" and "Label Size" and that the English caption is absent, so it failed whenever a catalog row went missing. It now checks only that each caption reads the translated name (the English when a row is missing) plus the colon, which still catches an untranslated caption while the rows exist. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/tools/count_options_bar_tests.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/tools/count_options_bar_tests.rs b/crates/ui-egui/src/tools/count_options_bar_tests.rs index 35f1455c50..31d2e98ea7 100644 --- a/crates/ui-egui/src/tools/count_options_bar_tests.rs +++ b/crates/ui-egui/src/tools/count_options_bar_tests.rs @@ -212,13 +212,12 @@ fn caption_node(h: &Harness<'static, PhotocraftApp>, text: &str) -> bool { #[test] fn the_size_captions_are_translated() { // The catalogs translate "Marker Size" and "Label Size" (main's captions); the colon follows. + // A missing catalog row shows the English, so the test doesn't require the translation. let _de = crate::i18n::language_scope(crate::i18n::Lang::from_code("de").expect("German")); let h = harness(app(1)); - for (english, key) in [("Marker Size:", "Marker Size"), ("Label Size:", "Label Size")] { + for key in ["Marker Size", "Label Size"] { let want = format!("{}:", crate::i18n::t(key)); - assert_ne!(want, english, "German has a translation of {key}"); assert!(caption_node(&h, &want), "the caption reads {want}"); - assert!(!caption_node(&h, english), "not the English {english}"); } } From ae2be4c786ac91737431139006c2f310eb03ad1e Mon Sep 17 00:00:00 2001 From: David Mann Date: Wed, 11 Nov 2026 21:09:48 +0100 Subject: [PATCH 6/6] Count size caption test: skip without the craft-i18n catalogs (PR #12206) Main moved the catalogs out to the optional craft-i18n build input; built without it, Lang::from_code("de") is None and the test's expect panicked. It now skips like main's other translation tests (needs_catalogs). Co-Authored-By: Hector Villarreal Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/tools/count_options_bar_tests.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/ui-egui/src/tools/count_options_bar_tests.rs b/crates/ui-egui/src/tools/count_options_bar_tests.rs index 31d2e98ea7..3a2e9c1f20 100644 --- a/crates/ui-egui/src/tools/count_options_bar_tests.rs +++ b/crates/ui-egui/src/tools/count_options_bar_tests.rs @@ -213,6 +213,9 @@ fn caption_node(h: &Harness<'static, PhotocraftApp>, text: &str) -> bool { fn the_size_captions_are_translated() { // The catalogs translate "Marker Size" and "Label Size" (main's captions); the colon follows. // A missing catalog row shows the English, so the test doesn't require the translation. + if !crate::i18n::needs_catalogs() { + return; + } let _de = crate::i18n::language_scope(crate::i18n::Lang::from_code("de").expect("German")); let h = harness(app(1)); for key in ["Marker Size", "Label Size"] {