Lumiera  0.pre.03
»edit your freedom«
UiStyle Class Reference

#include "stage/workspace/ui-style.hpp"

Description

Manage global concerns regarding a coherent user interface.

Offers access to some global UI resources, and establishes further global services to create workspace windows, to bind menu / command actions and to enter the top-level model parts.

Definition at line 72 of file ui-style.hpp.

Public Member Functions

 UiStyle ()
 Set up a coherent theming and styling for the application. More...
 
void prepareStyleContext (timeline::TimelineWidget const &)
 Use the existing TimelineWidget's GTK-WidgetPath to establish a systematic CSS styling context, which can be used for theming and styling of Lumiera's custom UI elements within the timeline display. More...
 
void setTheme (string const &stylesheetName)
 Sets the theme to use for the Lumiera GUI. More...
 

Static Public Member Functions

static Cairo::RefPtr< Cairo::SolidPattern > readStyleColourProperty (Gtk::Widget &widget, const gchar *property_name, guint16 red, guint16 green, guint16 blue)
 A utility function which reads a colour style from the GTK Style. More...
 

Static Public Attributes

static Gtk::IconSize GiantIconSize = Gtk::ICON_SIZE_INVALID
 The registered icon size for giant 48x48 px icons. More...
 
static Gtk::IconSize MenuIconSize = Gtk::ICON_SIZE_INVALID
 The registered icon size for giant 16x16 px icons. More...
 

Private Member Functions

bool addNonThemeIconSource (Glib::RefPtr< Gtk::IconSet > const &icon_set, cuString &base_dir, cuString &icon_name, Gtk::IconSize size, bool wildcard)
 Loads an icon from a non theme set. More...
 
bool addStockIcon (Glib::RefPtr< Gtk::IconSet > const &icon_set, cuString &icon_name, Gtk::IconSize size, bool wildcard)
 Loads an icon, searching standard icon locations, and adds it to an icon set. More...
 
bool addStockIconFromPath (string path, Glib::RefPtr< Gtk::IconSet > const &icon_set, Gtk::IconSize size, bool wildcard)
 Loads an icon from a specific path and adds it to an icon set. More...
 
bool addStockIconSet (Glib::RefPtr< Gtk::IconFactory > const &factory, Literal iconName, Literal id, Literal label)
 Adds an icon (in different sizes) to the icon factory. More...
 
bool addThemeIconSource (Glib::RefPtr< Gtk::IconSet > const &icon_set, cuString &icon_name, Gtk::IconSize size, bool wildcard)
 Loads an icon from a the icon theme. More...
 
void registerAppIconSizes ()
 
void registerStockItems ()
 Registers application stock items: icons and labels associated with IDs.
 
- Private Member Functions inherited from NonCopyable
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Private Attributes

string iconSearchPath_
 
string resourceSerachPath_
 
StyleAdvice styleAdviceTrackBody_
 
StyleAdvice styleAdviceTrackRuler_
 

Constructor & Destructor Documentation

◆ UiStyle()

UiStyle ( )

Set up a coherent theming and styling for the application.

Based on the Gtk::UIManager, the UiStyle service allows to access some style related resources, but mostly its task is to configure the GTK toolkit appropriately during startup.

Initialise the theme and style related global properties of the UI. Register the icon configuration and sizes and lookup all standard icons – either from the default theme of via the given Lumiera icon search paths, typically from setup.ini.

See also
lumiera::Config

Definition at line 68 of file ui-style.cpp.

References Config::get(), UiStyle::registerStockItems(), and UiStyle::setTheme().

+ Here is the call graph for this function:

Member Function Documentation

◆ setTheme()

void setTheme ( string const &  stylesheetName)

Sets the theme to use for the Lumiera GUI.

Parameters
stylesheetNameGTK CSS stylesheet to load from the resourceSearchPath_
Exceptions
error::Configif this stylesheet can't be resolved on the searchpath
See also
lumiera::Config

Definition at line 86 of file ui-style.cpp.

References cStr(), and lib::resolveModulePath().

Referenced by UiStyle::UiStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareStyleContext()

void prepareStyleContext ( timeline::TimelineWidget const &  timeline)

Use the existing TimelineWidget's GTK-WidgetPath to establish a systematic CSS styling context, which can be used for theming and styling of Lumiera's custom UI elements within the timeline display.

Especially, this allows us to anchor those custom elements at a dedicated point in the hierarchy, the way it is visible for CSS selectors. Thus, either standard CSS rules and inheritance take effect on our custom elements, or the GTK stylesheet may add dedicated style rules for elements within the timeline display, most notably the system of nested scopes in the track fork and the display of clips and overlays.

Especially the following selector path can be used

  • paned.timeline__page > timeline__body > fork.timeline__fork
Remarks
some implementation notes....
  • GTK defines for each widget a widget path, to describe the path of widget parent relationships down from the top-level window
  • this Gtk::WidgetPath is then used to match against CSS selectors of the GTK stylesheet, either the global system theme, or (with precedence) an application stylesheet (lumiera.css)
  • but the Gtk::StyleContext can (and should) also be used outside of the core GTK framework to carry out custom drawing tasks, which allows custom drawing to "blend in" with the desktop theme.
  • to support this usage, we construct a "virtual widget" and place it at a systematically correct position in the widget hierarchy, causing the corresponding style context to pick up the appropriate standard CSS definitions in effect at that point in the hierarchy. Moreover, users may (and shall) add custom styling rules in a way to match and affect this "virtual" CSS node.
  • the resulting Gtk::StyleContext is constructed only once, at initialisation. It is used from drawing code "deep down" within the TimelineWidget's implementation. The Advice System allows to pass such information without the need of a direct relation between provider and consumer.
  • for technical reference how to manage and populate GTK WidgetPath nodes, see the implementation of the C-function gtk_widget_path_append_for_widget() in in GTK 3.x, gtkwidget.c, line 16413

Definition at line 126 of file ui-style.cpp.

◆ readStyleColourProperty()

Cairo::RefPtr< Cairo::SolidPattern > readStyleColourProperty ( Gtk::Widget &  widget,
const gchar *  property_name,
guint16  red,
guint16  green,
guint16  blue 
)
static

A utility function which reads a colour style from the GTK Style.

Parameters
widgetThe widget to load the style out of.
property_nameThe name of the style property to load.
redThe fallback red intensity.
greenThe fallback green intensity.
blueThe fallback blue intensity.
Returns
The loaded colour.

Definition at line 158 of file ui-style.cpp.

◆ addStockIconSet()

bool addStockIconSet ( Glib::RefPtr< Gtk::IconFactory > const &  factory,
Literal  iconName,
Literal  id,
Literal  label 
)
private

Adds an icon (in different sizes) to the icon factory.

Parameters
factoryThe factory to add the icon to.
icon_nameThe file name of the icon to add.
idThe id name of the icon.
labelThe user readable icon name for this icon.
Returns
true if the icon was successfully loaded, returns false otherwise.

Definition at line 233 of file ui-style.cpp.

References UiStyle::addStockIcon(), UiStyle::GiantIconSize, and UiStyle::MenuIconSize.

Referenced by UiStyle::registerStockItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addStockIcon()

bool addStockIcon ( Glib::RefPtr< Gtk::IconSet > const &  icon_set,
cuString &  icon_name,
Gtk::IconSize  size,
bool  wildcard 
)
private

Loads an icon, searching standard icon locations, and adds it to an icon set.

Parameters
icon_setThe icon set to add the icon to.
icon_nameThe file name of the icon to load.
sizeThe size of the icon to load.
wildcardtrue if this icon is to be wildcarded.
Returns
true if the icon was loaded successfully.

Definition at line 266 of file ui-style.cpp.

References UiStyle::addNonThemeIconSource(), and UiStyle::addThemeIconSource().

Referenced by UiStyle::addStockIconSet().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addThemeIconSource()

bool addThemeIconSource ( Glib::RefPtr< Gtk::IconSet > const &  icon_set,
cuString &  icon_name,
Gtk::IconSize  size,
bool  wildcard 
)
private

Loads an icon from a the icon theme.

Parameters
icon_setThe icon set to add the icon to.
icon_nameThe name of the icon to load.
sizeThe size of the icon to load.
wildcardtrue if this icon is to be wildcarded.
Returns
true if the icon was loaded successfully.

Definition at line 290 of file ui-style.cpp.

References UiStyle::addStockIconFromPath().

Referenced by UiStyle::addStockIcon().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addNonThemeIconSource()

bool addNonThemeIconSource ( Glib::RefPtr< Gtk::IconSet > const &  icon_set,
cuString &  base_dir,
cuString &  icon_name,
Gtk::IconSize  size,
bool  wildcard 
)
private

Loads an icon from a non theme set.

Parameters
icon_setThe icon set to add the icon to.
base_dirThe root icons directory to load from.
icon_nameThe file name of the icon to load.
sizeThe size of the icon to load.
wildcardtrue if this icon is to be wildcarded.
Returns
true if the icon was loaded successfully.

Definition at line 316 of file ui-style.cpp.

References UiStyle::addStockIconFromPath().

Referenced by UiStyle::addStockIcon().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addStockIconFromPath()

bool addStockIconFromPath ( string  path,
Glib::RefPtr< Gtk::IconSet > const &  icon_set,
Gtk::IconSize  size,
bool  wildcard 
)
private

Loads an icon from a specific path and adds it to an icon set.

Parameters
pathThe path to load from.
icon_setThe icon set to add the icon to.
sizeThe size of the icon to load.
wildcardtrue if this icon is to be wildcarded.
Returns
true if the icon was loaded successfully.

Definition at line 336 of file ui-style.cpp.

Referenced by UiStyle::addNonThemeIconSource(), and UiStyle::addThemeIconSource().

+ Here is the caller graph for this function:

Member Data Documentation

◆ GiantIconSize

IconSize GiantIconSize = Gtk::ICON_SIZE_INVALID
static

The registered icon size for giant 48x48 px icons.

Remarks
This value is set to BuiltinIconSize::ICON_SIZE_INVALID until register_giant_icon_size is called.

Definition at line 89 of file ui-style.hpp.

Referenced by UiStyle::addStockIconSet().

◆ MenuIconSize

IconSize MenuIconSize = Gtk::ICON_SIZE_INVALID
static

The registered icon size for giant 16x16 px icons.

Remarks
This value is set to BuiltinIconSize::ICON_SIZE_INVALID until register_app_icon_sizes is called.

Definition at line 95 of file ui-style.hpp.

Referenced by UiStyle::addStockIconSet().

+ Inheritance diagram for UiStyle:
+ Collaboration diagram for UiStyle:

The documentation for this class was generated from the following files: