23#include "guillaume/entities/radio_button.hpp"
28#include "guillaume/ecs/entity_filler.hpp"
30#include "guillaume/components/bound.hpp"
31#include "guillaume/components/color.hpp"
32#include "guillaume/components/ellipse.hpp"
33#include "guillaume/components/transform.hpp"
35#include "guillaume/entities/content_helpers.hpp"
37#include "guillaume/entities/builder_base.hpp"
39#include "guillaume/components/hand_hover_interaction.hpp"
40#include "guillaume/components/mouse_hover_interaction.hpp"
42#include "guillaume/systems/radio_button.hpp"
43#include "guillaume/theme.hpp"
53 public ecs::EntityFiller<components::Transform, components::Bound,
54 components::Color, components::Ellipse>
62 RadioDot(ecs::ComponentRegistry ®istry,
63 const utility::graphic::Color32Bit &color)
64 : ecs::EntityFiller<components::Transform, components::Bound,
65 components::Color, components::Ellipse>(
68 getComponentRegistry()
69 .getComponent<components::Bound>(getIdentifier())
73 getComponentRegistry()
74 .getComponent<components::Color>(getIdentifier())
81 ~RadioDot(
void)
override =
default;
102 _variant = Variant::Enabled;
107 _config.mainAxisAlignment =
109 _config.crossAxisAlignment =
111 _config.spacing = 8.0f;
112 _config.padding = 0.0f;
113 _config.setFixedWidth(20.0f);
114 _config.setFixedHeight(20.0f);
138 std::shared_ptr<ecs::Entity> parent,
Variant variant,
139 const std::string &label)
141 return withVariant(variant).withLabel(label).registerEntity(parent);
146 const std::string &label)
217 void RadioButton::build(
void)
223 const auto dot = std::make_shared<RadioDot>(
225 dot->setParent(shared_from_this());
227 radio.setDot(dot->getIdentifier());
229 if (!radio.getLabel().empty()) {
231 buildText(registry, *
this, shared_from_this(), radio.getLabel(),
234 if (label !=
nullptr) {
235 radio.setLabelEntity(label->getIdentifier());
@ Start
Packed at the left (row) or top (column).
@ Horizontal
Row: children placed left to right.
Selected/unselected flag of an entity, with a callback run when it changes.
A run of text: its content, its font metrics and the position of the editing cursor.
Text & setContent(const std::string &content)
Replace the text.
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
ComponentType & getComponent(const Entity::Identifier &entityIdentifier)
Get a component of an entity, to read or modify it.
bool hasComponent(const Entity::Identifier &entityIdentifier) const
Tell whether an entity has a component of a given type.
ComponentRegistry & getComponentRegistry(void)
Get the registry in which the builder creates components.
Owns entities and gives the systems the list of entities to visit.
void addEntity(std::shared_ptr< Entity > entity)
Make this registry own an entity, so that it stays alive and systems visit it.
Entity::Identifier getIdentifier(void) const noexcept
Get the identifier of the entity.
ComponentRegistry & getComponentRegistry(void)
EntityBuilderBase(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
SurfaceBase(ecs::ComponentRegistry ®istry, const SurfaceConfig &config)
SurfaceBase & setChildren(const Children &children)
Makes the interaction helpers callable from guillaume::entities without qualification.
Makes the placement helpers callable from guillaume::entities without qualification.
Makes the color helpers callable from guillaume::entities without qualification.
State. Every class here is plain data attached to an entity.
Widgets: the classes used to create entities with the right components and children.
std::shared_ptr< Text > buildText(ecs::ComponentRegistry ®istry, ecs::EntityRegistry &entityRegistry, std::shared_ptr< ecs::Entity > parent, const std::string &content, float fontSize, const utility::graphic::Color32Bit &color)
Create a Text of a given font size as a child of a widget, or nothing when there is no content.
utility::graphic::Color32Bit schemeColor(SchemeColorRole role)
Look up a color role in the color scheme of the active theme.
@ BodyLarge
16 / 24, regular.
@ Full
Fully rounded (buttons, icon buttons, badges).
float getShapeRadius(theme::ShapeRole role)
Get the corner radius the active theme gives to a shape role.
Everything needed to set up a surface in one value: where it is, how it looks and how it arranges its...