1.1-rc3
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Theme Class Reference

Customizable characteristics for drawing widgets. More...

Inheritance diagram for Theme:
Inheritance graph
[legend]

Public Types

enum  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. More...
 
enum  FillFlag : uint32_t { solid = detail::bit(0), blend = detail::bit(1) }
 Fill flags are used to characterize how a widget's background should be drawn. More...
 
using FillFlags = Flags< FillFlag >
 Fill flags. More...
 

Public Member Functions

 Theme ()
 
 Theme (const Theme &)=default
 
 Theme (Theme &&) noexcept=default
 
virtual ~Theme () noexcept=default
 
virtual void apply ()
 Apply the Theme. More...
 
virtual DefaultDim default_border () const
 Get the default border width. More...
 
virtual float default_border_radius () const
 Get the default border radius. More...
 
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={}) const
 Draw a box specifying the properties directly. More...
 
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. More...
 
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. More...
 
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. More...
 
Fontfont ()
 Get a reference to the theme Font. More...
 
const Fontfont () const
 Get a const reference to the theme Font. More...
 
void font (const Font &font)
 Set the theme Font. More...
 
Themeoperator= (const Theme &)=default
 
Themeoperator= (Theme &&) noexcept=default
 
Palettepalette ()
 Get a reference to the theme Palette. More...
 
const Palettepalette () const
 Get a const reference to the theme Palette. More...
 
void palette (const Palette &palette)
 Set the theme palette. More...
 

Protected Member Functions

virtual void init_draw ()
 Setup for initializing drawing. More...
 
virtual void init_font ()
 Setup for initializing the font. More...
 
virtual void init_palette ()
 Setup for initializing the palette. More...
 
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. More...
 
Palette m_palette
 Palette instance used by the theme. More...
 

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

Enumerator
top 
right 
bottom 
left 
drop_shadow 

◆ FillFlag

enum FillFlag : uint32_t
strong

Fill flags are used to characterize how a widget's background 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/3]

Theme ( )

◆ Theme() [2/3]

Theme ( const Theme )
default

◆ Theme() [3/3]

Theme ( Theme &&  )
defaultnoexcept

◆ ~Theme()

virtual ~Theme ( )
virtualdefaultnoexcept

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 = {} 
) 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 ShamrockTheme, and CoconutTheme.

◆ init_palette()

virtual void init_palette ( )
protectedvirtual

Setup for initializing the palette.

Called by apply().

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

◆ 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_palette

Palette m_palette
protected

Palette instance used by the theme.