28#include "guillaume/ecs/component.hpp"
29#include "guillaume/ecs/entity.hpp"
65 enum class Variant { Enabled, Disabled, WithIcon };
81 Variant _variant { Variant::Enabled };
82 std::string _iconGlyph {};
83 std::string _label {};
147 const std::string &
getLabel(
void)
const noexcept;
static constexpr float ThumbInset
Inset of the thumb from the track ends, in dp.
ecs::Entity::Identifier getIcon(void) const noexcept
Get the child entity that draws the thumb icon.
static constexpr float LabelGap
Gap between the track and the label, in dp.
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(void)=default
Default destructor.
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
static constexpr float ThumbSize
Diameter of the thumb, in dp.
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.