*/
+#if !defined USE_CAIRO_IMAGE_SURFACE && !defined NDEBUG
+#define OPTIONAL_CAIRO_IMAGE_SURFACE
+#endif
+
#include <iostream>
#include <sstream>
#include <unistd.h>
#include <cstdlib>
#include <cstdio> /* for snprintf, grrr */
+#include <cairo/cairo.h>
+
+#include <pango/pangoft2.h> // for fontmap resolution control for GnomeCanvas
+#include <pango/pangocairo.h> // for fontmap resolution control for GnomeCanvas
+
#include <glibmm/miscutils.h>
#include <glib/gstdio.h>
+#include <gtkmm/settings.h>
+
#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"
#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"
static const double hue_width = 18.0;
+sigc::signal<void> UIConfiguration::ColorsChanged;
+
+sigc::signal<void> UIConfiguration::DPIReset;
+
UIConfiguration::UIConfiguration ()
:
#undef UI_CONFIG_VARIABLE
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 ()
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) << ';';
}
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<void (std::string)>& 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 ()
{
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
return -1;
}
- ARDOUR_UI_UTILS::ColorsChanged ();
+ ColorsChanged ();
} else {
warning << string_compose (_("Color file %1 not found"), basename) << endmsg;
}
UIConfiguration::store_color_theme ()
{
XMLNode* root;
- LocaleGuard lg (X_("POSIX"));
+ LocaleGuard lg (X_("C"));
root = new XMLNode("Ardour");
UIConfiguration::get_state ()
{
XMLNode* root;
- LocaleGuard lg (X_("POSIX"));
+ LocaleGuard lg (X_("C"));
root = new XMLNode("Ardour");
UIConfiguration::get_variables (std::string which_node)
{
XMLNode* node;
- LocaleGuard lg (X_("POSIX"));
+ LocaleGuard lg (X_("C"));
node = new XMLNode (which_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));
}
}
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;
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
{
i->second = color;
colors_modified = true;
- ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */
+ ColorsChanged (); /* EMIT SIGNAL */
}
void
i->second = alias;
aliases_modified = true;
- ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */
+ ColorsChanged (); /* EMIT SIGNAL */
}
void
m->second = svam;
modifiers_modified = true;
- ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */
+ ColorsChanged (); /* EMIT SIGNAL */
}
void