From 6f590e2e77894cd8105668b2a0c8ec5dc45c0953 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 29 Nov 2026 22:26:46 +0000 Subject: [PATCH] Selection pane: eye and padlock on every row, up before down The eye and lock cells showed their off icon only under the pointer, so an unlocked shape offered no padlock to lock it and a hidden group showed no eye. Both cells now show in every row. The move buttons read Bring Forward then Send Backward. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/panels/selpane.rs | 6 ++--- crates/ui-egui/src/panels/selpane/ui_tests.rs | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/panels/selpane.rs b/crates/ui-egui/src/panels/selpane.rs index b14240e00..e1c481869 100644 --- a/crates/ui-egui/src/panels/selpane.rs +++ b/crates/ui-egui/src/panels/selpane.rs @@ -144,7 +144,7 @@ fn toolbar(ui: &mut Ui, has_selection: bool, commands: &mut Vec) { Bar::new("Selection actions", BarKind::Tool) .trailing(|ui, _| { for (icon, label, command) in - [(Icon::ChevronDown, "Send Backward", "arrange.sendBackward"), (Icon::ChevronUp, "Bring Forward", "arrange.bringForward")] + [(Icon::ChevronUp, "Bring Forward", "arrange.bringForward"), (Icon::ChevronDown, "Send Backward", "arrange.sendBackward")] { if IconButton::new(icon.id()).label(label).enabled(has_selection).show(ui).clicked() { trailing.push((command, json!({}))); @@ -196,8 +196,8 @@ pub fn show(app: &mut SlideApp, ui: &mut Ui) { let mut line = ListRow::new(row.name.clone()) .depth(row.depth) .cells(icx.cells()) - .toggle(ToggleCell::eye(EYE, !row.hidden).name(if row.hidden { "Show {row}" } else { "Hide {row}" })) - .toggle(ToggleCell::lock(LOCK, row.locked).name(if row.locked { "Unlock {row}" } else { "Lock {row}" })); + .toggle(ToggleCell::eye(EYE, !row.hidden).name(if row.hidden { "Show {row}" } else { "Hide {row}" }).always_visible()) + .toggle(ToggleCell::lock(LOCK, row.locked).name(if row.locked { "Unlock {row}" } else { "Lock {row}" }).always_visible()); if row.group { line = line.group(icx.row.open); } diff --git a/crates/ui-egui/src/panels/selpane/ui_tests.rs b/crates/ui-egui/src/panels/selpane/ui_tests.rs index 2296f5238..5e77278e8 100644 --- a/crates/ui-egui/src/panels/selpane/ui_tests.rs +++ b/crates/ui-egui/src/panels/selpane/ui_tests.rs @@ -79,6 +79,32 @@ fn lists_front_most_first_with_groups_expanded() { assert!(h.query_by_label("Hide A").is_some() && h.query_by_label("Lock A").is_some()); } +/// Whether something is painted inside the node named `label`. +fn paints_inside(h: &Harness<'_, SlideApp>, label: &str) -> bool { + fn any(shape: &egui::Shape, within: egui::Rect) -> bool { + match shape { + egui::Shape::Vec(shapes) => shapes.iter().any(|shape| any(shape, within)), + shape => { + let bounds = shape.visual_bounding_rect(); + bounds.is_positive() && within.expand(0.5).contains_rect(bounds) + } + } + } + let cell = h.get_by_label(label).rect(); + h.output().shapes.iter().any(|shape| any(&shape.shape, cell)) +} + +#[test] +fn an_unlocked_row_and_a_hidden_group_show_their_toggles_without_the_pointer() { + let (mut h, ids) = harness(); + h.state_mut().run("shape.visible", json!({"id": ids[5], "visible": false})).unwrap(); + h.run_steps(3); + h.hover_at(Pos2::new(1.0, 1.0)); + h.run_steps(2); + assert!(paints_inside(&h, "Lock A"), "an unlocked shape shows the padlock it is locked with"); + assert!(paints_inside(&h, "Show G"), "a hidden group shows its struck eye"); +} + #[test] fn click_ctrl_click_and_shift_click_select() { let (mut h, _) = harness();