X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fui_config.cc;h=cc8a737cd9434d75d28ee963b88f00fd8c370acc;hb=45d487f16e8be102bfcdefcd950a69c886495b94;hp=e1aba7d524259cb285982ed0ae25a0a9df6a79f7;hpb=a5aa2df6fc42e8c780832cdd92c8bcb6386a2871;p=ardour.git diff --git a/gtk2_ardour/ui_config.cc b/gtk2_ardour/ui_config.cc index e1aba7d524..cc8a737cd9 100644 --- a/gtk2_ardour/ui_config.cc +++ b/gtk2_ardour/ui_config.cc @@ -17,19 +17,31 @@ */ +#if !defined USE_CAIRO_IMAGE_SURFACE && !defined NDEBUG +#define OPTIONAL_CAIRO_IMAGE_SURFACE +#endif + #include #include #include #include #include /* for snprintf, grrr */ +#include + +#include // for fontmap resolution control for GnomeCanvas +#include // for fontmap resolution control for GnomeCanvas + #include #include +#include + #include "pbd/convert.h" #include "pbd/failed_constructor.h" #include "pbd/xml++.h" #include "pbd/file_utils.h" +#include "pbd/locale_guard.h" #include "pbd/error.h" #include "pbd/stacktrace.h" @@ -37,9 +49,8 @@ #include "gtkmm2ext/gtk_ui.h" #include "ardour/filesystem_paths.h" +#include "ardour/utils.h" -#include "ardour_ui.h" -#include "global_signals.h" #include "ui_config.h" #include "i18n.h" @@ -55,6 +66,10 @@ UIConfiguration* UIConfiguration::_instance = 0; static const double hue_width = 18.0; +sigc::signal UIConfiguration::ColorsChanged; + +sigc::signal UIConfiguration::DPIReset; + UIConfiguration::UIConfiguration () : #undef UI_CONFIG_VARIABLE @@ -75,13 +90,9 @@ UIConfiguration::UIConfiguration () load_state(); - ARDOUR_UI_UTILS::ColorsChanged.connect (boost::bind (&UIConfiguration::colors_changed, this)); + ColorsChanged.connect (boost::bind (&UIConfiguration::colors_changed, this)); ParameterChanged.connect (sigc::mem_fun (*this, &UIConfiguration::parameter_changed)); - - /* force GTK theme setting, so that loading an RC file will work */ - - load_color_theme (); } UIConfiguration::~UIConfiguration () @@ -129,7 +140,6 @@ UIConfiguration::reset_gtk_theme () for (ColorAliases::iterator g = color_aliases.begin(); g != color_aliases.end(); ++g) { if (g->first.find ("gtk_") == 0) { - ColorAliases::const_iterator a = color_aliases.find (g->first); const string gtk_name = g->first.substr (4); ss << gtk_name << ":#" << std::setw (6) << setfill ('0') << (color (g->second) >> 8) << ';'; } @@ -141,7 +151,41 @@ UIConfiguration::reset_gtk_theme () Gtk::Settings::get_default()->property_gtk_color_scheme() = ss.str(); } - + +void +UIConfiguration::reset_dpi () +{ + long val = get_font_scale(); + set_pango_fontsize (); + /* Xft rendering */ + + gtk_settings_set_long_property (gtk_settings_get_default(), + "gtk-xft-dpi", val, "ardour"); + DPIReset(); //Emit Signal +} + +void +UIConfiguration::set_pango_fontsize () +{ + long val = get_font_scale(); + + /* FT2 rendering - used by GnomeCanvas, sigh */ + +#ifndef PLATFORM_WINDOWS + pango_ft2_font_map_set_resolution ((PangoFT2FontMap*) pango_ft2_font_map_new(), val/1024, val/1024); +#endif + + /* Cairo rendering, in case there is any */ + + pango_cairo_font_map_set_resolution ((PangoCairoFontMap*) pango_cairo_font_map_get_default(), val/1024); +} + +float +UIConfiguration::get_ui_scale () +{ + return get_font_scale () / 102400.; +} + void UIConfiguration::map_parameters (boost::function& functor) { @@ -151,6 +195,29 @@ UIConfiguration::map_parameters (boost::function& functor) #undef UI_CONFIG_VARIABLE } +int +UIConfiguration::pre_gui_init () +{ +#ifdef CAIRO_SUPPORTS_FORCE_BUGGY_GRADIENTS_ENVIRONMENT_VARIABLE + if (get_buggy_gradients()) { + g_setenv ("FORCE_BUGGY_GRADIENTS", "1", 1); + } +#endif +#ifdef OPTIONAL_CAIRO_IMAGE_SURFACE + if (get_cairo_image_surface()) { + g_setenv ("ARDOUR_IMAGE_SURFACE", "1", 1); + } +#endif + return 0; +} + +UIConfiguration* +UIConfiguration::post_gui_init () +{ + load_color_theme (); + return this; +} + int UIConfiguration::load_defaults () { @@ -177,13 +244,14 @@ UIConfiguration::load_defaults () warning << string_compose (_("Could not find default UI configuration file %1"), default_ui_config_file_name) << endmsg; } + if (ret == 0) { /* reload color theme */ load_color_theme (false); - ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */ + ColorsChanged (); /* EMIT SIGNAL */ } - return 0; + return ret; } int @@ -228,7 +296,7 @@ UIConfiguration::load_color_theme (bool allow_own) return -1; } - ARDOUR_UI_UTILS::ColorsChanged (); + ColorsChanged (); } else { warning << string_compose (_("Color file %1 not found"), basename) << endmsg; } @@ -240,7 +308,7 @@ int UIConfiguration::store_color_theme () { XMLNode* root; - LocaleGuard lg (X_("POSIX")); + LocaleGuard lg (X_("C")); root = new XMLNode("Ardour"); @@ -375,7 +443,7 @@ XMLNode& UIConfiguration::get_state () { XMLNode* root; - LocaleGuard lg (X_("POSIX")); + LocaleGuard lg (X_("C")); root = new XMLNode("Ardour"); @@ -393,7 +461,7 @@ XMLNode& UIConfiguration::get_variables (std::string which_node) { XMLNode* node; - LocaleGuard lg (X_("POSIX")); + LocaleGuard lg (X_("C")); node = new XMLNode (which_node); @@ -497,7 +565,7 @@ UIConfiguration::load_colors (XMLNode const & node) if (name && color) { ArdourCanvas::Color c; - c = strtol (color->value().c_str(), 0, 16); + c = strtoul (color->value().c_str(), 0, 16); colors.insert (make_pair (name->value(), c)); } } @@ -506,7 +574,7 @@ UIConfiguration::load_colors (XMLNode const & node) void UIConfiguration::load_modifiers (XMLNode const & node) { - PBD::LocaleGuard lg ("POSIX"); + PBD::LocaleGuard lg ("C"); XMLNodeList const nlist = node.children(); XMLNodeConstIterator niter; XMLProperty const *name; @@ -557,6 +625,12 @@ UIConfiguration::color_mod (std::string const & colorname, std::string const & m return HSV (color (colorname)).mod (modifier (modifiername)).color (); } +ArdourCanvas::Color +UIConfiguration::color_mod (const ArdourCanvas::Color& color, std::string const & modifiername) const +{ + return HSV (color).mod (modifier (modifiername)).color (); +} + ArdourCanvas::Color UIConfiguration::color (const std::string& name, bool* failed) const { @@ -614,7 +688,7 @@ UIConfiguration::set_color (string const& name, ArdourCanvas::Color color) i->second = color; colors_modified = true; - ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */ + ColorsChanged (); /* EMIT SIGNAL */ } void @@ -628,7 +702,7 @@ UIConfiguration::set_alias (string const & name, string const & alias) i->second = alias; aliases_modified = true; - ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */ + ColorsChanged (); /* EMIT SIGNAL */ } void @@ -643,7 +717,7 @@ UIConfiguration::set_modifier (string const & name, SVAModifier svam) m->second = svam; modifiers_modified = true; - ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */ + ColorsChanged (); /* EMIT SIGNAL */ } void