28#include <utility/graphic/color.hpp>
30#include "guillaume/ecs/component.hpp"
31#include "guillaume/ecs/entity.hpp"
80 enum class Variant { Enabled, Disabled, Error };
92 State _state { State::Unchecked };
93 Variant _variant { Variant::Enabled };
94 std::string _label {};
103 std::optional<utility::graphic::Color32Bit>
105 std::optional<utility::graphic::Color32Bit>
158 const std::string &
getLabel(
void)
const noexcept;
209 const std::optional<utility::graphic::Color32Bit> &
229 const std::optional<utility::graphic::Color32Bit> &
242 std::optional<utility::graphic::Color32Bit> color);
const std::optional< utility::graphic::Color32Bit > & getCheckedColor(void) const noexcept
Get the color that replaces the themed fill of a checked box.
Checkbox & setLabelEntity(ecs::Entity::Identifier identifier)
Record which child entity draws the label.
Variant getVariant(void) const noexcept
Get the visual variant.
Checkbox & setVariant(Variant variant)
Choose the visual variant.
Checkbox & setLabel(const std::string &label)
Set the label text.
static constexpr float LabelGap
Gap between the touch target and the label, in dp.
Checkbox & setCheckedColor(std::optional< utility::graphic::Color32Bit > color)
Replace the themed fill of a checked or indeterminate box.
~Checkbox(void)=default
Default destructor.
Checkbox & setCheckIcon(ecs::Entity::Identifier identifier)
Record which child entity draws the check glyph.
static constexpr float TouchTarget
Edge of the square touch target centered on the box, in dp.
ecs::Entity::Identifier getLabelEntity(void) const noexcept
Get the child entity that draws the label.
std::function< void(State)> ValueChangeHandler
Called with the new state when the user toggles the box.
ecs::Entity::Identifier getCheckIcon(void) const noexcept
Get the child entity that draws the check glyph.
State getState(void) const noexcept
Get the checked state.
Checkbox & setState(State state)
Store the checked state.
const std::optional< utility::graphic::Color32Bit > & getUncheckedColor(void) const noexcept
Get the color that replaces the themed outline of an unchecked box.
const std::string & getLabel(void) const noexcept
Get the label text.
Checkbox & setUncheckedColor(std::optional< utility::graphic::Color32Bit > color)
Replace the themed outline of an unchecked box.
Checkbox & setOnValueChange(ValueChangeHandler handler)
Set the callback run when the user toggles the box.
const ValueChangeHandler & getOnValueChange(void) const noexcept
Get the callback run when the user toggles the box.
Checkbox(void)=default
Create the state of an enabled, unchecked checkbox with no label.
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
static constexpr Identifier InvalidIdentifier
"No entity": never the identifier of a real entity
State. Every class here is plain data attached to an entity.