31#include <utility/graphic/color.hpp>
33#include "guillaume/theme/tokens.hpp"
34#include "guillaume/theme/typescale.hpp"
92 OnPrimaryFixedVariant,
96 OnSecondaryFixedVariant,
100 OnTertiaryFixedVariant,
103 SurfaceContainerLowest,
106 SurfaceContainerHigh,
107 SurfaceContainerHighest,
160 utility::graphic::Color32Bit
163 std::string _description;
184 const std::string &name,
const std::string &description,
196 const utility::graphic::Color32Bit &
getColor(
void)
const;
223 void setColor(
const utility::graphic::Color32Bit &color);
338 const utility::graphic::Color32Bit &color,
339 const std::string &name =
"",
340 const std::string &description =
"",
341 bool harmonized =
false);
370 enum class Tone : std::uint8_t {
386 std::string _description;
387 std::map<Tone, ExtendedColor> _tones;
400 Palette(
const std::string &name,
const std::string &description);
424 const std::map<Tone, ExtendedColor> &
getTones(
void)
const;
455 void setTone(
Tone tone,
const utility::graphic::Color32Bit &color,
456 const std::string &name =
"",
457 const std::string &description =
"",
458 bool harmonized =
false);
538 std::string _description;
539 std::array<Scheme, ThemeSchemeRole::ThemeSchemeCount>
541 std::array<Palette, ThemePaletteRole::ThemePaletteCount>
564 Theme(
const std::string &name,
const std::string &description);
845 utility::graphic::Color32Bit
A color with a name and a description, as stored in a Scheme or a Palette.
ExtendedColor(const utility::graphic::Color32Bit &color, const std::string &name, const std::string &description, bool harmonized)
Create a color with its documentation.
const utility::graphic::Color32Bit & getColor(void) const
Get the color to draw with.
const std::string & getDescription(void) const
Get the text describing what the color is for.
~ExtendedColor(void)=default
Default destructor.
void setColor(const utility::graphic::Color32Bit &color)
Replace the color value; the name and the description are kept.
void setHarmonized(bool harmonized)
Mark the color as harmonized or not.
void setDescription(const std::string &description)
Replace the text describing what the color is for.
bool isHarmonized(void) const
Tell whether the color was shifted toward the theme's source color.
void setName(const std::string &name)
Replace the name of the color.
ExtendedColor(void)
Create a default-constructed color with an empty name and description, not harmonized.
const std::string & getName(void) const
Get the name of the color.
The shades of one color family, from black (tone 0) to white (tone 100).
~Palette(void)=default
Default destructor.
void setTone(Tone tone, const ExtendedColor &color)
Define a tone, replacing the color it already has, if any.
const std::string & getDescription(void) const
Get the text describing what the palette is for.
bool hasTone(Tone tone) const
Tell whether a tone is defined.
void setName(const std::string &name)
Replace the name of the palette.
Palette(const std::string &name, const std::string &description)
Create a palette with a name and no tone.
Palette(void)
Create a palette with no name and no tone.
const ExtendedColor & getTone(Tone tone) const
Get the color of a tone.
const std::string & getName(void) const
Get the name of the palette.
void setTone(Tone tone, const utility::graphic::Color32Bit &color, const std::string &name="", const std::string &description="", bool harmonized=false)
Define a tone from a plain color value, replacing the color it already has, if any.
void clearTones(void)
Undefine every tone of the palette.
void removeTone(Tone tone)
Undefine a tone. Does nothing when it is not defined.
Tone
The tones a palette can hold. The number is the lightness: 0 is black, 100 is white.
void setDescription(const std::string &description)
Replace the text describing what the palette is for.
const std::map< Tone, ExtendedColor > & getTones(void) const
Get every tone defined in the palette.
One complete set of colors: a color for every SchemeColorRole.
Scheme(void)=default
Create a scheme in which every role has a default-constructed, unnamed color.
~Scheme(void)=default
Default destructor.
const auto & getColors(void) const
Get every color of the scheme.
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.
ExtendedColor & getColor(SchemeColorRole role)
Get the color of a role, to modify it in place.
const ExtendedColor & getColor(SchemeColorRole role) const
Get the color of a role, with its name and description.
Scheme(const std::array< ExtendedColor, static_cast< std::size_t >(SchemeColorRole::Count)> &colors)
Create a scheme from a full set of colors.
Every design token of the UI in one object: colors, type scale, corner shapes, elevation,...
void setTypescale(const theme::Typescale &typescale)
Replace every text style of the theme at once.
const std::string & getDescription(void) const
Get the text describing the theme.
void setScheme(ThemeSchemeRole role, const Scheme &scheme)
Replace one of the six color schemes as a whole.
theme::Typescale & getTypescale(void)
Get the text styles of the theme, to change a role in place with theme::Typescale::set.
const theme::Typescale & getTypescale(void) const
Get the text styles of the theme.
const theme::ElevationScale & getElevations(void) const
Get the elevation levels of the theme (shadow and surface tint).
Theme(void)
Create an unnamed theme with the baseline scales and empty color schemes and palettes.
const Palette & getPalette(ThemePaletteRole role) const
Get one of the five tonal palettes.
Scheme & getScheme(ThemeSchemeRole role)
Get one of the six color schemes, to change its colors in place.
const theme::MotionScale & getMotion(void) const
Get the animation durations of the theme.
const theme::StateLayerScale & getStateLayers(void) const
Get the state-layer opacities of the theme (hovered, focused, pressed, ...).
const theme::ShapeScale & getShapes(void) const
Get the corner radii of the theme.
virtual ~Theme(void)=default
Virtual destructor.
Theme(const std::string &name, const std::string &description)
Create a named theme with the baseline scales and empty color schemes and palettes.
void setName(const std::string &name)
Replace the name of the theme.
theme::ShapeScale & getShapes(void)
Get the corner radii of the theme, to change the roundness in place.
const std::string & getName(void) const
Get the name of the theme.
theme::StateLayerScale & getStateLayers(void)
Get the state-layer opacities of the theme, to change one in place.
const Scheme & getScheme(ThemeSchemeRole role) const
Get one of the six color schemes.
theme::MotionScale & getMotion(void)
Get the animation durations of the theme, to change one in place.
void setPalette(ThemePaletteRole role, const Palette &palette)
Replace one of the five tonal palettes as a whole.
theme::ElevationScale & getElevations(void)
Get the elevation levels of the theme, to change a level in place.
Palette & getPalette(ThemePaletteRole role)
Get one of the five tonal palettes, to change its tones in place.
void setDescription(const std::string &description)
Replace the text describing the theme.
The six elevation levels of a theme: one ElevationToken per ElevationLevel.
The animation timings of a theme: one length per MotionDuration, plus which easing curve to use for w...
Turns a ShapeRole into a corner radius in dp, scaled by one "roundness" value.
The opacity of each StateLayer, 0 to 1.
The text styles of a theme: one TypeToken per TypeRole.
Design tokens: colors, type scale, shapes, elevation, motion and spacing. Read them through guillaume...
ElevationLevel
How far a surface is raised above the background, in six steps.
TypeRole
The named text styles of Material Design 3: what a piece of text is, not how big it is.
StateLayer
The interaction states that change how a widget is drawn.
MotionDuration
The named animation lengths of Material Design 3. The values given are the defaults.
ShapeRole
The corner radii a widget can ask for, by name.
A C++20 UI framework for desktop and XR, built as an entity-component-system.
ThemePaletteRole
The five tonal palettes a Theme holds, one per color family.
@ NeutralVariant
Tinted greys used for outlines and variants.
@ Neutral
Greys used for surfaces and text.
@ ThemePaletteCount
Number of palettes; not a palette.
@ Secondary
Tones of the secondary accent color.
@ Tertiary
Tones of the tertiary accent color.
@ Primary
Tones of the primary accent color.
ThemeSchemeRole
The six color schemes a Theme holds: light and dark, each in standard, medium and high contrast.
@ Dark
Dark scheme, standard contrast.
@ DarkHighContrast
Dark scheme, high contrast.
@ Light
Light scheme, standard contrast.
@ LightMediumContrast
Light scheme, medium contrast.
@ LightHighContrast
Light scheme, high contrast.
@ DarkMediumContrast
Dark scheme, medium contrast.
@ ThemeSchemeCount
Number of schemes; not a scheme.
utility::graphic::Color32Bit getElevatedSurfaceColor(theme::ElevationLevel level)
Get the background color of a surface raised to an elevation level.
const theme::ElevationToken & getElevationToken(theme::ElevationLevel level)
Get the shadow and tint the active theme gives to an elevation level.
const Theme & getActiveTheme(void)
Get the theme every widget and system reads its tokens from.
std::uint8_t getStateLayerAlpha(theme::StateLayer layer)
Get the opacity the active theme gives to a state layer, as an alpha channel value.
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...
SchemeColorRole
The named colors of a scheme: what a color is used for, not what it looks like.
@ SurfaceDisabled
Disabled container (onSurface at 12%).
@ OnSurfaceDisabled
Disabled content (onSurface at 38%).
@ Count
Number of roles; not a role.
@ Backdrop
Modal backdrop behind dialogs and drawers.
float getMotionDuration(theme::MotionDuration duration)
Get the length the active theme gives to a duration token.
void setActiveScheme(ThemeSchemeRole role)
Choose which of the six schemes of the active theme is in use, for instance to switch between light a...
const theme::Typescale & getActiveTypescale(void)
Get the text styles of the active theme.
const Theme defaultTheme
The theme of the library: Material Design 3 baseline colors (six schemes, five palettes) and scales.
void setActiveTheme(const Theme &theme)
Replace the active theme by a copy of another theme.
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.
const Scheme & getActiveScheme(void)
Get the color scheme in use: the scheme of the active theme selected by setActiveScheme().
What one elevation level looks like: how much the surface is tinted and how large and dark its shadow...
One text style: everything needed to measure and draw a piece of text.