1.10
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Theme Class Reference

Customizable characteristics for drawing widgets. More...

#include <theme.h>

Inheritance diagram for Theme:
Inheritance graph
[legend]

Public Types

enum class  BorderFlag : uint32_t {
  top = detail::bit(0) , right = detail::bit(1) , bottom = detail::bit(2) , left = detail::bit(3) ,
  drop_shadow = detail::bit(4)
}
 Border flags allow, when drawing a rectangle, control over what sides of the rectangle are drawn. More...
 
using BorderFlags = Flags< BorderFlag >
 Border flags.
 
enum class  FillFlag : uint32_t { solid = detail::bit(0) , blend = detail::bit(1) }
 Fill flags are used to characterize how a widget's background and border should be drawn. More...
 
using FillFlags = Flags< FillFlag >
 Fill flags.
 

Public Member Functions

 Theme ()
 
 Theme (const Theme &)=default
 
 Theme (Theme &&) noexcept=default
 
virtual ~Theme () noexcept=default
 
virtual void apply ()
 Apply the Theme.
 
virtual DefaultDim default_border () const
 Get the default border width.
 
virtual float default_border_radius () const
 Get the default border radius.
 
virtual void draw_box (Painter &painter, const FillFlags &type, const Rect &rect, const Pattern &border, const Pattern &bg, DefaultDim border_width=0, DefaultDim margin_width=0, float border_radius=0.0, const BorderFlags &border_flags={}, Image *background=nullptr) const
 Draw a box specifying the properties directly.
 
virtual void draw_box (Painter &painter, const Widget &widget, Palette::ColorId bg, Palette::ColorId border) const
 Draw a box using properties directly from the widget.
 
virtual void draw_circle (Painter &painter, const FillFlags &type, const Rect &rect, const Pattern &border, const Pattern &bg, DefaultDim border_width=0, DefaultDim margin_width=0) const
 Draw a circle specifying the properties directly.
 
virtual void draw_circle (Painter &painter, const Widget &widget, Palette::ColorId bg, Palette::ColorId border) const
 Draw a circle using properties directly from the widget.
 
Fontfont ()
 Get a reference to the theme Font.
 
const Fontfont () const
 Get a const reference to the theme Font.
 
void font (const Font &font)
 Set the theme Font.
 
EGT_NODISCARD const std::string & name () const
 Get the name of the Object.
 
void name (const std::string &name)
 Set the name of the Object.
 
Themeoperator= (const Theme &)=default
 
Themeoperator= (Theme &&) noexcept=default
 
Palettepalette ()
 Get a reference to the theme Palette.
 
const Palettepalette () const
 Get a const reference to the theme Palette.
 
void palette (const Palette &palette)
 Set the theme palette.
 

Protected Member Functions

 Theme (const std::string &name)
 
virtual void init_draw ()
 Setup for initializing drawing.
 
virtual void init_font ()
 Setup for initializing the font.
 
virtual void init_palette ()
 Setup for initializing the palette.
 
void rounded_box (Painter &painter, const Rect &box, float border_radius) const
 
virtual void rounded_box (Painter &painter, const RectF &box, float border_radius) const
 

Protected Attributes

Font m_font
 Default font instance used by the theme.
 
std::string m_name
 A user defined name for the Object.
 
Palette m_palette
 Palette instance used by the theme.
 

Detailed Description

Customizable characteristics for drawing widgets.

Theme implements common characteristics of drawing widgets. This can be overloaded and supplied with different properties like Palette and Font to change how a Widget is rendered globally.

Member Typedef Documentation

◆ BorderFlags

Border flags.

◆ FillFlags

Fill flags.

Member Enumeration Documentation

◆ BorderFlag

enum class BorderFlag : uint32_t
strong

Border flags allow, when drawing a rectangle, control over what sides of the rectangle are drawn.

If no flags are specified, the default assumption is that all flags are drawn. The drop_shadow flag prevails over other flags. If it is set, top, right, bottom, and left flags are ignored.

Enumerator
top 
right 
bottom 
left 
drop_shadow 

◆ FillFlag

enum class FillFlag : uint32_t
strong

Fill flags are used to characterize how a widget's background and border should be drawn.

This is an optimization to control whether a solid fill is done, it's blended, or if nothing is set - nothing will be drawn.

Enumerator
solid 

Overwrite and don't blend.

Note
This is the same as CAIRO_OPERATOR_SOURCE.
blend 

perform a blend

Constructor & Destructor Documentation

◆ Theme() [1/4]

Theme ( )

◆ Theme() [2/4]

Theme ( const Theme )
default

◆ Theme() [3/4]

Theme ( Theme &&  )
defaultnoexcept

◆ ~Theme()

virtual ~Theme ( )
virtualdefaultnoexcept

◆ Theme() [4/4]

Theme ( const std::string &  name)
explicitprotected

Member Function Documentation

◆ apply()

virtual void apply ( )
inlinevirtual

Apply the Theme.

Automatically called by global_theme() when setting a new theme.

◆ default_border()

virtual DefaultDim default_border ( ) const
inlinevirtual

Get the default border width.

◆ default_border_radius()

virtual float default_border_radius ( ) const
inlinevirtual

Get the default border radius.

◆ draw_box() [1/2]

virtual void draw_box ( Painter painter,
const FillFlags type,
const Rect rect,
const Pattern border,
const Pattern bg,
DefaultDim  border_width = 0,
DefaultDim  margin_width = 0,
float  border_radius = 0.0,
const BorderFlags border_flags = {},
Image background = nullptr 
) const
virtual

Draw a box specifying the properties directly.

◆ draw_box() [2/2]

virtual void draw_box ( Painter painter,
const Widget widget,
Palette::ColorId  bg,
Palette::ColorId  border 
) const
virtual

Draw a box using properties directly from the widget.

◆ draw_circle() [1/2]

virtual void draw_circle ( Painter painter,
const FillFlags type,
const Rect rect,
const Pattern border,
const Pattern bg,
DefaultDim  border_width = 0,
DefaultDim  margin_width = 0 
) const
virtual

Draw a circle specifying the properties directly.

◆ draw_circle() [2/2]

virtual void draw_circle ( Painter painter,
const Widget widget,
Palette::ColorId  bg,
Palette::ColorId  border 
) const
virtual

Draw a circle using properties directly from the widget.

◆ font() [1/3]

Font & font ( )
inline

Get a reference to the theme Font.

◆ font() [2/3]

const Font & font ( ) const
inline

Get a const reference to the theme Font.

◆ font() [3/3]

void font ( const Font font)
inline

Set the theme Font.

◆ init_draw()

virtual void init_draw ( )
protectedvirtual

Setup for initializing drawing.

Called by apply().

Reimplemented in ShamrockTheme, and SkyTheme.

◆ init_font()

virtual void init_font ( )
protectedvirtual

Setup for initializing the font.

Called by apply().

Reimplemented in CoconutTheme, and ShamrockTheme.

◆ init_palette()

virtual void init_palette ( )
protectedvirtual

Setup for initializing the palette.

Called by apply().

Reimplemented in CoconutTheme, LapisTheme, MidnightTheme, ShamrockTheme, SkyTheme, and UltraVioletTheme.

◆ name() [1/2]

EGT_NODISCARD const std::string & name ( ) const
inline

Get the name of the Object.

◆ name() [2/2]

void name ( const std::string &  name)
inline

Set the name of the Object.

Assigns a human readable name to an Object that can then be used to find timers by name or debug.

Parameters
[in]nameName to set for the Object.

◆ operator=() [1/2]

Theme & operator= ( const Theme )
default

◆ operator=() [2/2]

Theme & operator= ( Theme &&  )
defaultnoexcept

◆ palette() [1/3]

Palette & palette ( )
inline

Get a reference to the theme Palette.

◆ palette() [2/3]

const Palette & palette ( ) const
inline

Get a const reference to the theme Palette.

◆ palette() [3/3]

void palette ( const Palette palette)
inline

Set the theme palette.

◆ rounded_box() [1/2]

void rounded_box ( Painter painter,
const Rect box,
float  border_radius 
) const
inlineprotected

◆ rounded_box() [2/2]

virtual void rounded_box ( Painter painter,
const RectF box,
float  border_radius 
) const
protectedvirtual

Member Data Documentation

◆ m_font

Font m_font
protected

Default font instance used by the theme.

◆ m_name

std::string m_name
protected

A user defined name for the Object.

◆ m_palette

Palette m_palette
protected

Palette instance used by the theme.