guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::Scheme Class Reference

One complete set of colors: a color for every SchemeColorRole. More...

#include <headers/guillaume/theme.hpp>

Public Member Functions

 Scheme (void)=default
 Create a scheme in which every role has a default-constructed, unnamed color.
 Scheme (const std::array< ExtendedColor, static_cast< std::size_t >(SchemeColorRole::Count)> &colors)
 Create a scheme from a full set of colors.
 ~Scheme (void)=default
 Default destructor.
const ExtendedColor & getColor (SchemeColorRole role) const
 Get the color of a role, with its name and description.
ExtendedColor & getColor (SchemeColorRole role)
 Get the color of a role, to modify it in place.
void setColor (SchemeColorRole role, const ExtendedColor &color)
 Replace the color of a role, with its name and description.
void setColor (SchemeColorRole role, const utility::graphic::Color32Bit &color, const std::string &name="", const std::string &description="", bool harmonized=false)
 Replace the color of a role from a plain color value.
const auto & getColors (void) const
 Get every color of the scheme.

Detailed Description

One complete set of colors: a color for every SchemeColorRole.

A Theme holds six schemes (ThemeSchemeRole). Widgets read the active one through getActiveColor(). To change a color, edit the scheme in a copy of the theme and activate the copy:

.setColor(guillaume::SchemeColorRole::Primary,
utility::graphic::Color32Bit(0, 106, 106, 255));
Every design token of the UI in one object: colors, type scale, corner shapes, elevation,...
Definition theme.hpp:535
Design tokens: colors, type scale, shapes, elevation, motion and spacing. Read them through guillaume...
@ Light
Light scheme, standard contrast.
Definition theme.hpp:124
const Theme & getActiveTheme(void)
Get the theme every widget and system reads its tokens from.
void setActiveTheme(const Theme &theme)
Replace the active theme by a copy of another theme.
See also
Theme
getActiveScheme

Definition at line 262 of file theme.hpp.

Constructor & Destructor Documentation

◆ Scheme()

guillaume::Scheme::Scheme ( const std::array< ExtendedColor, static_cast< std::size_t >(SchemeColorRole::Count)> & colors)
explicit

Create a scheme from a full set of colors.

Parameters
colorsOne color per role, in the order of the SchemeColorRole enumerators.

Member Function Documentation

◆ getColor() [1/2]

ExtendedColor & guillaume::Scheme::getColor ( SchemeColorRole role)

Get the color of a role, to modify it in place.

Parameters
roleThe role to look up. Must not be SchemeColorRole::Count.
Returns
Mutable reference to the color of that role.

◆ getColor() [2/2]

const ExtendedColor & guillaume::Scheme::getColor ( SchemeColorRole role) const

Get the color of a role, with its name and description.

Parameters
roleThe role to look up. Must not be SchemeColorRole::Count.
Returns
The color of that role; call getColor() on it for the value to draw with.

◆ getColors()

const auto & guillaume::Scheme::getColors ( void ) const

Get every color of the scheme.

Returns
The array of colors, indexed by SchemeColorRole.
Note
The return type is deduced and the function is defined in theme.cpp, so it can only be called from that file. Use getColor() elsewhere.

◆ setColor() [1/2]

void guillaume::Scheme::setColor ( SchemeColorRole role,
const ExtendedColor & color )

Replace the color of a role, with its name and description.

Parameters
roleThe role to change. Must not be SchemeColorRole::Count.
colorThe new color and its documentation.

◆ setColor() [2/2]

void guillaume::Scheme::setColor ( SchemeColorRole role,
const utility::graphic::Color32Bit & color,
const std::string & name = "",
const std::string & description = "",
bool harmonized = false )

Replace the color of a role from a plain color value.

The name, the description and the harmonized flag of the role are replaced too, by the arguments or their defaults.

Parameters
roleThe role to change. Must not be SchemeColorRole::Count.
colorThe new color, 8 bits per RGBA channel.
nameThe name of the color; empty by default.
descriptionWhat the color is for; empty by default.
harmonizedTrue when the color was shifted toward the theme's source color.

The documentation for this class was generated from the following file: