23#include "guillaume/components/switch.hpp"
36 if (_variant != variant) {
50 if (_iconGlyph != glyph) {
64 if (_label != label) {
78 if (_thumb != identifier) {
92 if (_icon != identifier) {
106 if (_labelEntity != identifier) {
107 _labelEntity = identifier;
116 return _onValueChange;
121 _onValueChange = std::move(handler);
ecs::Entity::Identifier getIcon(void) const noexcept
Get the child entity that draws the thumb icon.
Switch & setOnValueChange(ValueChangeHandler handler)
Set the callback run when the user toggles the switch.
Variant getVariant(void) const noexcept
Get the visual variant.
Switch(void)=default
Create the configuration of an enabled switch with no icon and no label.
Switch & setThumb(ecs::Entity::Identifier identifier)
Record which child entity is the thumb.
Switch & setLabelEntity(ecs::Entity::Identifier identifier)
Record which child entity draws the label.
Switch & setIconGlyph(const std::string &glyph)
Set the name of the glyph drawn on the thumb.
const std::string & getIconGlyph(void) const noexcept
Get the name of the glyph drawn on the thumb.
const std::string & getLabel(void) const noexcept
Get the label text.
ecs::Entity::Identifier getThumb(void) const noexcept
Get the child entity drawn as the thumb.
ecs::Entity::Identifier getLabelEntity(void) const noexcept
Get the child entity that draws the label.
const ValueChangeHandler & getOnValueChange(void) const noexcept
Get the callback run when the user toggles the switch.
Switch & setLabel(const std::string &label)
Set the label text.
Switch & setVariant(Variant variant)
Choose the visual variant.
Switch & setIcon(ecs::Entity::Identifier identifier)
Record which child entity draws the thumb icon.
std::function< void(bool)> ValueChangeHandler
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.