guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
chip.hpp
1/*
2 Copyright (c) 2026 ETIB Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22
23#pragma once
24
25#include <string>
26
27#include "guillaume/ecs/system_filler.hpp"
28
29#include "guillaume/components/chip.hpp"
30
31namespace guillaume::systems
32{
69 class Chip: public ecs::SystemFiller<components::Chip>
70 {
71 public:
76 Chip(void);
77
81 ~Chip(void) override = default;
82
99 static void install(ecs::ComponentRegistry &componentRegistry,
100 const ecs::Entity::Identifier &entityIdentifier);
101
114 static void
115 installCloseIcon(ecs::ComponentRegistry &componentRegistry,
116 const ecs::Entity::Identifier &entityIdentifier);
117
148 static void apply(ecs::ComponentRegistry &componentRegistry,
149 const ecs::Entity::Identifier &entityIdentifier);
150
164 static void press(ecs::ComponentRegistry &componentRegistry,
165 const ecs::Entity::Identifier &entityIdentifier);
166
177 static void close(ecs::ComponentRegistry &componentRegistry,
178 const ecs::Entity::Identifier &entityIdentifier);
179
191 static void setSelected(ecs::ComponentRegistry &componentRegistry,
192 const ecs::Entity::Identifier &entityIdentifier,
193 bool selected);
194
202 static bool isSelected(const ecs::ComponentRegistry &componentRegistry,
203 const ecs::Entity::Identifier &entityIdentifier);
204
216 static void setDisabled(ecs::ComponentRegistry &componentRegistry,
217 const ecs::Entity::Identifier &entityIdentifier,
218 bool disabled);
219
227 static bool isDisabled(const ecs::ComponentRegistry &componentRegistry,
228 const ecs::Entity::Identifier &entityIdentifier);
229
242 static std::string
243 leadingGlyph(const ecs::ComponentRegistry &componentRegistry,
244 const ecs::Entity::Identifier &entityIdentifier);
245
253 static bool
254 needsCheckIcon(const ecs::ComponentRegistry &componentRegistry,
255 const ecs::Entity::Identifier &entityIdentifier);
256
265 static bool
266 needsCloseIcon(const ecs::ComponentRegistry &componentRegistry,
267 const ecs::Entity::Identifier &entityIdentifier);
268
274 void update(const ecs::Entity::Identifier &entityIdentifier) override;
275 };
276
277} // namespace guillaume::systems
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
Definition entity.hpp:86
The base class to derive a system from: a System whose signature is the list of component types given...
~Chip(void) override=default
Default destructor.
void update(const ecs::Entity::Identifier &entityIdentifier) override
Frame entry point: call apply on one chip.
Definition chip.cpp:340
static void setDisabled(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, bool disabled)
Enable or disable the chip and show it at once.
Definition chip.cpp:212
Chip(void)
Create the system for the Layout phase, matching entities that have a components::Chip.
Definition chip.cpp:107
static void apply(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Draw one chip from its components and arrange its children.
Definition chip.cpp:256
static bool needsCheckIcon(const ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Whether the widget class should build a selected check child for this chip.
Definition chip.cpp:184
static void press(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Press the chip as a click does.
Definition chip.cpp:220
static bool needsCloseIcon(const ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Whether the widget class should build a trailing close icon child for this chip.
Definition chip.cpp:193
static std::string leadingGlyph(const ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Get the name of the glyph the leading icon of the chip should show.
Definition chip.cpp:171
static void install(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Make an entity behave as a chip.
Definition chip.cpp:112
static bool isDisabled(const ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Whether the chip ignores input and is drawn disabled.
Definition chip.cpp:164
static void close(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Press the close icon of the chip as a click does.
Definition chip.cpp:240
static void installCloseIcon(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Make the trailing icon of a chip a close button.
Definition chip.cpp:134
static bool isSelected(const ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Whether the chip is selected.
Definition chip.cpp:156
static void setSelected(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, bool selected)
Select or deselect the chip from code and show it at once.
Definition chip.cpp:203
Rules. Every class here runs each frame on the entities that have the components it declares.