+ // Add and display region views, and flag them as valid
+ _trackview.track()->playlist()->foreach_region(
+ sigc::hide_return (sigc::mem_fun (*this, &StreamView::add_region_view))
+ );
+
+ // Stack regions by layer, and remove invalid regions
+ layer_regions();
+
+ // Update note range (not regions which are correct) and draw note lines
+ apply_note_range(_lowest_note, _highest_note, false);
+}
+
+
+void
+MidiStreamView::update_contents_height ()
+{
+ StreamView::update_contents_height();
+ _note_lines->property_y2() = child_height ();
+
+ apply_note_range (lowest_note(), highest_note(), true);
+}
+
+void
+MidiStreamView::draw_note_lines()
+{
+ if (!_note_lines || _updates_suspended) {
+ return;
+ }
+
+ double y;
+ double prev_y = contents_height();
+ uint32_t color;
+
+ _note_lines->clear();
+
+ if (child_height() < 140){
+ return;
+ }
+
+ for (int i = lowest_note(); i <= highest_note(); ++i) {
+ y = floor(note_to_y(i));
+
+ _note_lines->add_line(prev_y, 1.0, ARDOUR_UI::config()->canvasvar_PianoRollBlackOutline.get());
+
+ switch (i % 12) {
+ case 1:
+ case 3:
+ case 6:
+ case 8:
+ case 10:
+ color = ARDOUR_UI::config()->canvasvar_PianoRollBlack.get();
+ break;
+ default:
+ color = ARDOUR_UI::config()->canvasvar_PianoRollWhite.get();
+ break;
+ }
+
+ if (i == highest_note()) {
+ _note_lines->add_line(y, prev_y - y, color);
+ } else {
+ _note_lines->add_line(y + 1.0, prev_y - y - 1.0, color);
+ }
+
+ prev_y = y;
+ }
+}
+
+void
+MidiStreamView::set_note_range(VisibleNoteRange r)
+{
+ if (r == FullRange) {
+ _lowest_note = 0;
+ _highest_note = 127;
+ } else {
+ _lowest_note = _data_note_min;
+ _highest_note = _data_note_max;