guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
app_bar.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/app_bar.hpp"
24
25#include <utility>
26
28{
30 {
31 return _variant;
32 }
33
35 {
36 if (_variant != variant) {
37 _variant = variant;
38 setHasChanged(true);
39 }
40 return *this;
41 }
42
43 const std::string &AppBar::getTitle(void) const noexcept
44 {
45 return _title;
46 }
47
48 AppBar &AppBar::setTitle(const std::string &title)
49 {
50 if (_title != title) {
51 _title = title;
52 setHasChanged(true);
53 }
54 return *this;
55 }
56
57 const AppBar::Action &AppBar::getNavigation(void) const noexcept
58 {
59 return _navigation;
60 }
61
63 {
64 // An action carries a callback, which cannot be compared.
65 _navigation = std::move(navigation);
66 setHasChanged(true);
67 return *this;
68 }
69
70 const std::vector<AppBar::Action> &AppBar::getActions(void) const noexcept
71 {
72 return _actions;
73 }
74
75 AppBar &AppBar::setActions(std::vector<Action> actions)
76 {
77 // An action carries a callback, which cannot be compared.
78 _actions = std::move(actions);
79 setHasChanged(true);
80 return *this;
81 }
82
83 bool AppBar::isElevated(void) const noexcept
84 {
85 return _elevated;
86 }
87
89 {
90 if (_elevated != elevated) {
91 _elevated = elevated;
92 setHasChanged(true);
93 }
94 return *this;
95 }
96
98 {
99 return _navigationButton;
100 }
101
103 {
104 if (_navigationButton != identifier) {
105 _navigationButton = identifier;
106 setHasChanged(true);
107 }
108 return *this;
109 }
110
112 {
113 return _titleEntity;
114 }
115
117 {
118 if (_titleEntity != identifier) {
119 _titleEntity = identifier;
120 setHasChanged(true);
121 }
122 return *this;
123 }
124
126 {
127 return _actionButtons;
128 }
129
131 {
132 if (_actionButtons != identifiers) {
133 _actionButtons = identifiers;
134 setHasChanged(true);
135 }
136 return *this;
137 }
138} // namespace guillaume::components
ecs::Entity::Identifier getNavigationButton(void) const noexcept
Get the icon button child built for the navigation action.
Definition app_bar.cpp:97
Variant getVariant(void) const noexcept
Get the shape of the bar.
Definition app_bar.cpp:29
AppBar & setTitleEntity(ecs::Entity::Identifier identifier)
Record the text child that displays the title.
Definition app_bar.cpp:116
AppBar(void)=default
Create the configuration of a small, flat bar with no title and no icon.
AppBar & setVariant(Variant variant)
Set the shape of the bar, which decides its height and the size of its title.
Definition app_bar.cpp:34
bool isElevated(void) const noexcept
Tell whether the bar is elevated.
Definition app_bar.cpp:83
AppBar & setElevated(bool elevated)
Raise or flatten the bar.
Definition app_bar.cpp:88
ecs::Entity::Identifier getTitleEntity(void) const noexcept
Get the text child that displays the title.
Definition app_bar.cpp:111
const Identifiers & getActionButtons(void) const noexcept
Get the icon button children built for the trailing actions.
Definition app_bar.cpp:125
std::vector< ecs::Entity::Identifier > Identifiers
Identifiers of child entities, in display order.
Definition app_bar.hpp:79
AppBar & setNavigationButton(ecs::Entity::Identifier identifier)
Record the icon button child built for the navigation action.
Definition app_bar.cpp:102
const std::string & getTitle(void) const noexcept
Get the title shown in the bar.
Definition app_bar.cpp:43
AppBar & setActionButtons(const Identifiers &identifiers)
Record the icon button children built for the trailing actions.
Definition app_bar.cpp:130
Variant
Shape of the bar. It sets the height and the title size.
Definition app_bar.hpp:64
AppBar & setTitle(const std::string &title)
Set the title shown in the bar.
Definition app_bar.cpp:48
AppBar & setNavigation(Action navigation)
Set the leading navigation action.
Definition app_bar.cpp:62
AppBar & setActions(std::vector< Action > actions)
Replace the trailing actions.
Definition app_bar.cpp:75
const Action & getNavigation(void) const noexcept
Get the leading navigation action (back arrow, menu icon).
Definition app_bar.cpp:57
const std::vector< Action > & getActions(void) const noexcept
Get the trailing actions.
Definition app_bar.cpp:70
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.
One pressable icon of the bar: the leading navigation icon or a trailing action.
Definition app_bar.hpp:70