ColorPicker class
#include <Jazz2/UI/Windows/Colors.h>
Picks a color by its saturation and value in a square, its hue in a bar next to it, and optionally alpha.
The color is changed as it's dragged, every change goes to the callback. The hue and saturation are kept while the color is gray or black, so they don't jump back to red when it's dragged out of there again.
Base classes
- class Element
- Element of the interface.
Public static functions
- static void ShowPopup(Surface& surface, Vector2f pos, Function<Colorf()>&& color, Function<void(const Colorf&)>&& onChange, bool withAlpha = false)
- Shows it in a popup at a position, with the color it had before, and its hex code.
- static auto ToHex(const Colorf& color) -> String
- Converts a color to
#RRGGBB. - static auto FromHex(StringView text, Colorf& color) -> bool
- Converts
#RRGGBBorRRGGBBto a color, returnsfalseif it isn't one.
Constructors, destructors, conversion operators
- ColorPicker(Function<Colorf()>&& color, Function<void(const Colorf&)>&& onChange, bool withAlpha = false)
- Creates a new instance.
- ~ColorPicker() override
Public functions
- auto Measure(const Context& context, Vector2f available) -> Vector2f override
- Returns the size the element wants, in pixels.
- auto MeasureDependsOnAvailable() const -> bool override
- Returns
falseif what Measure() returns doesn't depend on the available size, it's measured once a frame then. - void Draw(Painter& painter) override
- Draws the element and its children.
- auto AcceptsPointer() const -> bool override
- Returns
trueif the element takes the pointer itself. - auto OnPointerDown(const PointerEvent& event) -> bool override
- Called when the pointer is pressed over the element, returns
trueto keep getting it until released. - void OnPointerMove(const PointerEvent& event) override
- Called when the pointer moves while pressed over the element.
- void OnPointerUp(const PointerEvent& event, bool inside) override
- Called when the pointer is released,
insidetells whether it's still over the element.
Function documentation
static void Jazz2:: UI:: Windows:: ColorPicker:: ShowPopup(Surface& surface,
Vector2f pos,
Function<Colorf()>&& color,
Function<void(const Colorf&)>&& onChange,
bool withAlpha = false)
Shows it in a popup at a position, with the color it had before, and its hex code.
It's closed by a click outside of it. Clicking the color it had before brings it back.