guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
style_helpers.hpp
Go to the documentation of this file.
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 <cstdint>
26
27#include <utility/graphic/color.hpp>
28
29#include "guillaume/theme.hpp"
30
48
55{
56
64 inline utility::graphic::Color32Bit
65 withAlpha(const utility::graphic::Color32Bit &color, std::uint8_t alpha)
66 {
67 return utility::graphic::Color32Bit(color.getRed(), color.getGreen(),
68 color.getBlue(), alpha);
69 }
70
82 inline utility::graphic::Color32Bit
83 stateLayer(const utility::graphic::Color32Bit &base,
84 const utility::graphic::Color32Bit &overlay,
85 std::uint8_t alpha)
86 {
87 return overlay.withAlpha(alpha).blendOver(base);
88 }
89
96 inline utility::graphic::Color32Bit schemeColor(SchemeColorRole role)
97 {
98 return guillaume::getActiveColor(role);
99 }
100
118 inline utility::graphic::Color32Bit
119 stateLayer(const utility::graphic::Color32Bit &base,
120 const utility::graphic::Color32Bit &overlay,
121 theme::StateLayer layer)
122 {
123 return stateLayer(base, overlay, getStateLayerAlpha(layer));
124 }
125
131 inline utility::graphic::Color32Bit disabledContentColor(void)
132 {
133 return withAlpha(
134 schemeColor(SchemeColorRole::OnSurface),
136 }
137
143 inline utility::graphic::Color32Bit disabledContainerColor(void)
144 {
145 return withAlpha(
146 schemeColor(SchemeColorRole::OnSurface),
148 }
149
155 inline utility::graphic::Color32Bit transparentColor(void)
156 {
157 return utility::graphic::Color32Bit(0, 0, 0, 0);
158 }
159
160} // namespace guillaume::systems::style
Color helpers shared by the widget systems.
utility::graphic::Color32Bit disabledContainerColor(void)
Fill color of the container of a disabled widget.
utility::graphic::Color32Bit transparentColor(void)
The color written to hide a fill or an outline without removing its component.
utility::graphic::Color32Bit stateLayer(const utility::graphic::Color32Bit &base, const utility::graphic::Color32Bit &overlay, std::uint8_t alpha)
Blend a translucent tint over a base color.
utility::graphic::Color32Bit disabledContentColor(void)
Color of the icon, label or outline of a disabled widget.
utility::graphic::Color32Bit withAlpha(const utility::graphic::Color32Bit &color, std::uint8_t alpha)
Copy a color with another alpha channel.
utility::graphic::Color32Bit schemeColor(SchemeColorRole role)
Look up a color role in the color scheme of the active theme.
StateLayer
The interaction states that change how a widget is drawn.
Definition tokens.hpp:223
@ DisabledContainer
0.12 opacity of onSurface containers.
Definition tokens.hpp:229
@ DisabledContent
0.38 opacity of onSurface content.
Definition tokens.hpp:228
std::uint8_t getStateLayerAlpha(theme::StateLayer layer)
Get the opacity the active theme gives to a state layer, as an alpha channel value.
SchemeColorRole
The named colors of a scheme: what a color is used for, not what it looks like.
Definition theme.hpp:58
utility::graphic::Color32Bit getActiveColor(SchemeColorRole role)
Get the color the active scheme gives to a role.