diff --git a/crates/ui-egui/src/layer_row_ui/tests.rs b/crates/ui-egui/src/layer_row_ui/tests.rs index a5c9ed3834..26bd8ee538 100644 --- a/crates/ui-egui/src/layer_row_ui/tests.rs +++ b/crates/ui-egui/src/layer_row_ui/tests.rs @@ -653,9 +653,7 @@ fn eye_column_edges_toggle_visibility_without_selecting_layer() { let visible = |h: &Harness<'_, PhotocraftApp>, id: u64| h.state().session.active().unwrap().doc.layer(photocraft_doc::LayerId(id)).unwrap().visible; let selected = |h: &Harness<'_, PhotocraftApp>| h.state().session.active().unwrap().active_layer.unwrap().0; - let row_for = |h: &Harness<'_, PhotocraftApp>, id: u64| { - recorded(&h.ctx).into_iter().find(|r| r.layer == id).unwrap().row - }; + let row_for = |h: &Harness<'_, PhotocraftApp>, id: u64| recorded(&h.ctx).into_iter().find(|r| r.layer == id).unwrap().row; let top_row = row_for(&h, l1); // Click at the far left edge of the eye column (left + 1.0, top + 1.0) @@ -673,3 +671,34 @@ fn eye_column_edges_toggle_visibility_without_selecting_layer() { assert_eq!(selected(&h), l0, "click on eye column must not select the layer"); } +/// #1662: a hidden layer's eye box stays empty, as in Photoshop (only a visible layer paints its +/// eye), in every theme; the widened hit area (#8467) changes nothing that is drawn. +#[test] +fn a_hidden_layers_eye_box_paints_nothing() { + fn bounds(shape: &egui::Shape, out: &mut Vec) { + match shape { + egui::Shape::Vec(shapes) => shapes.iter().for_each(|s| bounds(s, out)), + s => out.push(s.visual_bounding_rect()), + } + } + for theme in ["promedium", "pro", "studio", "studiolight", "classic"] { + let mut s = photocraft_engine::Session::new(); + s.execute("file.new", json!({"width": 64, "height": 48})).unwrap(); + let hidden = s.execute("layer.new.layer", json!({"name": "Hidden"})).unwrap()["layer"].as_u64().unwrap(); + s.execute("layer.setProps", json!({"layer": hidden, "visible": false})).unwrap(); + let shown = s.execute("layer.new.layer", json!({"name": "Shown"})).unwrap()["layer"].as_u64().unwrap(); + let h = harness(s, 1.0, theme, 290.0); + let mut drawn = Vec::new(); + for clipped in &h.output().shapes { + bounds(&clipped.shape, &mut drawn); + } + let rows = recorded(&h.ctx); + let in_eye_box = |id: u64| { + let row = rows.iter().find(|r| r.layer == id).unwrap().row; + let cell = Rect::from_min_max(row.left_top(), pos2(row.left() + 30.0, row.bottom())).shrink(1.0); + drawn.iter().filter(|b| b.is_positive() && cell.contains_rect(**b)).count() + }; + assert!(in_eye_box(shown) > 0, "{theme}: a visible layer paints its eye"); + assert_eq!(in_eye_box(hidden), 0, "{theme}: a hidden layer's eye box is left empty"); + } +} diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index f6c2de510a..6e52b37b76 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -3212,26 +3212,10 @@ fn layer_row( // The whole eye column takes drags too (so a drag starting on it never reorders the row): dragging down // the eyes gives every row swept over the visibility the first eye toggled to (#8467). let eye_resp = ui.interact(eye_cell, ui.id().with(("eye", l.id.0)), Sense::click_and_drag()); - // A hidden layer's eye box shows a sunken well indicating its eye socket (#8467). + // A hidden layer's eye box is left empty (still clickable; the whole column takes the click, #8467). if l.visible { // Centre the drawing in the column while preserving the visibility hit area. icons::paint(ui, eye_cell, "eye", 15.0, t.layer_label_icon(l.label)); - } else { - let well = Rect::from_center_size(eye_cell.center(), vec2(12.0, 12.0)); - if t.bevel { - crate::widgets::surface(ui, well, t.field, false); - } else { - painter.rect_filled(well, t.radius_sm, t.field); - let (hi, lo) = if t.dark() { - (Color32::from_black_alpha(65), Color32::from_white_alpha(35)) - } else { - (Color32::from_black_alpha(55), Color32::from_white_alpha(70)) - }; - painter.line_segment([well.left_bottom(), well.left_top()], Stroke::new(1.0, hi)); - painter.line_segment([well.left_top(), well.right_top()], Stroke::new(1.0, hi)); - painter.line_segment([well.right_top(), well.right_bottom()], Stroke::new(1.0, lo)); - painter.line_segment([well.right_bottom(), well.left_bottom()], Stroke::new(1.0, lo)); - } } eye_sweep(ctx, l, rect, &eye_resp, actions); if eye_resp.clicked() {