guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
navigation_drawer_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_drawer_destination.hpp"
24
25#include <utility>
26
28{
29 const std::string &NavigationDrawerDestination::getIcon(void) const noexcept
30 {
31 return _icon;
32 }
33
35 NavigationDrawerDestination::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 _label;
48 }
49
51 NavigationDrawerDestination::setLabel(const std::string &label)
52 {
53 if (_label != label) {
54 _label = label;
55 setHasChanged(true);
56 }
57 return *this;
58 }
59
60 const std::string &
62 {
63 return _right;
64 }
65
67 NavigationDrawerDestination::setRight(const std::string &right)
68 {
69 if (_right != right) {
70 _right = right;
71 setHasChanged(true);
72 }
73 return *this;
74 }
75
77 {
78 return _disabled;
79 }
80
83 {
84 if (_disabled != disabled) {
85 _disabled = disabled;
86 setHasChanged(true);
87 }
88 return *this;
89 }
90
92 {
93 return _collapsed;
94 }
95
98 {
99 if (_collapsed != collapsed) {
100 _collapsed = collapsed;
101 setHasChanged(true);
102 }
103 return *this;
104 }
105
108 {
109 return _lead;
110 }
111
114 {
115 if (_lead != identifier) {
116 _lead = identifier;
117 setHasChanged(true);
118 }
119 return *this;
120 }
121
124 {
125 return _iconEntity;
126 }
127
129 ecs::Entity::Identifier identifier)
130 {
131 if (_iconEntity != identifier) {
132 _iconEntity = identifier;
133 setHasChanged(true);
134 }
135 return *this;
136 }
137
140 {
141 return _labelEntity;
142 }
143
145 ecs::Entity::Identifier identifier)
146 {
147 if (_labelEntity != identifier) {
148 _labelEntity = identifier;
149 setHasChanged(true);
150 }
151 return *this;
152 }
153
156 {
157 return _rightEntity;
158 }
159
161 ecs::Entity::Identifier identifier)
162 {
163 if (_rightEntity != identifier) {
164 _rightEntity = identifier;
165 setHasChanged(true);
166 }
167 return *this;
168 }
169
172 {
173 return _onPress;
174 }
175
178 {
179 _onPress = std::move(handler);
180 return *this;
181 }
182} // namespace guillaume::components
State of one destination of a navigation drawer: an icon, a label and an optional text at the trailin...
ecs::Entity::Identifier getLead(void) const noexcept
Get the leading child of the destination.
NavigationDrawerDestination & setIconEntity(ecs::Entity::Identifier identifier)
Record the child that draws the icon.
ecs::Entity::Identifier getLabelEntity(void) const noexcept
Get the child that draws the label.
const PressHandler & getOnPress(void) const noexcept
Get the callback run when the user presses the destination.
NavigationDrawerDestination & setIcon(const std::string &icon)
Set the icon of the destination.
NavigationDrawerDestination & setDisabled(bool disabled)
Disable or enable the destination.
NavigationDrawerDestination(void)=default
Create the configuration of an enabled, regular destination with no icon and no text.
const std::string & getLabel(void) const noexcept
Get the label of the destination.
const std::string & getRight(void) const noexcept
Get the text shown at the trailing edge of a regular item.
NavigationDrawerDestination & setOnPress(PressHandler handler)
Set the callback run when the user presses the destination while it is enabled.
NavigationDrawerDestination & setRightEntity(ecs::Entity::Identifier identifier)
Record the child that draws the trailing text.
NavigationDrawerDestination & setLabel(const std::string &label)
Set the label of the destination.
NavigationDrawerDestination & setCollapsed(bool collapsed)
Choose between the regular row and the collapsed (rail) rendering.
NavigationDrawerDestination & setLabelEntity(ecs::Entity::Identifier identifier)
Record the child that draws the label.
ecs::Entity::Identifier getRightEntity(void) const noexcept
Get the child that draws the trailing text.
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.
NavigationDrawerDestination & setLead(ecs::Entity::Identifier identifier)
Record the leading child of the destination.
bool isDisabled(void) const noexcept
Tell whether the destination ignores presses.
const std::string & getIcon(void) const noexcept
Get the icon of the destination.
bool isCollapsed(void) const noexcept
Tell which rendering the destination uses.
NavigationDrawerDestination & setRight(const std::string &right)
Set the text shown at the trailing edge of a regular item, such as an unread count.
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.