Fixes for canvas and gain meter text not being scaled on startup

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3119 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Doug McLain 2008-02-24 19:13:09 +00:00
parent 6299560116
commit 2f18e339cd
11 changed files with 45 additions and 28 deletions

View file

@ -244,7 +244,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
keyboard = new Keyboard; keyboard = new Keyboard;
gtk_settings_set_long_property (gtk_settings_get_default(), "gtk-xft-dpi", Config->get_font_scale(), "ardour"); reset_dpi();
starting.connect (mem_fun(*this, &ARDOUR_UI::startup)); starting.connect (mem_fun(*this, &ARDOUR_UI::startup));
stopping.connect (mem_fun(*this, &ARDOUR_UI::shutdown)); stopping.connect (mem_fun(*this, &ARDOUR_UI::shutdown));
@ -632,7 +632,6 @@ ARDOUR_UI::startup ()
} }
BootMessage (_("Ardour is ready for use")); BootMessage (_("Ardour is ready for use"));
show (); show ();
} }

View file

@ -98,6 +98,7 @@ namespace ALSA {
#define FRAME_NAME "BaseFrame" #define FRAME_NAME "BaseFrame"
extern sigc::signal<void> ColorsChanged; extern sigc::signal<void> ColorsChanged;
extern sigc::signal<void> DPIReset;
class ARDOUR_UI : public Gtkmm2ext::UI class ARDOUR_UI : public Gtkmm2ext::UI
{ {

View file

@ -880,6 +880,7 @@ ARDOUR_UI::editor_realized ()
set_size_request_to_display_given_text (speed_display_box, _("-0.55"), 2, 2); set_size_request_to_display_given_text (speed_display_box, _("-0.55"), 2, 2);
const guint32 FUDGE = 25; // Combo's are stupid - they steal space from the entry for the button const guint32 FUDGE = 25; // Combo's are stupid - they steal space from the entry for the button
set_size_request_to_display_given_text (shuttle_style_button, _("sprung"), 2+FUDGE, 10); set_size_request_to_display_given_text (shuttle_style_button, _("sprung"), 2+FUDGE, 10);
reset_dpi();
} }
void void

View file

@ -206,7 +206,8 @@ GainMeter::GainMeter (boost::shared_ptr<IO> io, Session& s)
ResetGroupPeakDisplays.connect (mem_fun(*this, &GainMeter::reset_group_peak_display)); ResetGroupPeakDisplays.connect (mem_fun(*this, &GainMeter::reset_group_peak_display));
UI::instance()->theme_changed.connect (mem_fun(*this, &GainMeter::on_theme_changed)); UI::instance()->theme_changed.connect (mem_fun(*this, &GainMeter::on_theme_changed));
ColorsChanged.connect (mem_fun (*this, &GainMeter::color_handler)); ColorsChanged.connect (bind(mem_fun (*this, &GainMeter::color_handler), false));
DPIReset.connect (bind(mem_fun (*this, &GainMeter::color_handler), true));
//hide_all(); //hide_all();
} }
@ -288,7 +289,7 @@ GainMeter::meter_metrics_expose (GdkEventExpose *ev)
Glib::RefPtr<Gdk::Pixmap> pixmap; Glib::RefPtr<Gdk::Pixmap> pixmap;
std::map<string,Glib::RefPtr<Gdk::Pixmap> >::iterator i = metric_pixmaps.find (meter_metric_area.get_name()); std::map<string,Glib::RefPtr<Gdk::Pixmap> >::iterator i = metric_pixmaps.find (meter_metric_area.get_name());
if (i == metric_pixmaps.end() || style_changed) { if (i == metric_pixmaps.end() || style_changed || dpi_changed) {
pixmap = render_metrics (meter_metric_area); pixmap = render_metrics (meter_metric_area);
} else { } else {
pixmap = i->second; pixmap = i->second;
@ -965,8 +966,9 @@ void GainMeter::clear_meters ()
} }
} }
void GainMeter::color_handler() void GainMeter::color_handler(bool dpi)
{ {
color_changed = true; color_changed = true;
dpi_changed = (dpi) ? true : false;
setup_meters(); setup_meters();
} }

View file

@ -192,8 +192,9 @@ class GainMeter : public Gtk::VBox
void on_theme_changed (); void on_theme_changed ();
bool style_changed; bool style_changed;
bool dpi_changed;
bool color_changed; bool color_changed;
void color_handler(); void color_handler(bool);
}; };
#endif /* __ardour_gtk_gain_meter_h__ */ #endif /* __ardour_gtk_gain_meter_h__ */

View file

@ -46,6 +46,7 @@
#include "option_editor.h" #include "option_editor.h"
#include "midi_port_dialog.h" #include "midi_port_dialog.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "utils.h"
#include "i18n.h" #include "i18n.h"
@ -252,25 +253,6 @@ OptionEditor::add_session_paths ()
session_raid_entry.set_text(session->raid_path()); session_raid_entry.set_text(session->raid_path());
} }
static void
reset_dpi ()
{
long val = Config->get_font_scale();
/* FT2 rendering */
pango_ft2_font_map_set_resolution ((PangoFT2FontMap*) pango_ft2_font_map_for_display(), val/1024, val/1024);
/* Cairo rendering, in case there is any */
pango_cairo_font_map_set_resolution ((PangoCairoFontMap*) pango_cairo_font_map_get_default(), val/1024);
/* Xft rendering */
gtk_settings_set_long_property (gtk_settings_get_default(),
"gtk-xft-dpi", val, "ardour");
}
static void static void
font_scale_changed (Gtk::Adjustment* adj) font_scale_changed (Gtk::Adjustment* adj)
{ {

View file

@ -59,7 +59,7 @@ AudioRegionGainLine::view_to_model_y (double& y)
void void
AudioRegionGainLine::model_to_view_y (double& y) AudioRegionGainLine::model_to_view_y (double& y)
{ {
if (y < 0) y == 0; if (y < 0) y = 0;
y = gain_to_slider_position (y); y = gain_to_slider_position (y);
} }

View file

@ -143,7 +143,7 @@ RegionView::init (Gdk::Color& basic_color, bool wfd)
set_colors (); set_colors ();
ColorsChanged.connect (mem_fun (*this, &RegionView::color_handler)); ColorsChanged.connect (mem_fun (*this, &RegionView::color_handler));
set_pango_fontsize();
/* XXX sync mark drag? */ /* XXX sync mark drag? */
} }

View file

@ -17,6 +17,9 @@
*/ */
#include <pango/pangoft2.h> // for fontmap resolution control for GnomeCanvas
#include <pango/pangocairo.h> // for fontmap resolution control for GnomeCanvas
#include <cstdlib> #include <cstdlib>
#include <cctype> #include <cctype>
#include <fstream> #include <fstream>
@ -31,6 +34,7 @@
#include <gtkmm2ext/utils.h> #include <gtkmm2ext/utils.h>
#include <ardour/ardour.h> #include <ardour/ardour.h>
#include <ardour/configuration.h>
#include "ardour_ui.h" #include "ardour_ui.h"
#include "keyboard.h" #include "keyboard.h"
@ -45,6 +49,8 @@ using namespace sigc;
using namespace Glib; using namespace Glib;
using namespace PBD; using namespace PBD;
sigc::signal<void> DPIReset;
int int
pixel_width (const ustring& str, Pango::FontDescription& font) pixel_width (const ustring& str, Pango::FontDescription& font)
{ {
@ -692,6 +698,29 @@ key_is_legal_for_numeric_entry (guint keyval)
return false; return false;
} }
void
set_pango_fontsize ()
{
long val = ARDOUR::Config->get_font_scale();
/* FT2 rendering */
pango_ft2_font_map_set_resolution ((PangoFT2FontMap*) pango_ft2_font_map_for_display(), val/1024, val/1024);
/* Cairo rendering, in case there is any */
pango_cairo_font_map_set_resolution ((PangoCairoFontMap*) pango_cairo_font_map_get_default(), val/1024);
}
void
reset_dpi ()
{
long val = ARDOUR::Config->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
}

View file

@ -83,5 +83,7 @@ static std::map<std::string, Glib::RefPtr<Gdk::Pixbuf> > xpm_map;
const char* const *get_xpm_data (std::string path); const char* const *get_xpm_data (std::string path);
std::string longest (std::vector<std::string>&); std::string longest (std::vector<std::string>&);
bool key_is_legal_for_numeric_entry (guint keyval); bool key_is_legal_for_numeric_entry (guint keyval);
void reset_dpi ();
void set_pango_fontsize ();
#endif /* __ardour_gtk_utils_h__ */ #endif /* __ardour_gtk_utils_h__ */