Using the color picker

fontcolorpickers.C summarizes how to use a x::w::color_picker widget. This widget provides a popup for selecting the red, green, and blue channels of a x::w::rgb. The popup ignores the alpha channel component.

x::w::color_picker's overloaded current_color() method returns the most recently-selected x::w::rgb color, or resets the popup with the specified color. on_color_update() installs a callback that gets invoked whenever a new color gets officially picked, by the popup's Ok button. Only one callback can be installed at one time, and the initial callback is one of the values that are specified in x::w::color_picker_config when creating the color picker.

The same approach that gets used to save and restore the font picker's setting also gets used with the color picker. Each color picker has a unique identifier, or a label. x::w::color_picker_config's restore() method sets the new color picker's label and restores the color picker's saved color, if there is one. All color pickers created by the application must have unique labels.