From ce78296f96071f4617b52327b0face0b65553e88 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 3 Jun 2010 15:57:31 +0000 Subject: [PATCH] move computation of TimeAxisViewItem fixed heights into a static member function and call early in process life, because we need the values in MidiStreamview - fixes a bug with notes not aligning with note lines in a new session git-svn-id: svn://localhost/ardour2/branches/3.0@7220 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui.cc | 3 ++ gtk2_ardour/midi_region_view.cc | 4 +-- gtk2_ardour/midi_streamview.cc | 2 +- gtk2_ardour/time_axis_view_item.cc | 48 ++++++++++++++---------------- gtk2_ardour/time_axis_view_item.h | 2 +- 5 files changed, 28 insertions(+), 31 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 0a8209fe22..10fdeb991e 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -96,6 +96,7 @@ typedef uint64_t microseconds_t; #include "startup.h" #include "engine_dialog.h" #include "processor_box.h" +#include "time_axis_view_item.h" #include "i18n.h" @@ -286,6 +287,8 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[]) reset_dpi(); + TimeAxisViewItem::set_constant_heights (); + starting.connect (sigc::mem_fun(*this, &ARDOUR_UI::startup)); stopping.connect (sigc::mem_fun(*this, &ARDOUR_UI::shutdown)); diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 53948ef366..63852fdf9d 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -1336,14 +1336,12 @@ MidiRegionView::update_note (CanvasNote* ev) { boost::shared_ptr note = ev->note(); - const nframes64_t note_start_frames = beats_to_frames(note->time()); const nframes64_t note_end_frames = beats_to_frames(note->end_time()); const double x = trackview.editor().frame_to_pixel(note_start_frames - _region->start()); const double y1 = midi_stream_view()->note_to_y(note->note()); - const double note_endpixel = - trackview.editor().frame_to_pixel(note_end_frames - _region->start()); + const double note_endpixel = trackview.editor().frame_to_pixel(note_end_frames - _region->start()); ev->property_x1() = x; ev->property_y1() = y1; diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc index 34111c3c60..4ab4c7154e 100644 --- a/gtk2_ardour/midi_streamview.cc +++ b/gtk2_ardour/midi_streamview.cc @@ -298,7 +298,7 @@ MidiStreamView::update_contents_height () { StreamView::update_contents_height(); _note_lines->property_y2() = height; - + draw_note_lines(); } diff --git a/gtk2_ardour/time_axis_view_item.cc b/gtk2_ardour/time_axis_view_item.cc index 416a1741dc..e4f7a860e7 100644 --- a/gtk2_ardour/time_axis_view_item.cc +++ b/gtk2_ardour/time_axis_view_item.cc @@ -49,7 +49,6 @@ using namespace PBD; using namespace ARDOUR; Pango::FontDescription* TimeAxisViewItem::NAME_FONT = 0; -bool TimeAxisViewItem::have_name_font = false; const double TimeAxisViewItem::NAME_X_OFFSET = 15.0; const double TimeAxisViewItem::GRAB_HANDLE_LENGTH = 6; @@ -58,6 +57,28 @@ double TimeAxisViewItem::NAME_Y_OFFSET; double TimeAxisViewItem::NAME_HIGHLIGHT_SIZE; double TimeAxisViewItem::NAME_HIGHLIGHT_THRESH; +void +TimeAxisViewItem::set_constant_heights () +{ + NAME_FONT = get_font_for_style (X_("TimeAxisViewItemName")); + + Gtk::Window win; + Gtk::Label foo; + win.add (foo); + + Glib::RefPtr layout = foo.create_pango_layout (X_("Hg")); /* ascender + descender */ + int width = 0; + int height = 0; + + layout->set_font_description (*NAME_FONT); + Gtkmm2ext::get_ink_pixel_size (layout, width, height); + + NAME_HEIGHT = height; + NAME_Y_OFFSET = height + 3; + NAME_HIGHLIGHT_SIZE = height + 2; + NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 3; +} + /** * Construct a new TimeAxisViewItem. * @@ -76,31 +97,6 @@ TimeAxisViewItem::TimeAxisViewItem(const string & it_name, ArdourCanvas::Group& , _height (1.0) , _recregion (recording) { - if (!have_name_font) { - - /* first constructed item sets up font info */ - - NAME_FONT = get_font_for_style (N_("TimeAxisViewItemName")); - - Gtk::Window win; - Gtk::Label foo; - win.add (foo); - - Glib::RefPtr layout = foo.create_pango_layout (X_("Hg")); /* ascender + descender */ - int width = 0; - int height = 0; - - layout->set_font_description (*NAME_FONT); - Gtkmm2ext::get_ink_pixel_size (layout, width, height); - - NAME_HEIGHT = height; - NAME_Y_OFFSET = height + 3; - NAME_HIGHLIGHT_SIZE = height + 2; - NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 3; - - have_name_font = true; - } - group = new ArdourCanvas::Group (parent); init (it_name, spu, base_color, start, duration, vis, true, true); diff --git a/gtk2_ardour/time_axis_view_item.h b/gtk2_ardour/time_axis_view_item.h index 390b3ee2f5..7a34d7e590 100644 --- a/gtk2_ardour/time_axis_view_item.h +++ b/gtk2_ardour/time_axis_view_item.h @@ -88,7 +88,7 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList // Default sizes, font and spacing static Pango::FontDescription* NAME_FONT; - static bool have_name_font; + static void set_constant_heights (); static const double NAME_X_OFFSET; static const double GRAB_HANDLE_LENGTH;