Offer intersection in the mask panel: an Intersect button and a third chip state

The pipeline could now keep only where two selections agree, but the panel
had no way to ask for it: the part row's chip flipped between + and -, and
the buttons under the parts joined an added or a subtracted correction.

An "∩ Intersect" button joins a painted part that intersects, and the chip
on a part row cycles + -> - -> ∩ and round, so an existing part can be
turned into an intersection without being repainted. Both go through the
same session calls as before, indexing Join::ALL, whose first two entries
kept their places. The chip is now a tagged gesture, so it is in the
gesture book.
This commit is contained in:
2026-09-24 21:25:48 -04:00
parent 8cdad3863d
commit 5f0b7ac799
3 changed files with 56 additions and 8 deletions
+3 -1
View File
@@ -543,7 +543,9 @@ impl DevelopSession {
.record(&self.graph, Edit::Action(labels::step::MASK_PART_REMOVED));
}
/// Change how a part joins: added to the mask, or taken out of it.
/// TRACES: FR-DEV-19a
/// Change how a part joins: added to the mask, taken out of it, or kept
/// only where the mask already was. `join` indexes `Join::ALL`.
pub fn set_mask_part_join(&mut self, id: &str, index: usize, join: usize) {
use dr_pipeline::mask::Join;
let Some(&join) = Join::ALL.get(join) else {
+25
View File
@@ -1534,6 +1534,31 @@ mod tests {
assert_eq!(s.mask_feather(&id), 0.03, "and the base was left alone");
}
/// TRACES: FR-DEV-19a
/// The panel's third join reaches the layer: the "∩ Intersect" button
/// joins an intersecting part, the part row reports it as the chip's third
/// state, and cycling the chip on from there comes back round to a union.
#[test]
fn the_intersect_button_joins_a_part_that_intersects() {
use dr_pipeline::mask::Join;
let Some(mut s) = session() else {
eprintln!("no adapter; skipping");
return;
};
let id = s.add_gradient_mask(true).expect("radial");
s.set_active_mask(Some(&id));
let index = s.add_mask_part(&id, 2).expect("a part was joined");
let join = |s: &DevelopSession| {
s.masks().get(&id).expect("layer").part(index).expect("part").join
};
assert_eq!(join(&s), Join::Intersect);
assert_eq!(s.mask_parts(&id)[index].2, 2, "the chip shows ∩");
s.set_mask_part_join(&id, index, (2 + 1) % 3);
assert_eq!(join(&s), Join::Union, "and the chip cycles back to +");
}
/// TRACES: FR-DEV-3 | FR-UI-1
/// The fault this pass exists for, stated as a test.
///