ColorSwatch class
#include <Jazz2/UI/Windows/Colors.h>
Shows a color, a translucent one over a checkerboard.
If it has a callback, it can be clicked.
Base classes
- class Element
- Element of the interface.
Constructors, destructors, conversion operators
- ColorSwatch(Function<Colorf()>&& color, Function<void()>&& onClick = {}) explicit
- Creates a new instance.
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 OnPointerUp(const PointerEvent& event, bool inside) override
- Called when the pointer is released,
insidetells whether it's still over the element. - auto YieldsToScroll() const -> bool override
- Returns
trueif a press on the element may become scrolling of the list it's in. - auto IsTabStop() const -> bool override
- Returns
trueifTabcan give the element the keyboard focus. - auto OnKeyPressed(const KeyboardEvent& event) -> bool override
- Called when a key is pressed while the element has the focus, returns
trueif it was used.
Public variables
Function documentation
bool Jazz2:: UI:: Windows:: ColorSwatch:: YieldsToScroll() const override
Returns true if a press on the element may become scrolling of the list it's in.
A finger dragged over a button scrolls the list then, the button isn't clicked. Elements that are dragged themselves keep the press.
bool Jazz2:: UI:: Windows:: ColorSwatch:: IsTabStop() const override
Returns true if Tab can give the element the keyboard focus.
Buttons and other controls are reached by Tab too, though a click doesn't focus them. Every element that can take the focus can, by default.