Skip to content

TP-119: "only on" layer intersection toggle (union vs intersection) - #16

Open
meintsot wants to merge 7 commits into
masterfrom
worktree-tp119-onlyon-intersection
Open

TP-119: "only on" layer intersection toggle (union vs intersection)#16
meintsot wants to merge 7 commits into
masterfrom
worktree-tp119-onlyon-intersection

Conversation

@meintsot

@meintsot meintsot commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

When 2+ "only on" filter items are selected, the user can now choose whether an operation applies where any item is present (union — the existing default) or only where all of them overlap (intersection). The choice appears as two radio menu items — "Match any of these (union)" / "Match all of these (intersection)" — in the shared "only on" popup, so it works for both brushes and Global Operations (the Fill dialog).

Note on the ticket premise: TP-119 says "brush mode already does the intersection." That is not accurate in the code — brushes and Global Operations share the same filter path and both currently do union (AnyOfFilter) for multiple "only on" items. This PR adds the intersection option (reusing the existing AllOfFilter) rather than making one path match another.

Changes

  • OnlyOnTerrainOrLayerFilter.create(dim, item, boolean intersection) — new overload; for a multi-item list returns AllOfFilter (intersection / min-strength) when true, else AnyOfFilter (union / max-strength). The 2-arg overload delegates with false.
  • DefaultFilter — new 13-arg constructor carrying onlyOnIntersection (the existing 12-arg constructor is preserved and delegates with false, so CreateFilterOp and other callers are untouched), plus a field, isOnlyOnIntersection() getter, and Builder support.
  • FilterPreset — persists the choice (onlyOnIntersection field + accessors + 10th captureFrom param). serialVersionUID unchanged; presets saved before this change load as false (union).
  • BrushOptions — adds the two mutually-exclusive radio menu items (shown only for 2+ items, default "any"), wires the flag through getFilter()/setFilter() and into preset save/load.
  • AllOfFilter — Javadoc updated to note the new "only on" intersection usage.
  • Default behavior is unchanged everywhere (union); "except on" is intentionally untouched.

Test plan

  • WPCore unit tests: 13 new tests pass (OnlyOnIntersectionFilterTest 6, DefaultFilterOnlyOnIntersectionTest 4, FilterPresetTest 3) — covers combiner semantics, create() type selection, DefaultFilter wiring, Builder, and a FilterPreset serialize/deserialize round-trip.
  • Full multi-module build: mvn -DskipTests=true -pl WPGUI -am install → BUILD SUCCESS.
  • Manual (Swing): with 2+ "only on" items, the two match-mode items appear (default "Match any"); "Match all" affects only the overlap; verified in both a brush and the Global Operations/Fill dialog; saving a "Match all" preset and reloading restores the selection; with a single item the items do not appear.

Known follow-ups (out of scope, non-blocking)

  • Pre-existing: DefaultFilter.setDimension() does not propagate the dimension to the children of multi-item AnyOfFilter/AllOfFilter (affects the already-shipped multi-select union path and "except on" too). Worth a separate ticket.
  • Minor UX: onlyOnIntersection is not reset if the "only on" list is shrunk back to a single item (inert — create() ignores the flag for single items).

Design: docs/superpowers/specs/2026-06-06-tp119-onlyon-layer-intersection-design.md
Plan: docs/superpowers/plans/2026-06-06-tp119-onlyon-layer-intersection.md

🤖 Generated with Claude Code

meintsot and others added 7 commits June 6, 2026 11:54
Add a union/intersection choice for multi-item "only on" filters, shared
by brushes and Global Operations. Corrects the ticket premise (brushes do
not currently do intersection; both paths use AnyOfFilter/union). Reuses
the existing AllOfFilter, threads an onlyOnIntersection flag UI ->
DefaultFilter -> OnlyOnTerrainOrLayerFilter.create(), and persists it in
FilterPreset. Default stays union.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Plan with exact TDD steps across WPCore (model + persistence) and WPGUI
(only-on popup "Match any/all" menu items). Spec UI revised from inline
panel radios to popup menu items to avoid NetBeans GroupLayout surgery and
match how multi-select was previously added.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…presets

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant