23#include "guillaume/components/checkbox.hpp"
36 if (_state != state) {
50 if (_variant != variant) {
64 if (_label != label) {
78 if (_checkIcon != identifier) {
79 _checkIcon = identifier;
92 if (_labelEntity != identifier) {
93 _labelEntity = identifier;
99 const std::optional<utility::graphic::Color32Bit> &
102 return _checkedColor;
106 std::optional<utility::graphic::Color32Bit> color)
108 if (_checkedColor != color) {
109 _checkedColor = color;
115 const std::optional<utility::graphic::Color32Bit> &
118 return _uncheckedColor;
122 std::optional<utility::graphic::Color32Bit> color)
124 if (_uncheckedColor != color) {
125 _uncheckedColor = color;
134 return _onValueChange;
139 _onValueChange = std::move(handler);
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.
Checkbox & setCheckedColor(std::optional< utility::graphic::Color32Bit > color)
Replace the themed fill of a checked or indeterminate box.
Checkbox & setCheckIcon(ecs::Entity::Identifier identifier)
Record which child entity draws the check glyph.
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.
void setHasChanged(bool hasChanged)
Raise or lower the changed flag.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
State. Every class here is plain data attached to an entity.