1.10
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...

#include <palette.h>

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

Static Public Attributes

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

Protected Attributes

PatternArray m_colors {}
 Patterns in the palette.
 

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 class 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 class 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.