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

The shades of one color family, from black (tone 0) to white (tone 100). More...

#include <headers/guillaume/theme.hpp>

Public Types

enum class  Tone : std::uint8_t {
  T0 = 0 , T10 = 10 , T20 = 20 , T30 = 30 ,
  T40 = 40 , T50 = 50 , T60 = 60 , T70 = 70 ,
  T80 = 80 , T90 = 90 , T100 = 100
}
 The tones a palette can hold. The number is the lightness: 0 is black, 100 is white. More...

Public Member Functions

 Palette (void)
 Create a palette with no name and no tone.
 Palette (const std::string &name, const std::string &description)
 Create a palette with a name and no tone.
 ~Palette (void)=default
 Default destructor.
const std::string & getName (void) const
 Get the name of the palette.
const std::string & getDescription (void) const
 Get the text describing what the palette is for.
const std::map< Tone, ExtendedColor > & getTones (void) const
 Get every tone defined in the palette.
void setName (const std::string &name)
 Replace the name of the palette.
void setDescription (const std::string &description)
 Replace the text describing what the palette is for.
void setTone (Tone tone, const ExtendedColor &color)
 Define a tone, replacing the color it already has, if any.
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.
bool hasTone (Tone tone) const
 Tell whether a tone is defined.
const ExtendedColor & getTone (Tone tone) const
 Get the color of a tone.
void removeTone (Tone tone)
 Undefine a tone. Does nothing when it is not defined.
void clearTones (void)
 Undefine every tone of the palette.

Detailed Description

The shades of one color family, from black (tone 0) to white (tone 100).

A Theme holds five palettes (ThemePaletteRole). They are reference data: widgets read scheme colors, not tones. A palette starts empty; tones are added with setTone().

See also
Theme::getPalette

Definition at line 363 of file theme.hpp.

Member Enumeration Documentation

◆ Tone

enum class guillaume::Palette::Tone : std::uint8_t
strong

The tones a palette can hold. The number is the lightness: 0 is black, 100 is white.

Enumerator
T0 

Black.

T10 

Lightness 10.

T20 

Lightness 20.

T30 

Lightness 30.

T40 

Lightness 40.

T50 

Lightness 50.

T60 

Lightness 60.

T70 

Lightness 70.

T80 

Lightness 80.

T90 

Lightness 90.

T100 

White.

Definition at line 370 of file theme.hpp.

Constructor & Destructor Documentation

◆ Palette()

guillaume::Palette::Palette ( const std::string & name,
const std::string & description )

Create a palette with a name and no tone.

Parameters
nameThe name of the palette, such as "Neutral".
descriptionWhat the palette is for; may be empty.

Member Function Documentation

◆ getDescription()

const std::string & guillaume::Palette::getDescription ( void ) const

Get the text describing what the palette is for.

Returns
The description; empty when none was given.

◆ getName()

const std::string & guillaume::Palette::getName ( void ) const

Get the name of the palette.

Returns
The name; empty when none was given.

◆ getTone()

const ExtendedColor & guillaume::Palette::getTone ( Tone tone) const

Get the color of a tone.

Parameters
toneThe tone to look up.
Returns
The color of that tone.
Exceptions
std::out_of_rangeWhen the tone is not defined. Check with hasTone() first when unsure.

◆ getTones()

const std::map< Tone, ExtendedColor > & guillaume::Palette::getTones ( void ) const

Get every tone defined in the palette.

Returns
The tones, ordered from the darkest to the lightest; empty when none was set.

◆ hasTone()

bool guillaume::Palette::hasTone ( Tone tone) const

Tell whether a tone is defined.

Parameters
toneThe tone to look for.
Returns
True when setTone() was called for that tone and it was not removed since.

◆ removeTone()

void guillaume::Palette::removeTone ( Tone tone)

Undefine a tone. Does nothing when it is not defined.

Parameters
toneThe tone to remove.

◆ setDescription()

void guillaume::Palette::setDescription ( const std::string & description)

Replace the text describing what the palette is for.

Parameters
descriptionThe new description; may be empty.

◆ setName()

void guillaume::Palette::setName ( const std::string & name)

Replace the name of the palette.

Parameters
nameThe new name.

◆ setTone() [1/2]

void guillaume::Palette::setTone ( Tone tone,
const ExtendedColor & color )

Define a tone, replacing the color it already has, if any.

Parameters
toneThe tone to define.
colorThe color of that tone and its documentation.

◆ setTone() [2/2]

void guillaume::Palette::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.

Parameters
toneThe tone to define.
colorThe color of that tone, 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: