33#include <gtkmm/stylecontext.h>
36using Gtk::IconFactory;
61 , styleAdviceTrackBody_{
"style(trackBody)"}
62 , styleAdviceTrackRuler_{
"style(trackRuler)"}
77 auto screen = Gdk::Screen::get_default();
78 auto css_provider = Gtk::CssProvider::create();
85 catch(Glib::Error
const& failure)
87 WARN (
stage,
"Failure while loading stylesheet '%s': %s",
cStr(stylesheetName),
cStr(failure.what()));
90 Gtk::StyleContext::add_provider_for_screen (screen, css_provider,
91 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
121 GType scopeNode = Gtk::Box::get_type();
122 int pos = path.path_append_type (scopeNode);
124 gtk_widget_path_iter_set_object_name (path.gobj(), pos,
NODE_fork);
127 for (
int i=0; i<pos; ++i)
128 gtk_widget_path_iter_set_state(path.gobj(), i, GTK_STATE_FLAG_NORMAL);
130 style->set_screen(Gdk::Screen::get_default());
131 style->set_path (path);
134 pos = path.path_append_type (scopeNode);
135 gtk_widget_path_iter_set_object_name (path.gobj(), pos,
NODE_frame);
138 style = Gtk::StyleContext::create();
139 style->set_path (path);
146 Cairo::RefPtr<Cairo::SolidPattern>
148 ,
const gchar * property_name
149 ,guint16 red, guint16 green, guint16 blue)
151 REQUIRE (property_name);
156 gtk_widget_style_get(widget.gobj(), property_name, &color,
NULL);
158 Cairo::RefPtr<Cairo::SolidPattern> pattern;
162 pattern = Cairo::SolidPattern::create_rgb ( (
double)color->red / 0xFFFF,
163 (
double)color->green / 0xFFFF,
164 (
double)color->blue / 0xFFFF);
168 WARN (
stage,
"%s style value failed to load", property_name);
170 pattern = Cairo::SolidPattern::create_rgb ( red, green, blue );
194 Glib::RefPtr<IconFactory> factory = Gtk::IconFactory::create();
200 addStockIconSet(factory,
"panel-timeline",
"panel_timeline",
_(
"_Timeline"));
201 addStockIconSet(factory,
"panel-timeline",
"panel_timeline_obsolete",
_(
"_ZombieTimeline"));
213 addStockIconSet(factory,
"track-disabled",
"track_disabled",
_(
"Track Disabled"));
214 addStockIconSet(factory,
"track-enabled",
"track_enabled",
_(
"Track Enabled"));
215 addStockIconSet(factory,
"track-locked",
"track_locked",
_(
"Track Locked"));
216 addStockIconSet(factory,
"track-unlocked",
"track_unlocked",
_(
"Track Unlocked"));
218 factory->add_default();
228 Glib::RefPtr<Gtk::IconSet> icon_set = Gtk::IconSet::create();
229 cuString uIconName{iconName}, uLabel{label};
235 found |=
addStockIcon (icon_set, uIconName, Gtk::ICON_SIZE_BUTTON, not found);
236 found |=
addStockIcon (icon_set, uIconName, Gtk::ICON_SIZE_MENU, not found);
237 found |=
addStockIcon (icon_set, uIconName, Gtk::ICON_SIZE_LARGE_TOOLBAR, not found);
243 ERROR (
stage,
"Unable to load icon '%s'", iconName);
248 const Gtk::StockID stock_id(
id);
249 factory->add(stock_id, icon_set);
250 Gtk::Stock::add(Gtk::StockItem(stock_id, uLabel));
267 for (
auto const& location : iconLocations)
286 int width = 0, height = 0;
287 if(!IconSize::lookup(size, width, height))
292 Glib::RefPtr<Gtk::IconTheme> theme = Gtk::IconTheme::get_default();
296 Gtk::IconInfo info = theme->lookup_icon(icon_name, width, (Gtk::IconLookupFlags)0);
298 if (!info)
return false;
313 int width = 0, height = 0;
314 if(!IconSize::lookup(size, width, height))
319 cuString path(Glib::ustring::compose(
"%1/%2x%3/%4.png",
320 base_dir, width, height, icon_name));
327 ,Glib::RefPtr<Gtk::IconSet>
const& icon_set
331 if (not fs::exists (path))
return false;
334 Gtk::IconSource source;
335 source.set_pixbuf(Gdk::Pixbuf::create_from_file(path));
336 source.set_size_wildcarded(wildcard);
337 source.set_size(size);
339 icon_set->add_source(source);
344 catch(Glib::Exception
const& ex)
346 WARN (
stage,
"Failure when accessing icon '%s'. Problem: %s",
cStr(path),
cStr(ex.what()));
Helper: Access a path Specification as a sequence of filesystem Paths.
C++ wrapper for convenient access to the Lumiera config system.
static string get(lib::Literal key)
void setAdvice(AD const &pieceOfAdvice)
StyleAdvice styleAdviceTrackRuler_
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.
static Gtk::IconSize GiantIconSize
The registered icon size for giant 48x48 px icons.
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.
StyleAdvice styleAdviceTrackBody_
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.
string resourceSerachPath_
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.
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.
UiStyle()
Set up a coherent theming and styling for the application.
void prepareStyleContext(timeline::TimelineWidget const &)
Use the existing TimelineWidget's GTK-WidgetPath to establish a systematic CSS styling context,...
void registerAppIconSizes()
void registerStockItems()
Registers application stock items: icons and labels associated with IDs.
static Gtk::IconSize MenuIconSize
The registered icon size for giant 16x16 px icons.
void setTheme(string const &stylesheetName)
Sets the theme to use for the Lumiera GUI.
bool addStockIconSet(Glib::RefPtr< Gtk::IconFactory > const &factory, Literal iconName, Literal id, Literal label)
Adds an icon (in different sizes) to the icon factory.
Definition of access keys for global UI configuration.
Includes the C++ Filesystem library and provides some convenience helpers.
string resolveModulePath(fs::path moduleName, string searchPath)
helper to establish the location to search for loadable modules, configuration files,...
Lumiera GTK UI implementation root.
Literal ICON_arrow_hand_up
Glib::RefPtr< Gtk::StyleContext > PStyleContext
Literal ICON_arrow_hand_menu
cuString CLASS_timeline_fork
Literal ICON_arrow_hand_down
cuString CLASS_timeline_ruler
Helpers to handle directory search paths.
Definition of access keys for uniform UI styling.
CStr cStr(std::string const &rendered)
convenience shortcut: forced conversion to c-String via string.
Service for global theming and style related concerns.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...