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();