mirror of
https://github.com/storytold/lightcraft.git
synced 2026-11-02 06:27:53 -06:00
Review: under the all-masks overlay, a stroke into a hidden mask isn't tinted while painting (#2549)
The all-masks overlay shows only visible masks, so the live tint now follows the same rule: a stroke into a hidden mask is untinted there, and when no visible mask has anything in it the selected-mask overlay setting decides, as the rendered overlay does.
This commit is contained in:
@@ -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<Pos2> = points.iter().map(|q| map.screen(*q)).collect();
|
||||
// opacity 0 only gets here in the image views, which ignore it: a fixed tint there
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user