Merge PR #3182: Disarm color picking when adding mask components

This commit is contained in:
aiongg
2026-10-31 02:07:42 +00:00
2 changed files with 26 additions and 0 deletions
+4
View File
@@ -227,6 +227,10 @@ impl LightcraftApp {
// menu), it must not keep a search that no longer applies (issue #1648)
self.ui.search.clear();
}
if r.is_ok() && id == "mask.addComponent" && params.get("kind").and_then(Value::as_str) != Some("colorRange") && self.ui.tool == "colorRange"
{
self.ui.tool.clear();
}
if r.is_ok() && id == "mask.adjust" {
// Judge local adjustments on the photo, without the selection overlay obscuring them.
// Keep it hidden after release; O / the overlay eye can show it again.
+22
View File
@@ -1700,6 +1700,28 @@ fn assert_close(a: &serde_json::Value, b: &serde_json::Value) {
/// Regression: the Colour Range "Pick" button armed the eyedropper, but with the Masking panel
/// open the loupe's clicks went to the mask overlay, so no sample was ever taken.
#[test]
fn adding_radial_component_disarms_color_range_picker() {
let mut h = detail("panel.masking");
exec(&mut h, "mask.add", json!({"kind": "colorRange"}));
h.app.ui.tool.clear();
click(&mut h, "button:colorPick0");
brush_at(&mut h, 0.25, 0.5);
assert_eq!(color_samples(&h).as_array().map(Vec::len), Some(1));
exec(&mut h, "mask.addComponent", json!({"kind": "radial", "op": "intersect", "center": [0.5, 0.5], "rx": 0.22, "ry": 0.22}));
assert!(h.app.ui.tool.is_empty(), "adding a radial component disarms colour picking");
let widget = "maskHandle:1:1:1";
let rect = h.app.widgets.iter().find(|(id, _)| *id == widget).unwrap().1;
let image = h.app.image_rect.unwrap();
let q = rect.center();
let (x, y) = ((q.x - image.left()) / image.width(), (q.y - image.top()) / image.height());
pointer(&mut h, json!([{"kind": "down", "x": x, "y": y}, {"kind": "drag", "x": x + 0.05, "y": y}, {"kind": "up", "x": x + 0.05, "y": y}]));
let MaskShape::Radial { rx, .. } = develop(&h).masks[0].components[1].shape else { panic!("radial") };
assert!(rx > 0.22, "dragging a radial handle resizes the component: {rx}");
}
#[test]
fn color_range_pick_button_samples_the_photo() {
let mut h = detail("panel.masking");