diff --git a/crates/ui-egui/src/panels/detail.rs b/crates/ui-egui/src/panels/detail.rs index 84531132b..7fd50d00f 100644 --- a/crates/ui-egui/src/panels/detail.rs +++ b/crates/ui-egui/src/panels/detail.rs @@ -2390,7 +2390,11 @@ fn mask_overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Respons // the photo (issue #2549) use lightcraft_pipeline::MaskView; let colored = matches!(MaskView::parse(&app.ui.mask_overlay_mode).unwrap_or_default(), MaskView::Color | MaskView::ColorOnBw); - let shown = (app.ui.mask_overlay || app.ui.mask_overlay_all) && !(colored && app.ui.mask_overlay_opacity <= 0.0); + // the all-masks overlay ([`view_overlay`]) shows only visible masks, and gives way to the + // selected mask's when none has anything in it (a stroke goes into the selected mask, or a new one) + let visible = active.and_then(|id| d.masks.iter().find(|m| m.id == id)).is_none_or(|m| m.visible); + let all = app.ui.mask_overlay_all && (visible || d.masks.iter().any(|m| m.visible && !m.components.is_empty())); + let shown = if all { visible } else { app.ui.mask_overlay } && !(colored && app.ui.mask_overlay_opacity <= 0.0); if shown && let Some(Gesture::Brush { points, pressure }) = &app.gesture { let screen: Vec = points.iter().map(|q| map.screen(*q)).collect(); // opacity 0 only gets here in the image views, which ignore it: a fixed tint there diff --git a/crates/ui-egui/src/tests_masking.rs b/crates/ui-egui/src/tests_masking.rs index f6841129f..7c221bef5 100644 --- a/crates/ui-egui/src/tests_masking.rs +++ b/crates/ui-egui/src/tests_masking.rs @@ -1880,6 +1880,14 @@ fn a_brush_stroke_is_not_tinted_while_the_mask_overlay_is_hidden() { } pointer(&mut h, json!([{"kind": "up", "x": 0.85, "y": 0.75}])); assert_eq!(develop(&h).masks.len(), 1, "every stroke went into the one mask"); + + // a hidden mask isn't in the all-masks overlay: nor is the stroke being painted into it + let id = develop(&h).masks[0].id; + exec(&mut h, "mask.visible", json!({"id": id, "visible": false})); + let (photo, held) = hold_fast_stroke(&mut h, 0.9); + let t = tinted(&photo, &held); + assert!(t.is_empty(), "the all-masks overlay tints a stroke into a hidden mask: {} of 74 points, first {:?}", t.len(), t.first()); + pointer(&mut h, json!([{"kind": "up", "x": 0.85, "y": 0.9}])); } #[test]