Every design token of the UI in one object: colors, type scale, corner shapes, elevation, state layers and motion.
More...
|
|
| Theme (void) |
| | Create an unnamed theme with the baseline scales and empty color schemes and palettes.
|
| | Theme (const std::string &name, const std::string &description) |
| | Create a named theme with the baseline scales and empty color schemes and palettes.
|
|
virtual | ~Theme (void)=default |
| | Virtual destructor.
|
| const std::string & | getName (void) const |
| | Get the name of the theme.
|
| const std::string & | getDescription (void) const |
| | Get the text describing the theme.
|
| void | setName (const std::string &name) |
| | Replace the name of the theme.
|
| void | setDescription (const std::string &description) |
| | Replace the text describing the theme.
|
| const Scheme & | getScheme (ThemeSchemeRole role) const |
| | Get one of the six color schemes.
|
| Scheme & | getScheme (ThemeSchemeRole role) |
| | Get one of the six color schemes, to change its colors in place.
|
| const Palette & | getPalette (ThemePaletteRole role) const |
| | Get one of the five tonal palettes.
|
| Palette & | getPalette (ThemePaletteRole role) |
| | Get one of the five tonal palettes, to change its tones in place.
|
| void | setScheme (ThemeSchemeRole role, const Scheme &scheme) |
| | Replace one of the six color schemes as a whole.
|
| void | setPalette (ThemePaletteRole role, const Palette &palette) |
| | Replace one of the five tonal palettes as a whole.
|
| const theme::Typescale & | getTypescale (void) const |
| | Get the text styles of the theme.
|
| theme::Typescale & | getTypescale (void) |
| | Get the text styles of the theme, to change a role in place with theme::Typescale::set.
|
| void | setTypescale (const theme::Typescale &typescale) |
| | Replace every text style of the theme at once.
|
| const theme::ShapeScale & | getShapes (void) const |
| | Get the corner radii of the theme.
|
| theme::ShapeScale & | getShapes (void) |
| | Get the corner radii of the theme, to change the roundness in place.
|
| const theme::ElevationScale & | getElevations (void) const |
| | Get the elevation levels of the theme (shadow and surface tint).
|
| theme::ElevationScale & | getElevations (void) |
| | Get the elevation levels of the theme, to change a level in place.
|
| const theme::StateLayerScale & | getStateLayers (void) const |
| | Get the state-layer opacities of the theme (hovered, focused, pressed, ...).
|
| theme::StateLayerScale & | getStateLayers (void) |
| | Get the state-layer opacities of the theme, to change one in place.
|
| const theme::MotionScale & | getMotion (void) const |
| | Get the animation durations of the theme.
|
| theme::MotionScale & | getMotion (void) |
| | Get the animation durations of the theme, to change one in place.
|
Every design token of the UI in one object: colors, type scale, corner shapes, elevation, state layers and motion.
A token is a named design value (the "primary" color, the "title
large" text style, the "medium" corner radius). Widgets and systems never hard-code such values: they ask the active theme through the free functions at the end of this header.
Reading tokens, from anywhere:
guillaume::SchemeColorRole::Primary);
@ TitleLarge
22 / 28, regular.
const theme::TypeToken & getTypeToken(theme::TypeRole role)
Get the text style the active theme gives to a role: font family, weight, size, line height and lette...
float getMotionDuration(theme::MotionDuration duration)
Get the length the active theme gives to a duration token.
float getShapeRadius(theme::ShapeRole role)
Get the corner radius the active theme gives to a shape role.
utility::graphic::Color32Bit getActiveColor(SchemeColorRole role)
Get the color the active scheme gives to a role.
Overriding tokens: copy the active theme, change the copy, activate it. Do it before the Application is created, so the scenes are built with the new values.
.setColor(guillaume::SchemeColorRole::Primary,
utility::graphic::Color32Bit(128, 216, 208, 255));
theme.getShapes().setRoundness(2.0f);
Every design token of the UI in one object: colors, type scale, corner shapes, elevation,...
Design tokens: colors, type scale, shapes, elevation, motion and spacing. Read them through guillaume...
@ Dark
Dark scheme, standard contrast.
const Theme & getActiveTheme(void)
Get the theme every widget and system reads its tokens from.
void setActiveScheme(ThemeSchemeRole role)
Choose which of the six schemes of the active theme is in use, for instance to switch between light a...
void setActiveTheme(const Theme &theme)
Replace the active theme by a copy of another theme.
A default-constructed Theme has the Material Design 3 baseline type scale, shapes, elevations, state layers and motion, but empty color schemes and palettes. The complete default theme, colors included, is defaultTheme, which is also what the active theme starts as.
- See also
- getActiveTheme
-
setActiveTheme
-
theme::Typescale
Definition at line 534 of file theme.hpp.