33#include <utility/graphic/pose.hpp>
35#include "guillaume/ecs/component_registry.hpp"
36#include "guillaume/ecs/entity_builder.hpp"
38#include "guillaume/components/radio_group.hpp"
40#include "guillaume/entities/builder_base.hpp"
41#include "guillaume/entities/radio_button.hpp"
42#include "guillaume/entities/surface.hpp"
99 std::vector<std::string>
101 std::optional<std::size_t>
104 std::function<void(std::size_t)>
124 std::shared_ptr<RadioGroup>
buildEntity(
void)
override;
132 void reset(
void)
override;
167 std::function<
void(std::size_t)> onValueChange);
181 std::shared_ptr<RadioGroup>
183 const std::vector<std::string> &options);
198 template<
typename... Arguments>
199 static std::shared_ptr<RadioGroup>
create(Arguments &&...arguments)
201 std::shared_ptr<RadioGroup> entity(
202 new RadioGroup(std::forward<Arguments>(arguments)...));
222 RadioGroup &
setValue(std::size_t index);
229 std::optional<std::size_t>
getValue(
void)
const;
244 std::shared_ptr<RadioButton>
getOption(std::size_t index)
const;
277 const std::vector<std::string> &options,
278 std::optional<std::size_t> value,
279 std::function<
void(std::size_t)> onValueChange);
static constexpr float RowSpacing
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)
Builder(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Construct a builder holding the defaults of reset().
Builder & withValue(std::size_t index)
Choose the option selected when the group is built.
Builder & withPose(const utility::graphic::PoseF &pose)
Set where the group is.
void reset(void) override
Restore the defaults: default pose, no option, no selected option, no value-change handler,...
Builder & withOnValueChange(std::function< void(std::size_t)> onValueChange)
Set the function called when the user selects another option.
std::shared_ptr< RadioGroup > buildEntity(void) override
Build a group and its radio buttons from the current configuration, without registering it or giving ...
std::shared_ptr< RadioGroup > makeRadioGroup(std::shared_ptr< ecs::Entity > parent, const std::vector< std::string > &options)
Build a group and its radio buttons, register it under parent and reset the builder.
Builder & addOption(const std::string &label)
Append an option at the end of the list.
std::size_t getOptionCount(void) const
Get the number of options.
std::optional< std::size_t > getValue(void) const
Get the selected option.
static std::shared_ptr< RadioGroup > create(Arguments &&...arguments)
Build a group without registering it in an entity registry.
RadioGroup & setOnValueChange(std::function< void(std::size_t)> onValueChange)
Set the function called when the user selects another option.
std::shared_ptr< RadioButton > getOption(std::size_t index) const
Get the radio button of an option, for example to disable it.
RadioGroup & setValue(std::size_t index)
Select an option from code.
static constexpr float RowSpacing
Vertical space between two radio buttons, in dp: enough for the 40 dp touch targets of their 20 dp ri...
~RadioGroup(void) override=default
Destructor.
SurfaceBase(ecs::ComponentRegistry ®istry, const SurfaceConfig &config)
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...