Skip to main content

ColorPickerBuilder

Trait ColorPickerBuilder 

Source
pub trait ColorPickerBuilder: Sized {
    // Required methods
    fn alpha(self) -> Self;
    fn idiom(self, idiom: PickerIdiom) -> Self;
    fn native(self) -> Self;
    fn composed(self) -> Self;
    fn title<M>(self, t: impl IntoText<M>) -> Self;
    fn presets(self, presets: Vec<Color>) -> Self;
    fn id(self, id: ElementId) -> Self;
}
Expand description

Builder methods of ColorPicker, reachable through a Decorated (docs/api-style.md “Typed builders and erasure”): generic modifiers and typed ones chain in any order.

Required Methods§

Source

fn alpha(self) -> Self

Offer an opacity channel, and let the bound signal carry a non-opaque alpha. Honored by the composed panel everywhere, and by every native chooser but one: a browser’s <input type="color"> gained an alpha attribute only recently, so the web arm sets it and stays opaque where the browser has not shipped it (docs/colorpicker.md).

Source

fn idiom(self, idiom: PickerIdiom) -> Self

Which chooser this well opens (see PickerIdiom).

Source

fn native(self) -> Self

Pin this well to the platform’s chooser, PickerIdiom::Native.

Source

fn composed(self) -> Self

Pin this well to Day’s composed panel, PickerIdiom::Composed.

Source

fn title<M>(self, t: impl IntoText<M>) -> Self

The chooser’s heading. Native: the iOS picker’s navigation title, the GTK dialog heading, QColorDialog’s window title, the XAML button’s tooltip; AppKit sets the shared color panel’s title. Composed: the panel’s own heading. A constant, Signal<String> or closure, read once at build.

Source

fn presets(self, presets: Vec<Color>) -> Self

The swatch row the composed panel offers below its strips (ignored by the native choosers, which each have their own palette). Pass an empty vector to drop the row.

Source

fn id(self, id: ElementId) -> Self

The composed well’s dayscript id (default "color-picker").

It goes here rather than on Decorate::id because what an app can reach from outside is the layout wrapper the piece returns, and an id on that tags a node no toolkit realizes; a tap: against it resolves to nothing while every step still reports ✓. Give two composed pickers on one page different keys so a script can tell them apart.

The panel’s own parts carry fixed ids (color-picker-panel, -shade, -hue, -opacity, -presets, -value, -cancel, -done); only one panel is ever open, so they need no disambiguation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<C> ColorPickerBuilder for ColorPicker<C>
where C: Binding<Color>,

Source§

impl<DecoratedInner> ColorPickerBuilder for Decorated<DecoratedInner>
where DecoratedInner: ColorPickerBuilder + Piece,