Skip to main content

Module color_picker

Module color_picker 

Source
Expand description

ColorPicker — embeddable composite color selector.

Combines a 2D HSV canvas, 1D hue and alpha strips, RGB and HSV component spinners, a hex input, a current-color preview, and an optional preset swatch grid into a single bound widget. Driven by a Signal<Color> (or Signal<Option<Color>>) source of truth — every subcomponent reads from / writes to the same signal so the various representations stay in lockstep.

§Layouts

  • ColorPickerLayout::Compact — HSV canvas + hue strip + hex input. Minimal vertical footprint, suitable for popovers.
  • ColorPickerLayout::Standard (default) — HSV canvas + hue strip + alpha strip (when enabled), with RGB spinners, hex input, and preset swatches stacked beneath. The everything-on layout for inspector panes and settings dialogs.
  • ColorPickerLayout::Wide — HSV canvas with strips on the right, spinners stacked vertically alongside the swatch grid. For wide property pages.

§Accessibility

Root: Role::Group with a localized label and Live::Polite so screen readers announce committed color changes. The HSV canvas’s subtree is excluded from the AT tree (no ARIA precedent for 2D pointer gestures); the hue strip, alpha strip, RGB / HSV spinners, hex input, current-color preview, and swatch grid each carry their own appropriate role and value.

§Touch and pen

The hue strip, the alpha strip and the HSV canvas are continuous manipulators — the value each produces is the press position — so all three declare touch_action(NONE): a finger that lands on one adjusts it rather than scrolling the surface the picker sits in. What NONE forbids, with a test on it, is a two-contact pinch begun on one of them reaching the surface underneath; the press capture each takes on its own PointerDown is what separately keeps an enclosing scroller from taking the gesture away. docs/touch-and-pen.md §7.3.

The strips are 14 dp across and cannot grow — the panel’s column geometry is built around them — so they make the 24 dp shortfall up between the pointer and the arena, through Widget::hit_outset, on the short axis only. A 22 dp preset swatch earns the same widening, on both of its axes. The strips also report what they painted through Widget::target_regions, so the knob a user aims at is visible to a conformance audit even though no layout ever produced it.

Re-exports§

pub use self::swatch::ColorSwatch;

Modules§

alpha_strip
AlphaStrip — 1D opacity slider with a checkerboard background + tinted gradient overlay.
hsv_canvas
HsvCanvas — 2D saturation × value picker rendered as three stacked gradients.
hue_strip
HueStrip — 1D hue slider rendered from a CPU-generated 256×1 rainbow texture.
state
Internal state for ColorPicker.
swatch
ColorSwatch — single clickable color cell with Role::ColorWell.
swatch_grid
SwatchGrid — Role::Grid container of color swatches with arrow-key roving focus, mirroring the Calendar widget’s grid pattern.

Structs§

ColorPicker
Embeddable HSV+RGB+hex+alpha+swatches color picker.

Enums§

ColorPickerLayout
Layout variant — controls how the recipe arranges the rows. Re-exported from color_picker_style so the config and any custom ColorPickerStyle impl can branch on it without an upward dep on teksilo-widgets.

Constants§

DEFAULT_SWATCHES
Default 12-color preset palette (Int UI–flavored). Apps can use this verbatim or pass their own via ColorPicker::swatches.