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
This commit is contained in:
Paul Davis 2010-06-03 15:57:31 +00:00
parent eb37119975
commit ce78296f96
5 changed files with 28 additions and 31 deletions

View File

@ -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));

View File

@ -1336,14 +1336,12 @@ MidiRegionView::update_note (CanvasNote* ev)
{
boost::shared_ptr<NoteType> 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;

View File

@ -298,7 +298,7 @@ MidiStreamView::update_contents_height ()
{
StreamView::update_contents_height();
_note_lines->property_y2() = height;
draw_note_lines();
}

View File

@ -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<Pango::Layout> 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<Pango::Layout> 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);

View File

@ -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;