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;
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));
stopping.connect (mem_fun(*this, &ARDOUR_UI::shutdown));
@ -632,7 +632,6 @@ ARDOUR_UI::startup ()
}
BootMessage (_("Ardour is ready for use"));
show ();
}

View file

@ -98,6 +98,7 @@ namespace ALSA {
#define FRAME_NAME "BaseFrame"
extern sigc::signal<void> ColorsChanged;
extern sigc::signal<void> DPIReset;
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);
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);
reset_dpi();
}
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));
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();
}
@ -288,7 +289,7 @@ GainMeter::meter_metrics_expose (GdkEventExpose *ev)
Glib::RefPtr<Gdk::Pixmap> pixmap;
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);
} else {
pixmap = i->second;
@ -965,8 +966,9 @@ void GainMeter::clear_meters ()
}
}
void GainMeter::color_handler()
void GainMeter::color_handler(bool dpi)
{
color_changed = true;
dpi_changed = (dpi) ? true : false;
setup_meters();
}

View file

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

View file

@ -243,7 +243,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, con
mark->property_outline_color_rgba() = rgba;
mark->property_width_pixels() = 1;
Pango::FontDescription* font = get_font_for_style (N_("MarkerText"));
text = new Text (*group);
text->property_text() = annotation.c_str();
text->property_font_desc() = *font;

View file

@ -46,6 +46,7 @@
#include "option_editor.h"
#include "midi_port_dialog.h"
#include "gui_thread.h"
#include "utils.h"
#include "i18n.h"
@ -252,25 +253,6 @@ OptionEditor::add_session_paths ()
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
font_scale_changed (Gtk::Adjustment* adj)
{

View file

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

View file

@ -143,7 +143,7 @@ RegionView::init (Gdk::Color& basic_color, bool wfd)
set_colors ();
ColorsChanged.connect (mem_fun (*this, &RegionView::color_handler));
set_pango_fontsize();
/* 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 <cctype>
#include <fstream>
@ -31,6 +34,7 @@
#include <gtkmm2ext/utils.h>
#include <ardour/ardour.h>
#include <ardour/configuration.h>
#include "ardour_ui.h"
#include "keyboard.h"
@ -45,6 +49,8 @@ using namespace sigc;
using namespace Glib;
using namespace PBD;
sigc::signal<void> DPIReset;
int
pixel_width (const ustring& str, Pango::FontDescription& font)
{
@ -692,6 +698,29 @@ key_is_legal_for_numeric_entry (guint keyval)
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);
std::string longest (std::vector<std::string>&);
bool key_is_legal_for_numeric_entry (guint keyval);
void reset_dpi ();
void set_pango_fontsize ();
#endif /* __ardour_gtk_utils_h__ */