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 <noreply@anthropic.com>
This commit is contained in:
Dylan M. Taylor
2026-11-29 22:26:46 +00:00
co-authored by Claude Opus 5.5
parent 5a3bae4cc0
commit 6f590e2e77
2 changed files with 29 additions and 3 deletions
+3 -3
View File
@@ -144,7 +144,7 @@ fn toolbar(ui: &mut Ui, has_selection: bool, commands: &mut Vec<Command>) {
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);
}
@@ -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();