From 9970a37c6c3b9af61191f58385c305d8de515d2d Mon Sep 17 00:00:00 2001 From: David Mann Date: Thu, 26 Nov 2026 16:44:41 +0100 Subject: [PATCH 1/2] WIP: tool flyouts mark only the shown tool (photocraft#17102) Co-Authored-By: Claude Opus 5.5 From eec33e6082b3c5576310f118b4d536493014e05e Mon Sep 17 00:00:00 2001 From: David Mann Date: Thu, 26 Nov 2026 17:36:59 +0100 Subject: [PATCH 2/2] ui-panels: a tool flyout checks the shown tool and marks no other row The flyout marked each row with radio_mark(tool.id == shown), and an unchosen radio row paints an empty ring, so every other tool had a circle before it. Rows now take check(tool.id == shown): a check before the shown tool and nothing before the others, as the reference application's tool flyouts show (photocraft#17102). The mark column stays reserved, so icons and labels keep their alignment. Co-Authored-By: Claude Opus 5.5 --- crates/ui-panels/src/rails/flyout.rs | 16 ++++++++------- crates/ui-panels/tests/it/rails/mod.rs | 27 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/crates/ui-panels/src/rails/flyout.rs b/crates/ui-panels/src/rails/flyout.rs index deca16fdbc..97aa8e81ad 100644 --- a/crates/ui-panels/src/rails/flyout.rs +++ b/crates/ui-panels/src/rails/flyout.rs @@ -111,9 +111,9 @@ struct Laid { /// One rail button that may stand for a group of tools. The face shows the tool `shown` with a mark at the corner /// when there is a flyout. A click, Enter or Space selects the shown tool and runs its command; holding the press, /// dragging it away from the button, a right click or the Menu key opens the flyout; a press on the corner mark opens it -/// at once; after a press that opened it, releasing over a row picks it. Rows are the tools' commands, the shown tool with the radio mark. A hold selects the shown tool -/// unless `hold_selects` is off, as for a command button. An Alt-click selects the next enabled tool of the slot, -/// wrapping, and opens no flyout. With a `click` command, a click fires that command and selects nothing, and the +/// at once; after a press that opened it, releasing over a row picks it. Rows are the tools' commands, the shown tool +/// with a check mark and the others with none. A hold selects the shown tool unless `hold_selects` is off, as for a +/// command button. An Alt-click selects the next enabled tool of the slot, wrapping, and opens no flyout. With a `click` command, a click fires that command and selects nothing, and the /// release that ends a hold fires nothing. A modified press is never a double click. /// /// With `tear_off` a bar runs down the flyout's end edge, named by `RailWords::tear_off`: a press on it dragged past @@ -372,9 +372,9 @@ impl Component for FlyoutButton<'_, T> { } } - /// The flyout: one row per tool, each the tool's command, the shown tool with the radio mark, and with `tear_off` - /// the bar beside the rows. Running a row reports its tool and closes the flyout; tearing it off by the bar - /// reports the pointer and closes it. + /// The flyout: one row per tool, each the tool's command, the shown tool with a check mark and the others with + /// none, and with `tear_off` the bar beside the rows. Running a row reports its tool and closes the flyout; tearing + /// it off by the bar reports the pointer and closes it. fn overlay(&mut self, ui: &mut OverlayUi<'_>, cx: &mut Cx<'_, Self>) { if !self.has_flyout() { return; @@ -394,7 +394,9 @@ impl Component for FlyoutButton<'_, T> { let rows = Menu::inline(name.clone()).show(ui, |ui, _| { let mut ran = None; for (at, tool) in tools.iter().enumerate() { - let mut item = MenuItem::command(tool.command.clone()).radio_mark(tool.id == *shown); + // A check before the shown tool and nothing before the others, as the reference application's + // flyouts do: an unchosen radio row would draw an empty ring before every other tool. + let mut item = MenuItem::command(tool.command.clone()).check(tool.id == *shown); if let Some(icon) = &tool.icon { item = item.icon(icon.clone()); } diff --git a/crates/ui-panels/tests/it/rails/mod.rs b/crates/ui-panels/tests/it/rails/mod.rs index 743f26dae1..75f5937b7d 100644 --- a/crates/ui-panels/tests/it/rails/mod.rs +++ b/crates/ui-panels/tests/it/rails/mod.rs @@ -111,6 +111,33 @@ fn dragging_a_press_away_opens_the_flyout_and_releasing_over_a_row_picks_it() { assert_eq!(*dragged.selected.borrow(), [REDO], "releasing over Redo picks it and nothing else"); } +/// The flyout marks only the shown tool, with a check, as the reference application's tool flyouts do: the other +/// rows draw no mark, not the empty ring of an unchosen radio row (photocraft#17102). +#[trial] +fn the_flyout_checks_the_shown_tool_and_marks_no_other_row() { + let mut held = rig(true); + let target = button(&held); + held.fixture.press(&target); + held.fixture.advance(HELD); + held.fixture.idle(3); + assert!(!held.fixture.by_role(Role::MENU).is_empty(), "a held press opens the flyout"); + // The rows, not the rail button that also bears the shown tool's name. + let checked = |fixture: &Fixture, label: &str| { + let rows = fixture.by_role(Role::MENU_ITEM_CHECK_BOX); + let row = rows.iter().find(|row| fixture.tree().name_of(row.node) == Some(label)); + fixture.tree().toggled_of(row.unwrap_or_else(|| panic!("the flyout lists {label}")).node) + }; + assert_eq!(checked(&held.fixture, "Undo"), Some(Mixed::Same(true)), "the shown tool's row is checked"); + assert_eq!(checked(&held.fixture, "Redo"), Some(Mixed::Same(false)), "another tool's row is not"); + let rings = held + .fixture + .frame_shapes() + .iter() + .filter(|shape| matches!(shape, egui::Shape::Circle(circle) if circle.stroke.width > 0.0 && circle.fill == egui::Color32::TRANSPARENT)) + .count(); + assert_eq!(rings, 0, "no row of the flyout draws an empty ring"); +} + /// A flyout of a tool low on the rail, too tall for the room under the tool's top, slides up to stay in the window /// as PhotoCraft's tool flyouts do, rather than opening upward from the tool as a submenu does. #[trial]