Skip to content

Open the Color Picker from every colour swatch - #10

Merged
IAmJSD merged 1 commit into
mainfrom
t3code/891290f5
Aug 24, 2026
Merged

Open the Color Picker from every colour swatch#10
IAmJSD merged 1 commit into
mainfrom
t3code/891290f5

Conversation

@IAmJSD

@IAmJSD IAmJSD commented Aug 24, 2026

Copy link
Copy Markdown
Member

Clicking the swatch on Layer Style's Color row did nothing, which is the one thing the control looks like it should do.

The reason it did nothing is that Workspace::modal is a single Option<Modal> and the picker is itself a Modal, so opening it would have thrown away the Layer Style session mid-edit. So modals get a suspend stack: open_color_picker_on pushes the dialog that is already up, and close_modal pops it back rather than clearing, whether the picker was OK'd or cancelled. modal stays the top of the stack, so the dozen places that read it -- the renderer, the key routing, the "is a dialog up" guards -- carry on unchanged. open_modal clears the stack, so a dialog launched from the menus still replaces everything.

Three swatches wanted this, not one:

  • Layer Style's per-effect Color, via ColorTarget::StyleEffect(key). OK writes through set_color and re-previews the layer, the same path the sliders use, so the canvas keeps up.
  • Gradient Overlay's From and To, which had no swatches at all -- only the "From = FG" / "To = FG" buttons, so the two colours were reachable only by way of the foreground. They ride the same variant under dotted keys, gradient_overlay.from and .to, since they are ends of a gradient rather than "the effect's colour" and have no slot in color_of.
  • Select > Color Range's Sampled, which needs its own variant because it writes back to a different modal.

Driven headlessly to check the parts that are easy to get wrong: OK restores the parent dialog with every other control intact, Cancel and Escape restore it with the colour unchanged, and the parent's own OK/Cancel still commit and revert.

Clicking the swatch on Layer Style's Color row did nothing, which is the
one thing the control looks like it should do.

The reason it did nothing is that `Workspace::modal` is a single
`Option<Modal>` and the picker is itself a `Modal`, so opening it would
have thrown away the Layer Style session mid-edit. So modals get a
suspend stack: `open_color_picker_on` pushes the dialog that is already
up, and `close_modal` pops it back rather than clearing, whether the
picker was OK'd or cancelled. `modal` stays the top of the stack, so the
dozen places that read it -- the renderer, the key routing, the
"is a dialog up" guards -- carry on unchanged. `open_modal` clears the
stack, so a dialog launched from the menus still replaces everything.

Three swatches wanted this, not one:

- Layer Style's per-effect Color, via `ColorTarget::StyleEffect(key)`.
  OK writes through `set_color` and re-previews the layer, the same path
  the sliders use, so the canvas keeps up.
- Gradient Overlay's From and To, which had no swatches at all -- only
  the "From = FG" / "To = FG" buttons, so the two colours were reachable
  only by way of the foreground. They ride the same variant under dotted
  keys, `gradient_overlay.from` and `.to`, since they are ends of a
  gradient rather than "the effect's colour" and have no slot in
  `color_of`.
- Select > Color Range's Sampled, which needs its own variant because it
  writes back to a different modal.

Driven headlessly to check the parts that are easy to get wrong: OK
restores the parent dialog with every other control intact, Cancel and
Escape restore it with the colour unchanged, and the parent's own
OK/Cancel still commit and revert.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@IAmJSD
IAmJSD merged commit 578ba5b into main Aug 24, 2026
3 checks passed
@IAmJSD
IAmJSD deleted the t3code/891290f5 branch August 24, 2026 02:19
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