22#include "guillaume/systems/radio_button.hpp"
24#include "guillaume/components/accessibility.hpp"
25#include "guillaume/components/bound.hpp"
26#include "guillaume/components/color.hpp"
27#include "guillaume/components/hand_hover_interaction.hpp"
28#include "guillaume/components/layout.hpp"
29#include "guillaume/components/mouse_hover_interaction.hpp"
30#include "guillaume/components/ring.hpp"
31#include "guillaume/components/selection.hpp"
35#include "guillaume/systems/layout.hpp"
36#include "guillaume/theme.hpp"
61 [registry, identifier]() {
62 press(*registry, identifier);
64 [registry, identifier]() {
65 apply(*registry, identifier);
72 const auto margin =
static_cast<unsigned int>(
76 .setAccessibilityMargin(utility::graphic::SizeUI(margin, margin));
79 .setAccessibilityMargin(utility::graphic::SizeUI(margin, margin));
82 .setOnSelectionChangedHandler([registry, identifier](
bool) {
83 apply(*registry, identifier);
91 return componentRegistry
103 .setSelected(selected);
104 apply(componentRegistry, entityIdentifier);
110 if (
isDisabled(componentRegistry, entityIdentifier)) {
114 select(componentRegistry, entityIdentifier,
true);
136 variant != Variant::Disabled);
138 const bool disabled =
isDisabled(componentRegistry, entityIdentifier);
139 const bool errored = (variant == Variant::Error);
140 const bool selected =
149 }
else if (errored) {
150 color.setColor(
schemeColor(SchemeColorRole::Error));
151 }
else if (selected) {
152 color.setColor(
schemeColor(SchemeColorRole::Primary));
154 color.setColor(
schemeColor(SchemeColorRole::OnSurfaceVariant));
159 .setLabel(radio.getLabel())
164 const auto layer =
Layout::layerOf(componentRegistry, entityIdentifier);
165 const auto dot = radio.getDot();
167 const auto dotColor = disabled
170 : SchemeColorRole::Primary);
179 const auto label = radio.getLabelEntity();
184 : SchemeColorRole::OnSurface));
190 const auto &labelBound =
195 const float y = (ring.getHeight() - labelBound.getHeight()) / 2.0f;
197 utility::graphic::PositionF(x, y, 0.0f),
200 x + labelBound.getWidth()
What an entity means to a user who does not see it: its name, its role, its state and its place in th...
Accessibility & setSelected(bool selected)
Set whether the entity is the selected one of its group.
Accessibility & setChecked(std::optional< CheckedState > checked)
Set whether the entity is ticked.
Size of an entity: the width and height, in dp, of the rectangle that starts at the position of its c...
Main color of an entity: the fill of a shape, or the ink of a text or an icon.
Whether an XR hand (controller) aims at an entity, what to call when the aim enters or leaves,...
How a container arranges its children: in a row or a column, with which alignment,...
Whether the mouse pointer is over an entity, what to call when it enters or leaves,...
A full ring: the outline of a radio button, the track of a circular progress indicator.
Selected/unselected flag of an entity, with a callback run when it changes.
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.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
SystemFiller(Phase phase)
ecs::ComponentRegistry & getComponentRegistry(void)
Get the component registry of the scene being processed.
bool requireComponent(const ecs::Entity::Identifier &entityIdentifier)
Tell whether an entity has a component, and log a warning naming the entity and the component when it...
Arranges the children of a container in a row or a column and sizes the container around them.
static std::uint32_t layerOf(const ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &identifier)
Get the layer of an entity: its depth in the entity tree.
State. Every class here is plain data attached to an entity.
The entity-component-system core, independent of any widget.
void centerChild(ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &parentIdentifier, const ecs::Entity::Identifier &childIdentifier, std::uint32_t parentLayer)
Center a child inside the bound of its parent, on both axes.
void placeChild(ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &parentIdentifier, const ecs::Entity::Identifier &childIdentifier, const utility::graphic::PositionF &offset, std::uint32_t parentLayer)
Place a child at an offset from the position of its parent.
void reserveTrailingWidth(ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &identifier, float width)
Reserve layout room after an entity's Bound.
utility::graphic::Color32Bit transparentColor(void)
The color written to hide a fill or an outline without removing its component.
utility::graphic::Color32Bit disabledContentColor(void)
Color of the icon, label or outline of a disabled widget.
utility::graphic::Color32Bit schemeColor(SchemeColorRole role)
Look up a color role in the color scheme of the active theme.
Rules. Every class here runs each frame on the entities that have the components it declares.
utility::graphic::Color32Bit transparentColor(void)
The color written to hide a fill or an outline without removing its component.
utility::graphic::Color32Bit disabledContentColor(void)
Color of the icon, label or outline of a disabled widget.
utility::graphic::Color32Bit schemeColor(SchemeColorRole role)
Look up a color role in the color scheme of the active theme.
Helpers of the namespace systems::interaction: what "pressable" means for a widget,...
bool isEnabled(const ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &entityIdentifier)
Whether an entity accepts input.
void makeInteractive(ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &entityIdentifier, components::AccessibilityRole role, std::function< void(void)> onPress, std::function< void(void)> onStateChange={})
Make an entity hoverable, pressable and focusable.
void setEnabled(ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &entityIdentifier, bool enabled)
Enable or disable an entity.
Placement helpers for the children systems::Layout does not arrange.
Color helpers shared by the widget systems: scheme lookup, state layers and the disabled colors.