fix up drawing of MIDI note "lines" on track canvas, which were in the wrong places
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 23 Oct 2013 14:38:09 +0000 (10:38 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 23 Oct 2013 14:38:09 +0000 (10:38 -0400)
gtk2_ardour/midi_streamview.cc

index 640c0263e14f8b66a6480b96c0b74438f5c5aaa9..f192607da4ff1196d7e938f5ce321477f9f521b5 100644 (file)
@@ -285,7 +285,7 @@ MidiStreamView::draw_note_lines()
        }
 
        double y;
-       double prev_y = contents_height();
+       double prev_y = 0;
        uint32_t color;
 
        _note_lines->clear();
@@ -295,10 +295,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
+        */
 
-               _note_lines->add (prev_y, 1.0, ARDOUR_UI::config()->get_canvasvar_PianoRollBlackOutline());
+       for (int i = highest_note(); i >= lowest_note(); --i) {
+
+               y = floor (note_to_y(i));
+
+               /* this is the line actually corresponding to the division
+                * between notes
+                */
+
+               _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 +326,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;