guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
navigation_bar_destination.cpp
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#include "guillaume/components/navigation_bar_destination.hpp"
24
25#include <utility>
26
28{
29 const std::string &NavigationBarDestination::getIcon(void) const noexcept
30 {
31 return _icon;
32 }
33
35 NavigationBarDestination::setIcon(const std::string &icon)
36 {
37 if (_icon != icon) {
38 _icon = icon;
39 setHasChanged(true);
40 }
41 return *this;
42 }
43
44 const std::string &
46 {
47 return _focusedIcon;
48 }
49
52 {
53 if (_focusedIcon != icon) {
54 _focusedIcon = icon;
55 setHasChanged(true);
56 }
57 return *this;
58 }
59
60 const std::string &NavigationBarDestination::getLabel(void) const noexcept
61 {
62 return _label;
63 }
64
66 NavigationBarDestination::setLabel(const std::string &label)
67 {
68 if (_label != label) {
69 _label = label;
70 setHasChanged(true);
71 }
72 return *this;
73 }
74
75 const std::string &NavigationBarDestination::getBadge(void) const noexcept
76 {
77 return _badge;
78 }
79
81 NavigationBarDestination::setBadge(const std::string &badge)
82 {
83 if (_badge != badge) {
84 _badge = badge;
85 setHasChanged(true);
86 }
87 return *this;
88 }
89
91 {
92 return _showLabel;
93 }
94
96 {
97 if (_showLabel != show) {
98 _showLabel = show;
99 setHasChanged(true);
100 }
101 return *this;
102 }
103
106 {
107 return _indicator;
108 }
109
111 ecs::Entity::Identifier identifier)
112 {
113 if (_indicator != identifier) {
114 _indicator = identifier;
115 setHasChanged(true);
116 }
117 return *this;
118 }
119
122 {
123 return _iconEntity;
124 }
125
127 ecs::Entity::Identifier identifier)
128 {
129 if (_iconEntity != identifier) {
130 _iconEntity = identifier;
131 setHasChanged(true);
132 }
133 return *this;
134 }
135
138 {
139 return _labelEntity;
140 }
141
143 ecs::Entity::Identifier identifier)
144 {
145 if (_labelEntity != identifier) {
146 _labelEntity = identifier;
147 setHasChanged(true);
148 }
149 return *this;
150 }
151
154 {
155 return _badgeEntity;
156 }
157
159 ecs::Entity::Identifier identifier)
160 {
161 if (_badgeEntity != identifier) {
162 _badgeEntity = identifier;
163 setHasChanged(true);
164 }
165 return *this;
166 }
167
170 {
171 return _onPress;
172 }
173
176 {
177 _onPress = std::move(handler);
178 return *this;
179 }
180} // namespace guillaume::components
State of one destination of a navigation bar: an icon in a pill, a label under it and an optional bad...
NavigationBarDestination & setLabelEntity(ecs::Entity::Identifier identifier)
Record the child that draws the label.
NavigationBarDestination & setBadge(const std::string &badge)
Set the text of the badge.
ecs::Entity::Identifier getIndicator(void) const noexcept
Get the pill drawn behind the icon of the selected destination.
NavigationBarDestination & setOnPress(PressHandler handler)
Set the callback run when the user presses the destination.
const PressHandler & getOnPress(void) const noexcept
Get the callback run when the user presses the destination.
NavigationBarDestination & setLabel(const std::string &label)
Set the text shown under the icon.
NavigationBarDestination(void)=default
Create the configuration of a destination with no icon, no text and a visible label.
std::function< void(void)> PressHandler
Callback run when the user presses the destination.
ecs::Entity::Identifier getIconEntity(void) const noexcept
Get the child that draws the icon.
NavigationBarDestination & setIconEntity(ecs::Entity::Identifier identifier)
Record the child that draws the icon.
NavigationBarDestination & setIcon(const std::string &icon)
Set the icon shown while the destination is not selected.
const std::string & getLabel(void) const noexcept
Get the text shown under the icon.
NavigationBarDestination & setBadgeEntity(ecs::Entity::Identifier identifier)
Record the child that draws the badge.
const std::string & getFocusedIcon(void) const noexcept
Get the icon shown while the destination is selected.
NavigationBarDestination & setFocusedIcon(const std::string &icon)
Set the icon shown while the destination is selected, typically the filled version of the unselected ...
ecs::Entity::Identifier getBadgeEntity(void) const noexcept
Get the child that draws the badge.
NavigationBarDestination & setShowLabel(bool show)
Show or hide the label.
NavigationBarDestination & setIndicator(ecs::Entity::Identifier identifier)
Record the active indicator pill child.
const std::string & getIcon(void) const noexcept
Get the icon shown while the destination is not selected.
ecs::Entity::Identifier getLabelEntity(void) const noexcept
Get the child that draws the label.
const std::string & getBadge(void) const noexcept
Get the text of the badge.
bool isLabelShown(void) const noexcept
Tell whether the label is visible.
void setHasChanged(bool hasChanged)
Raise or lower the changed flag.
Definition component.cpp:32
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
State. Every class here is plain data attached to an entity.