Small refactoring; fix stuck notes on the sequence LMB down, RMB down, LMB up, RMB...
authorCarl Hetherington <carl@carlh.net>
Wed, 9 Mar 2011 18:13:12 +0000 (18:13 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 9 Mar 2011 18:13:12 +0000 (18:13 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9114 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/piano_roll_header.cc
gtk2_ardour/piano_roll_header.h

index e88f551e91ff0853a3989c60fa8837b73ae70c36..28398678a139cdcde0efca4ee98d597bced2ffa7 100644 (file)
@@ -479,7 +479,7 @@ PianoRollHeader::on_motion_notify_event (GdkEventMotion* ev)
                if (_clicked_note != no_note && _clicked_note != note) {
                        _active_notes[_clicked_note] = false;
                        send_note_off(_clicked_note);
-                       
+
                        _clicked_note = note;
                        
                        if (!_active_notes[note]) {
@@ -516,7 +516,7 @@ PianoRollHeader::on_button_press_event (GdkEventButton* ev)
                                
                                invalidate_note_range(note, note);
                        } else {
-                               _clicked_note = no_note;
+                               reset_clicked_note(note);
                        }
                }
        }
@@ -547,11 +547,7 @@ PianoRollHeader::on_button_release_event (GdkEventButton* ev)
                        _dragging = false;
                        
                        if (note == _clicked_note) {
-                               _active_notes[note] = false;
-                               _clicked_note = no_note;
-                               send_note_off(note);
-                               
-                               invalidate_note_range(note, note);
+                               reset_clicked_note(note);
                        }
                } 
        }
@@ -574,14 +570,7 @@ PianoRollHeader::on_leave_notify_event (GdkEventCrossing*)
        invalidate_note_range(_highlighted_note, _highlighted_note);
 
        if (_clicked_note != no_note) {
-               _active_notes[_clicked_note] = false;
-               send_note_off(_clicked_note);
-
-               if (_clicked_note != _highlighted_note) {
-                       invalidate_note_range(_clicked_note, _clicked_note);
-               }
-
-               _clicked_note = no_note;
+               reset_clicked_note(_clicked_note, _clicked_note != _highlighted_note);
        }
 
        _highlighted_note = no_note;
@@ -700,3 +689,13 @@ PianoRollHeader::send_note_off(uint8_t note)
        }
 }
 
+void
+PianoRollHeader::reset_clicked_note (uint8_t note, bool invalidate)
+{
+       _active_notes[note] = false;
+       _clicked_note = no_note;
+       send_note_off (note);
+       if (invalidate) {
+               invalidate_note_range (note, note);
+       }
+}
index 453c32468de620a2c33378b1d35d4e8002ee3359..7f469aebcefe20b49ff7defb4f1a1846c6d9650f 100644 (file)
@@ -92,6 +92,8 @@ private:
        void send_note_on(uint8_t note);
        void send_note_off(uint8_t note);
 
+       void reset_clicked_note(uint8_t, bool invalidate = true);
+
        MidiStreamView& _view;
 
        uint8_t _event[3];