22#include "guillaume/systems/button.hpp"
26#include "guillaume/components/accessibility.hpp"
27#include "guillaume/components/color.hpp"
28#include "guillaume/components/glyph.hpp"
29#include "guillaume/components/hand_button_interaction.hpp"
30#include "guillaume/components/hand_hover_interaction.hpp"
31#include "guillaume/components/mouse_button_interaction.hpp"
32#include "guillaume/components/mouse_hover_interaction.hpp"
33#include "guillaume/components/style_state.hpp"
34#include "guillaume/components/text.hpp"
35#include "guillaume/components/transform.hpp"
36#include "guillaume/components/typography.hpp"
37#include "guillaume/systems/typography.hpp"
38#include "guillaume/theme.hpp"
45 , _identifier(identifier)
49 Button::Child::operator bool(
void)
const
111 const auto pressed = [storage, id]() {
114 const auto released = [storage, id]() {
117 const auto hovered = [storage, id]() {
122 .setOnButtonPressHandler(utility::event::HandButtonEvent::Button::A,
124 .setOnButtonReleaseHandler(
125 utility::event::HandButtonEvent::Button::A, released);
127 .setOnButtonPressHandler(
128 utility::event::MouseButtonEvent::Button::Left, pressed)
129 .setOnButtonReleaseHandler(
130 utility::event::MouseButtonEvent::Button::Left, released);
132 .setOnHoverHandler(hovered)
135 .setOnHoverHandler(hovered)
162 .isButtonPressed(utility::event::HandButtonEvent::Button::A)
166 utility::event::MouseButtonEvent::Button::Left);
183 utility::graphic::Color32Bit
185 const utility::graphic::Color32Bit &color)
190 utility::graphic::Color32Bit
192 const utility::graphic::Color32Bit &color)
199 float width,
float height)
201 const utility::graphic::SizeUI margin(
202 static_cast<unsigned int>(
204 static_cast<unsigned int>(
208 .setAccessibilityMargin(margin);
210 .setAccessibilityMargin(margin);
225 .
setSelected(button.isToggle() && button.isSelected());
231 const auto function =
234 if (function !=
nullptr) {
235 function(registry, identifier);
245 if (!button.isToggle()) {
267 if (
isDisabled(registry, identifier) || !button.isVisible()) {
279 if (
isDisabled(registry, identifier) || !button.isVisible()) {
282 if (button.isToggle()) {
283 button.setSelected(!button.isSelected());
289 const auto onLongPress = button.getOnLongPress();
290 const auto onClick = button.getOnClick();
291 const bool longPress = onLongPress
293 && std::chrono::steady_clock::now() - button.getPressStart()
295 button.setPressStart({});
298 }
else if (onClick) {
What an entity means to a user who does not see it: its name, its role, its state and its place in th...
Main color of an entity: the fill of a shape, or the ink of a text or an icon.
An icon: one glyph of the Material Symbols font, chosen by name, at a given size.
Glyph & setName(const std::string &name)
Choose the icon by name.
Glyph & setStyle(const Style &style)
Set the font family of the icon.
Whether an XR hand (controller) aims at an entity, what to call when the aim enters or leaves,...
HandHoverInteraction & setOnUnhoverHandler(const UnhoverHandler &handler)
Store the callback run when the hand ray leaves the entity.
Whether the mouse pointer is over an entity, what to call when it enters or leaves,...
MouseHoverInteraction & setOnUnhoverHandler(const UnhoverHandler &handler)
Store the callback run when the pointer leaves the entity.
The interaction state of an entity in one place: enabled or disabled, and whether it is hovered,...
A run of text: its content, its font metrics and the position of the editing cursor.
Which typescale role a text uses (BodyMedium, TitleLarge, ...) and an optional explicit size.
Typography & setFontSize(std::optional< float > fontSize)
Override the font size of the role, or clear the override.
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...
static constexpr Identifier InvalidIdentifier
"No entity": never the identifier of a real entity
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...
static void apply(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Resolve the metrics of one text and write them into its components::Text.
static constexpr float touchMargin(float extent)
Get the invisible margin that makes a small control as easy to hit as MinTouchTarget.
State. Every class here is plain data attached to an entity.
ButtonInteraction< utility::event::MouseButtonEvent, utility::event::MouseButtonEvent::Button, MouseButtons.size(), MouseButtons > MouseButtonInteraction
Which mouse buttons are held on an entity, with a press and a release handler per button.
ButtonInteraction< utility::event::HandButtonEvent, utility::event::HandButtonEvent::Button, HandButtons.size(), HandButtons > HandButtonInteraction
Which XR controller buttons are held on an entity, with a press and a release handler per button.
The entity-component-system core, independent of any widget.
Rules. Every class here runs each frame on the entities that have the components it declares.
TypeRole
The named text styles of Material Design 3: what a piece of text is, not how big it is.