X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmidi_streamview.cc;h=a1e1269468ada724f5c7b2829b42bcc66293ac67;hb=33cadc0ef1cb3bd3f2468b8ac085ae1cf55b009e;hp=640c0263e14f8b66a6480b96c0b74438f5c5aaa9;hpb=5e5c71614664d02e1160454f080505fbcc2078aa;p=ardour.git diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc index 640c0263e1..a1e1269468 100644 --- a/gtk2_ardour/midi_streamview.cc +++ b/gtk2_ardour/midi_streamview.cc @@ -116,11 +116,11 @@ MidiStreamView::create_region_view (boost::shared_ptr r, bool /*wfd*/, b } RegionView* -MidiStreamView::add_region_view_internal (boost::shared_ptr r, bool wfd, bool recording) +MidiStreamView::add_region_view_internal (boost::shared_ptr r, bool wait_for_data, bool recording) { boost::shared_ptr region = boost::dynamic_pointer_cast (r); - if (region == 0) { + if (!region) { return 0; } @@ -131,13 +131,13 @@ MidiStreamView::add_region_view_internal (boost::shared_ptr r, bool wfd, (*i)->set_valid (true); - display_region(dynamic_cast(*i), wfd); + display_region(dynamic_cast(*i), wait_for_data); return 0; } } - MidiRegionView* region_view = dynamic_cast (create_region_view (r, wfd, recording)); + MidiRegionView* region_view = dynamic_cast (create_region_view (r, wait_for_data, recording)); if (region_view == 0) { return 0; } @@ -151,7 +151,7 @@ MidiStreamView::add_region_view_internal (boost::shared_ptr r, bool wfd, } /* display events and find note range */ - display_region (region_view, wfd); + display_region (region_view, wait_for_data); /* fit note range if we are importing */ if (_trackview.session()->operation_in_progress (Operations::insert_file)) { @@ -174,7 +174,7 @@ MidiStreamView::display_region(MidiRegionView* region_view, bool load_model) return; } - region_view->enable_display(true); + region_view->enable_display (true); boost::shared_ptr source(region_view->midi_region()->midi_source(0)); @@ -191,6 +191,7 @@ MidiStreamView::display_region(MidiRegionView* region_view, bool load_model) region_view->display_model(source->model()); } + void MidiStreamView::display_track (boost::shared_ptr tr) { @@ -285,7 +286,7 @@ MidiStreamView::draw_note_lines() } double y; - double prev_y = contents_height(); + double prev_y = 0; uint32_t color; _note_lines->clear(); @@ -295,10 +296,23 @@ MidiStreamView::draw_note_lines() return; } - for (int i = lowest_note(); i <= highest_note(); ++i) { - y = floor(note_to_y(i)); + /* do this is order of highest ... lowest since that matches the + * coordinate system in which y=0 is at the top + */ + + for (int i = highest_note(); i >= lowest_note(); --i) { + + y = note_to_y (i); + + /* this is the line actually corresponding to the division + * between notes + */ - _note_lines->add (prev_y, 1.0, ARDOUR_UI::config()->get_canvasvar_PianoRollBlackOutline()); + _note_lines->add (y, 1.0, ARDOUR_UI::config()->get_canvasvar_PianoRollBlackOutline()); + + /* now add a thicker line/bar which covers the entire vertical + * height of this note. + */ switch (i % 12) { case 1: @@ -313,10 +327,11 @@ MidiStreamView::draw_note_lines() break; } - if (i == highest_note()) { - _note_lines->add (y, prev_y - y, color); - } else { - _note_lines->add (y + 1.0, prev_y - y - 1.0, color); + double h = y - prev_y; + double mid = y + (h/2.0); + + if (height > 1.0) { + _note_lines->add (mid, h, color); } prev_y = y; @@ -642,9 +657,11 @@ void MidiStreamView::resume_updates () { _updates_suspended = false; - + draw_note_lines (); apply_note_range_to_regions (); + + _canvas_group->redraw (); } void