PaletteGrid class
#include <Jazz2/UI/Windows/Colors.h>
The 256 entries of a palette in a grid of 16 × 16, to pick one of them, or a range of them.
Colors of the palette are as ContentResolver::Shift if SelectionEndFunc is set.
Base classes
- class Element
- Element of the interface.
Public static variables
- static float DefaultCellSize constexpr
- Usual size of an entry in units.
Public static functions
-
static void ShowPopup(Surface& surface,
Vector2f pos,
Function<const std::
uint32_t*()>&& palette, Function<std:: int32_t()>&& selected, Function<void(std:: int32_t)>&& onPick) - Shows it in a popup at a position, it's closed when an entry is picked.
-
static auto ToColor(std::
uint32_t entry) -> Colorf - Converts an entry of a palette to a color.
Constructors, destructors, conversion operators
-
PaletteGrid(Function<const std::
uint32_t*()>&& palette, Function<std:: int32_t()>&& selected, Function<void(std:: int32_t, bool)>&& onPick) - 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 OnPointerMove(const PointerEvent& event) override
- Called when the pointer moves while pressed over the element.
- auto GetTooltip(Vector2f pos) const -> StringView override
- Returns the tooltip at a position.
Public variables
- float CellSize
- Size of an entry in units.
-
Function<std::
int32_t()> SelectionEndFunc - Returns the other end of the picked range, ranges can't be picked if it isn't set.
-
Function<bool(std::
int32_t)> IsCrossedFunc - Returns
truefor an entry that is crossed out, such as one nothing uses, none is if it isn't set.
Function documentation
Jazz2:: UI:: Windows:: PaletteGrid:: PaletteGrid(Function<const std:: uint32_t*()>&& palette,
Function<std:: int32_t()>&& selected,
Function<void(std:: int32_t, bool)>&& onPick)
Creates a new instance.
onPick gets the picked entry, and whether it extends the range picked before instead of starting a new one.