1.8
Public Types | Public Member Functions | Protected Attributes | List of all members
Palette Class Reference

Color palette that contains a 2 dimensional array of colors. More...

Public Types

enum class  ColorId {
  bg = 1 , text , text_highlight , cursor ,
  border , button_bg , button_fg , button_text ,
  label_bg , label_text
}
 The Pattern identifier in the Palette. More...
 
enum class  GroupId { normal = 1 , active = 2 , disabled = 3 , checked = 4 }
 Used to define a category of patterns that usually relate to the state of a widget. More...
 
using PatternArray = FixedVector< std::pair< GroupId, FixedVector< std::pair< ColorId, Pattern >, 10 > >, 4 >
 

Public Member Functions

 Palette ()=default
 
constexpr Palette (std::initializer_list< PatternArray::value_type > colors) noexcept
 
void clear ()
 Remove all colors from the Palette. More...
 
void clear (ColorId id, GroupId group=GroupId::normal)
 Remove a color from the Palette. More...
 
EGT_NODISCARD const Patterncolor (ColorId id, GroupId group=GroupId::normal) const
 Get a color. More...
 
void deserialize (const std::string &name, const std::string &value, const Serializer::Attributes &attrs)
 Deserialize. More...
 
EGT_NODISCARD bool empty () const
 Returns true if the palette is empty. More...
 
EGT_NODISCARD bool exists (ColorId id, GroupId group, const Pattern **color) const
 Check if a color exists in the palette and get the color. More...
 
EGT_NODISCARD bool exists (ColorId id, GroupId group=GroupId::normal) const
 Check if a color exists in the palette. More...
 
Paletteoperator= (const PatternArray &colors)
 
void serialize (const std::string &name, Serializer &serializer) const
 Serialize to the specified serializer. More...
 
void set (ColorId id, const Pattern &color, GroupId group=GroupId::normal)
 Set a color in a Palette. More...
 
void set (ColorId id, GroupId group, const Pattern &color)
 Set a color in the Palette. More...
 

Static Public Attributes

constexpr static Color transparent = Color(0x00000000)
 Predefined color. More...
 
constexpr static Color aliceblue = Color::rgb(0xf0f8ff)
 Predefined color. More...
 
constexpr static Color antiquewhite = Color::rgb(0xfaebd7)
 Predefined color. More...
 
constexpr static Color aqua = Color::rgb(0x00ffff)
 Predefined color. More...
 
constexpr static Color aquamarine = Color::rgb(0x7fffd4)
 Predefined color. More...
 
constexpr static Color azure = Color::rgb(0xf0ffff)
 Predefined color. More...
 
constexpr static Color beige = Color::rgb(0xf5f5dc)
 Predefined color. More...
 
constexpr static Color bisque = Color::rgb(0xffe4c4)
 Predefined color. More...
 
constexpr static Color black = Color::rgb(0x000000)
 Predefined color. More...
 
constexpr static Color blanchedalmond = Color::rgb(0xffebcd)
 Predefined color. More...
 
constexpr static Color blue = Color::rgb(0x0000ff)
 Predefined color. More...
 
constexpr static Color blueviolet = Color::rgb(0x8a2be2)
 Predefined color. More...
 
constexpr static Color brown = Color::rgb(0xa52a2a)
 Predefined color. More...
 
constexpr static Color burlywood = Color::rgb(0xdeb887)
 Predefined color. More...
 
constexpr static Color cadetblue = Color::rgb(0x5f9ea0)
 Predefined color. More...
 
constexpr static Color chartreuse = Color::rgb(0x7fff00)
 Predefined color. More...
 
constexpr static Color chocolate = Color::rgb(0xd2691e)
 Predefined color. More...
 
constexpr static Color coral = Color::rgb(0xff7f50)
 Predefined color. More...
 
constexpr static Color cornflowerblue = Color::rgb(0x6495ed)
 Predefined color. More...
 
constexpr static Color cornsilk = Color::rgb(0xfff8dc)
 Predefined color. More...
 
constexpr static Color crimson = Color::rgb(0xdc143c)
 Predefined color. More...
 
constexpr static Color cyan = Color::rgb(0x00ffff)
 Predefined color. More...
 
constexpr static Color darkblue = Color::rgb(0x00008b)
 Predefined color. More...
 
constexpr static Color darkcyan = Color::rgb(0x008b8b)
 Predefined color. More...
 
constexpr static Color darkgoldenrod = Color::rgb(0xb8860b)
 Predefined color. More...
 
constexpr static Color darkgray = Color::rgb(0xa9a9a9)
 Predefined color. More...
 
constexpr static Color darkgreen = Color::rgb(0x006400)
 Predefined color. More...
 
constexpr static Color darkgrey = Color::rgb(0xa9a9a9)
 Predefined color. More...
 
constexpr static Color darkkhaki = Color::rgb(0xbdb76b)
 Predefined color. More...
 
constexpr static Color darkmagenta = Color::rgb(0x8b008b)
 Predefined color. More...
 
constexpr static Color darkolivegreen = Color::rgb(0x556b2f)
 Predefined color. More...
 
constexpr static Color darkorange = Color::rgb(0xff8c00)
 Predefined color. More...
 
constexpr static Color darkorchid = Color::rgb(0x9932cc)
 Predefined color. More...
 
constexpr static Color darkred = Color::rgb(0x8b0000)
 Predefined color. More...
 
constexpr static Color darksalmon = Color::rgb(0xe9967a)
 Predefined color. More...
 
constexpr static Color darkseagreen = Color::rgb(0x8fbc8f)
 Predefined color. More...
 
constexpr static Color darkslateblue = Color::rgb(0x483d8b)
 Predefined color. More...
 
constexpr static Color darkslategray = Color::rgb(0x2f4f4f)
 Predefined color. More...
 
constexpr static Color darkslategrey = Color::rgb(0x2f4f4f)
 Predefined color. More...
 
constexpr static Color darkturquoise = Color::rgb(0x00ced1)
 Predefined color. More...
 
constexpr static Color darkviolet = Color::rgb(0x9400d3)
 Predefined color. More...
 
constexpr static Color deeppink = Color::rgb(0xff1493)
 Predefined color. More...
 
constexpr static Color deepskyblue = Color::rgb(0x00bfff)
 Predefined color. More...
 
constexpr static Color dimgray = Color::rgb(0x696969)
 Predefined color. More...
 
constexpr static Color dimgrey = Color::rgb(0x696969)
 Predefined color. More...
 
constexpr static Color dodgerblue = Color::rgb(0x1e90ff)
 Predefined color. More...
 
constexpr static Color firebrick = Color::rgb(0xb22222)
 Predefined color. More...
 
constexpr static Color floralwhite = Color::rgb(0xfffaf0)
 Predefined color. More...
 
constexpr static Color forestgreen = Color::rgb(0x228b22)
 Predefined color. More...
 
constexpr static Color fuchsia = Color::rgb(0xff00ff)
 Predefined color. More...
 
constexpr static Color gainsboro = Color::rgb(0xdcdcdc)
 Predefined color. More...
 
constexpr static Color ghostwhite = Color::rgb(0xf8f8ff)
 Predefined color. More...
 
constexpr static Color gold = Color::rgb(0xffd700)
 Predefined color. More...
 
constexpr static Color goldenrod = Color::rgb(0xdaa520)
 Predefined color. More...
 
constexpr static Color gray = Color::rgb(0x808080)
 Predefined color. More...
 
constexpr static Color green = Color::rgb(0x008000)
 Predefined color. More...
 
constexpr static Color greenyellow = Color::rgb(0xadff2f)
 Predefined color. More...
 
constexpr static Color grey = Color::rgb(0x808080)
 Predefined color. More...
 
constexpr static Color honeydew = Color::rgb(0xf0fff0)
 Predefined color. More...
 
constexpr static Color hotpink = Color::rgb(0xff69b4)
 Predefined color. More...
 
constexpr static Color indianred = Color::rgb(0xcd5c5c)
 Predefined color. More...
 
constexpr static Color indigo = Color::rgb(0x4b0082)
 Predefined color. More...
 
constexpr static Color ivory = Color::rgb(0xfffff0)
 Predefined color. More...
 
constexpr static Color khaki = Color::rgb(0xf0e68c)
 Predefined color. More...
 
constexpr static Color lavender = Color::rgb(0xe6e6fa)
 Predefined color. More...
 
constexpr static Color lavenderblush = Color::rgb(0xfff0f5)
 Predefined color. More...
 
constexpr static Color lawngreen = Color::rgb(0x7cfc00)
 Predefined color. More...
 
constexpr static Color lemonchiffon = Color::rgb(0xfffacd)
 Predefined color. More...
 
constexpr static Color lightblue = Color::rgb(0xadd8e6)
 Predefined color. More...
 
constexpr static Color lightcoral = Color::rgb(0xf08080)
 Predefined color. More...
 
constexpr static Color lightcyan = Color::rgb(0xe0ffff)
 Predefined color. More...
 
constexpr static Color lightgoldenrodyellow = Color::rgb(0xfafad2)
 Predefined color. More...
 
constexpr static Color lightgray = Color::rgb(0xd3d3d3)
 Predefined color. More...
 
constexpr static Color lightgreen = Color::rgb(0x90ee90)
 Predefined color. More...
 
constexpr static Color lightgrey = Color::rgb(0xd3d3d3)
 Predefined color. More...
 
constexpr static Color lightpink = Color::rgb(0xffb6c1)
 Predefined color. More...
 
constexpr static Color lightsalmon = Color::rgb(0xffa07a)
 Predefined color. More...
 
constexpr static Color lightseagreen = Color::rgb(0x20b2aa)
 Predefined color. More...
 
constexpr static Color lightskyblue = Color::rgb(0x87cefa)
 Predefined color. More...
 
constexpr static Color lightslategray = Color::rgb(0x778899)
 Predefined color. More...
 
constexpr static Color lightslategrey = Color::rgb(0x778899)
 Predefined color. More...
 
constexpr static Color lightsteelblue = Color::rgb(0xb0c4de)
 Predefined color. More...
 
constexpr static Color lightyellow = Color::rgb(0xffffe0)
 Predefined color. More...
 
constexpr static Color lime = Color::rgb(0x00ff00)
 Predefined color. More...
 
constexpr static Color limegreen = Color::rgb(0x32cd32)
 Predefined color. More...
 
constexpr static Color linen = Color::rgb(0xfaf0e6)
 Predefined color. More...
 
constexpr static Color magenta = Color::rgb(0xff00ff)
 Predefined color. More...
 
constexpr static Color maroon = Color::rgb(0x800000)
 Predefined color. More...
 
constexpr static Color mediumaquamarine = Color::rgb(0x66cdaa)
 Predefined color. More...
 
constexpr static Color mediumblue = Color::rgb(0x0000cd)
 Predefined color. More...
 
constexpr static Color mediumorchid = Color::rgb(0xba55d3)
 Predefined color. More...
 
constexpr static Color mediumpurple = Color::rgb(0x9370db)
 Predefined color. More...
 
constexpr static Color mediumseagreen = Color::rgb(0x3cb371)
 Predefined color. More...
 
constexpr static Color mediumslateblue = Color::rgb(0x7b68ee)
 Predefined color. More...
 
constexpr static Color mediumspringgreen = Color::rgb(0x00fa9a)
 Predefined color. More...
 
constexpr static Color mediumturquoise = Color::rgb(0x48d1cc)
 Predefined color. More...
 
constexpr static Color mediumvioletred = Color::rgb(0xc71585)
 Predefined color. More...
 
constexpr static Color midnightblue = Color::rgb(0x191970)
 Predefined color. More...
 
constexpr static Color mintcream = Color::rgb(0xf5fffa)
 Predefined color. More...
 
constexpr static Color mistyrose = Color::rgb(0xffe4e1)
 Predefined color. More...
 
constexpr static Color moccasin = Color::rgb(0xffe4b5)
 Predefined color. More...
 
constexpr static Color navajowhite = Color::rgb(0xffdead)
 Predefined color. More...
 
constexpr static Color navy = Color::rgb(0x000080)
 Predefined color. More...
 
constexpr static Color oldlace = Color::rgb(0xfdf5e6)
 Predefined color. More...
 
constexpr static Color olive = Color::rgb(0x808000)
 Predefined color. More...
 
constexpr static Color olivedrab = Color::rgb(0x6b8e23)
 Predefined color. More...
 
constexpr static Color orange = Color::rgb(0xffa500)
 Predefined color. More...
 
constexpr static Color orangered = Color::rgb(0xff4500)
 Predefined color. More...
 
constexpr static Color orchid = Color::rgb(0xda70d6)
 Predefined color. More...
 
constexpr static Color palegoldenrod = Color::rgb(0xeee8aa)
 Predefined color. More...
 
constexpr static Color palegreen = Color::rgb(0x98fb98)
 Predefined color. More...
 
constexpr static Color paleturquoise = Color::rgb(0xafeeee)
 Predefined color. More...
 
constexpr static Color palevioletred = Color::rgb(0xdb7093)
 Predefined color. More...
 
constexpr static Color papayawhip = Color::rgb(0xffefd5)
 Predefined color. More...
 
constexpr static Color peachpuff = Color::rgb(0xffdab9)
 Predefined color. More...
 
constexpr static Color peru = Color::rgb(0xcd853f)
 Predefined color. More...
 
constexpr static Color pink = Color::rgb(0xffc0cb)
 Predefined color. More...
 
constexpr static Color plum = Color::rgb(0xdda0dd)
 Predefined color. More...
 
constexpr static Color powderblue = Color::rgb(0xb0e0e6)
 Predefined color. More...
 
constexpr static Color purple = Color::rgb(0x800080)
 Predefined color. More...
 
constexpr static Color red = Color::rgb(0xff0000)
 Predefined color. More...
 
constexpr static Color rosybrown = Color::rgb(0xbc8f8f)
 Predefined color. More...
 
constexpr static Color royalblue = Color::rgb(0x4169e1)
 Predefined color. More...
 
constexpr static Color saddlebrown = Color::rgb(0x8b4513)
 Predefined color. More...
 
constexpr static Color salmon = Color::rgb(0xfa8072)
 Predefined color. More...
 
constexpr static Color sandybrown = Color::rgb(0xf4a460)
 Predefined color. More...
 
constexpr static Color seagreen = Color::rgb(0x2e8b57)
 Predefined color. More...
 
constexpr static Color seashell = Color::rgb(0xfff5ee)
 Predefined color. More...
 
constexpr static Color sienna = Color::rgb(0xa0522d)
 Predefined color. More...
 
constexpr static Color silver = Color::rgb(0xc0c0c0)
 Predefined color. More...
 
constexpr static Color skyblue = Color::rgb(0x87ceeb)
 Predefined color. More...
 
constexpr static Color slateblue = Color::rgb(0x6a5acd)
 Predefined color. More...
 
constexpr static Color slategray = Color::rgb(0x708090)
 Predefined color. More...
 
constexpr static Color slategrey = Color::rgb(0x708090)
 Predefined color. More...
 
constexpr static Color snow = Color::rgb(0xfffafa)
 Predefined color. More...
 
constexpr static Color springgreen = Color::rgb(0x00ff7f)
 Predefined color. More...
 
constexpr static Color steelblue = Color::rgb(0x4682b4)
 Predefined color. More...
 
constexpr static Color tan = Color::rgb(0xd2b48c)
 Predefined color. More...
 
constexpr static Color teal = Color::rgb(0x008080)
 Predefined color. More...
 
constexpr static Color thistle = Color::rgb(0xd8bfd8)
 Predefined color. More...
 
constexpr static Color tomato = Color::rgb(0xff6347)
 Predefined color. More...
 
constexpr static Color turquoise = Color::rgb(0x40e0d0)
 Predefined color. More...
 
constexpr static Color violet = Color::rgb(0xee82ee)
 Predefined color. More...
 
constexpr static Color wheat = Color::rgb(0xf5deb3)
 Predefined color. More...
 
constexpr static Color white = Color::rgb(0xffffff)
 Predefined color. More...
 
constexpr static Color whitesmoke = Color::rgb(0xf5f5f5)
 Predefined color. More...
 
constexpr static Color yellow = Color::rgb(0xffff00)
 Predefined color. More...
 
constexpr static Color yellowgreen = Color::rgb(0x9acd32)
 Predefined color. More...
 

Protected Attributes

PatternArray m_colors {}
 Patterns in the palette. More...
 

Detailed Description

Color palette that contains a 2 dimensional array of colors.

The Palette defines a bank of colors, or complex patterns, used by the Theme, and ultimately widgets.

The palette manages a 2 dimensional array. The first dimension is the ColorId. The second dimension is the GroupId, which supports the capability for a ColorId to change based on the state of a Widget.

Member Typedef Documentation

◆ PatternArray

using PatternArray = FixedVector<std::pair<GroupId, FixedVector<std::pair<ColorId, Pattern>, 10> >, 4>

Member Enumeration Documentation

◆ ColorId

enum ColorId
strong

The Pattern identifier in the Palette.

See also
GroupId
Enumerator
bg 

General (Window, Frame) background color.

text 

Control (TextBox) text color.

text_highlight 

TextBox highlight color.

cursor 

TextBox cursor color.

border 

Border color.

button_bg 

Button background color.

button_fg 

Button foreground color.

button_text 

Button text color.

label_bg 

Label background color.

label_text 

Label text color.

◆ GroupId

enum GroupId
strong

Used to define a category of patterns that usually relate to the state of a widget.

This allows the Palette to contain patterns like a background color, that can be different based on the state of the widget.

See also
ColorId
Enumerator
normal 

Default color group associated with a normal Widget state.

active 

Color group usually associated with the Widget::Flag::active flag.

disabled 

Color group usually associated with the Widget::Flag::disabled flag.

checked 

Checked state associated with buttons.

Constructor & Destructor Documentation

◆ Palette() [1/2]

Palette ( )
default

◆ Palette() [2/2]

constexpr Palette ( std::initializer_list< PatternArray::value_type colors)
inlineexplicitconstexprnoexcept

Member Function Documentation

◆ clear() [1/2]

void clear ( )

Remove all colors from the Palette.

◆ clear() [2/2]

void clear ( ColorId  id,
GroupId  group = GroupId::normal 
)

Remove a color from the Palette.

Parameters
idColor id.
groupColor group.

◆ color()

EGT_NODISCARD const Pattern& color ( ColorId  id,
GroupId  group = GroupId::normal 
) const

Get a color.

Parameters
idColor id.
groupColor group.
Returns
The color or pattern.

◆ deserialize()

void deserialize ( const std::string &  name,
const std::string &  value,
const Serializer::Attributes attrs 
)

Deserialize.

◆ empty()

EGT_NODISCARD bool empty ( ) const
inline

Returns true if the palette is empty.

◆ exists() [1/2]

EGT_NODISCARD bool exists ( ColorId  id,
GroupId  group,
const Pattern **  color 
) const

Check if a color exists in the palette and get the color.

Parameters
idColor id.
groupColor group.
colorThe color if found.
Returns
True if exists.

◆ exists() [2/2]

EGT_NODISCARD bool exists ( ColorId  id,
GroupId  group = GroupId::normal 
) const

Check if a color exists in the palette.

Parameters
idColor id.
groupColor group.
Returns
True if exists.

◆ operator=()

Palette& operator= ( const PatternArray colors)

◆ serialize()

void serialize ( const std::string &  name,
Serializer serializer 
) const

Serialize to the specified serializer.

◆ set() [1/2]

void set ( ColorId  id,
const Pattern color,
GroupId  group = GroupId::normal 
)

Set a color in a Palette.

Parameters
idColor id.
colorThe color or pattern.
groupColor group.
Returns
Reference to the Palette instance.

◆ set() [2/2]

void set ( ColorId  id,
GroupId  group,
const Pattern color 
)

Set a color in the Palette.

Parameters
idColor id.
groupColor group.
colorThe color or pattern.
Returns
Reference to the Palette instance.

Member Data Documentation

◆ m_colors

PatternArray m_colors {}
protected

Patterns in the palette.