30#include <utility/graphic/color.hpp>
31#include <utility/graphic/pose.hpp>
33#include "guillaume/ecs/component_registry.hpp"
34#include "guillaume/ecs/entity_builder.hpp"
36#include "guillaume/components/hand_button_interaction.hpp"
37#include "guillaume/components/mouse_button_interaction.hpp"
38#include "guillaume/components/switch.hpp"
39#include "guillaume/components/value.hpp"
41#include "guillaume/entities/icon.hpp"
42#include "guillaume/entities/builder_base.hpp"
43#include "guillaume/entities/surface.hpp"
44#include "guillaume/entities/text.hpp"
96 components::Value, components::MouseButtonInteraction,
97 components::HandButtonInteraction, components::Switch>
112 Variant _variant { Variant::Enabled };
113 bool _checked {
false };
114 std::string _iconGlyph {};
116 std::string _label {};
134 std::shared_ptr<Switch>
buildEntity(
void)
override;
141 void reset(
void)
override;
195 std::shared_ptr<Switch>
197 bool checked,
const std::string &iconGlyph,
198 const std::string &label);
215 template<
typename... Arguments>
216 static std::shared_ptr<Switch>
create(Arguments &&...arguments)
218 std::shared_ptr<Switch> entity(
219 new Switch(std::forward<Arguments>(arguments)...));
302 Switch &
setLabel(
const std::string &label);
317 Variant variant,
bool checked,
const std::string &iconGlyph,
318 const std::string &label);
static constexpr float LabelGap
Gap between the track and the label, in dp.
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
Owns entities and gives the systems the list of entities to visit.
EntityBuilderBase(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
SurfaceBase(ecs::ComponentRegistry ®istry, const SurfaceConfig &config)
Builder & withChecked(bool checked)
Choose whether the switch starts on.
Builder & withVariant(Variant variant)
Choose whether the switch reacts to input.
Builder & withIcon(const std::string &iconGlyph)
Draw an icon on the thumb.
Builder(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Construct a builder holding the defaults of reset().
std::shared_ptr< Switch > makeSwitch(std::shared_ptr< ecs::Entity > parent, Variant variant, bool checked, const std::string &iconGlyph, const std::string &label)
Build a switch and its children, register it under parent and reset the builder.
Builder & withLabel(const std::string &label)
Set the text shown to the right of the track.
void reset(void) override
Restore the defaults: default pose, the Enabled variant, off, no icon, no label, and a 52 x 32 dp tra...
Builder & withPose(const utility::graphic::PoseF &pose)
Set where the switch is.
std::shared_ptr< Switch > buildEntity(void) override
Build a switch and its children from the current configuration, without registering it or giving it a...
Switch & setOnValueChange(std::function< void(bool)> onValueChange)
Set the handler called when the user toggles the switch (Paper onValueChange).
Switch & setVariant(Variant variant)
Enable or disable the switch. Restyles at once.
Switch & toggle(void)
Flip the checked state, as a user activation would.
~Switch(void) override=default
Destructor.
components::Switch::Variant Variant
bool isChecked(void) const
Whether the switch is on.
Variant getVariant(void) const
Get the variant of the switch.
static std::shared_ptr< Switch > create(Arguments &&...arguments)
Build a switch without registering it in an entity registry.
bool isDisabled(void) const
Check whether the switch ignores input.
Switch & setLabel(const std::string &label)
Change the text of the label. Restyles at once.
static constexpr float LabelGap
Gap between the track and the label, in dp.
Switch & setChecked(bool checked)
Turn the switch on or off from code.
Widgets: the classes used to create entities with the right components and children.
Everything needed to set up a surface in one value: where it is, how it looks and how it arranges its...