From 33088c728a08e65df182ab7b386e2f583e655cbc Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 30 Jan 2021 02:22:55 +0100 Subject: [PATCH] Clean up AudioClock font API see also previous commit 2abf9c66a4fbf --- gtk2_ardour/audio_clock.cc | 41 +++++++++----------------------------- gtk2_ardour/audio_clock.h | 1 - 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index 72115d6d8f..fb30e0913f 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -173,39 +173,9 @@ AudioClock::on_realize () first_width = req.width; first_height = req.height; - // XXX FIX ME: define font based on ... ??? - // set_font (); set_colors (); } -void -AudioClock::set_font (Pango::FontDescription font) -{ - Glib::RefPtr style = get_style (); - Pango::AttrFontDesc* font_attr; - - font_size = font.get_size(); - font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font)); - - normal_attributes.change (*font_attr); - editing_attributes.change (*font_attr); - delete font_attr; - - /* get the figure width for the font. This doesn't have to super - * accurate since we only use it to measure the (roughly 1 character) - * offset from the position Pango tells us for the "cursor" - */ - - Glib::RefPtr tmp = Pango::Layout::create (get_pango_context()); - int ignore_height; - - tmp->set_text ("8"); - tmp->get_pixel_size (em_width, ignore_height); - - /* force redraw of markup with new font-size */ - AudioClock::set (last_when, true); -} - void AudioClock::set_active_state (Gtkmm2ext::ActiveState s) { @@ -2280,11 +2250,18 @@ AudioClock::on_style_changed (const Glib::RefPtr& old_style) { CairoWidget::on_style_changed (old_style); + Glib::RefPtr const& new_style = get_style (); + if (_layout && (_layout->get_font_description ().gobj () == 0 || _layout->get_font_description () != new_style->get_font ())) { + _layout->set_font_description (new_style->get_font ()); + queue_resize (); + } else if (is_realized ()) { + queue_resize (); + } + Gtk::Requisition req; set_clock_dimensions (req); - /* XXXX fix me ... we shouldn't be using GTK styles anyway */ - // set_font (); + /* set-colors also sets up font-attributes */ set_colors (); } diff --git a/gtk2_ardour/audio_clock.h b/gtk2_ardour/audio_clock.h index dc089a0d9e..4a59d2dd01 100644 --- a/gtk2_ardour/audio_clock.h +++ b/gtk2_ardour/audio_clock.h @@ -256,7 +256,6 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr ARDOUR::samplecnt_t parse_as_seconds_distance (const std::string&); ARDOUR::samplecnt_t parse_as_samples_distance (const std::string&); - void set_font (Pango::FontDescription); void set_colors (); void show_edit_status (int length); int merge_input_and_edit_string ();