Fix two ghost note drawing problems.
authorAndré Nusser <andre.nusser@googlemail.com>
Mon, 30 Nov 2015 23:15:53 +0000 (00:15 +0100)
committerRobin Gareus <robin@gareus.org>
Tue, 12 Jan 2016 12:45:38 +0000 (13:45 +0100)
A ghost note could appear:
1) above the region.
2) inside another note even though we haven't yet entered it.

gtk2_ardour/midi_streamview.cc

index ce34fb9b888d1fcc92251b8827acdef4fb0b06c5..9258cf027d385973dd4080f64bcce0a4c881cc31 100644 (file)
@@ -619,7 +619,7 @@ MidiStreamView::update_rec_box ()
 uint8_t
 MidiStreamView::y_to_note (double y) const
 {
-       int const n = ((contents_height() - y - 1) / contents_height() * (double)contents_note_range())
+       int const n = ((contents_height() - y) / contents_height() * (double)contents_note_range())
                + lowest_note();
 
        if (n < 0) {
@@ -628,7 +628,8 @@ MidiStreamView::y_to_note (double y) const
                return 127;
        }
 
-       return n;
+       /* min due to rounding and/or off-by-one errors */
+       return min ((uint8_t) n, highest_note());
 }
 
 /** Suspend updates to the regions' note ranges and our