From 07b584f3126094b44ada7b13f84bf40598888ad3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 11 Jul 2011 13:17:01 +0000 Subject: [PATCH] fix for #3977 - shift-tab and shift-ctrl-tab move to the next/previous note like tab, but leave existing selected note(s) selected git-svn-id: svn://localhost/ardour2/branches/3.0@9838 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/midi_region_view.cc | 48 +++++++++++++++++++-------------- gtk2_ardour/midi_region_view.h | 4 +-- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index b873ea884d..eb0f87e117 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -723,13 +723,26 @@ MidiRegionView::key_press (GdkEventKey* ev) } else if (ev->keyval == GDK_Tab) { - if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { - goto_previous_note (); + if (Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier)) { + goto_previous_note (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)); } else { - goto_next_note (); + goto_next_note (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)); } return true; + } else if (ev->keyval == GDK_ISO_Left_Tab) { + + /* Shift-TAB generates ISO Left Tab, for some reason */ + + if (Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier)) { + goto_previous_note (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)); + } else { + goto_next_note (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)); + } + return true; + + + } else if (ev->keyval == GDK_Up) { bool allow_smush = Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier); @@ -2054,15 +2067,6 @@ MidiRegionView::note_selected(ArdourCanvas::CanvasNoteEvent* ev, bool add, bool add_to_selection (*i); } -#if 0 - /* if events were guaranteed to be time sorted, we could do this. - but as of sept 10th 2009, they no longer are. - */ - - if ((*i)->note()->time() > latest) { - break; - } -#endif } } } @@ -3141,9 +3145,8 @@ MidiRegionView::time_sort_events () } void -MidiRegionView::goto_next_note () +MidiRegionView::goto_next_note (bool add_to_selection) { - // framepos_t pos = -1; bool use_next = false; if (_events.back()->selected()) { @@ -3157,8 +3160,11 @@ MidiRegionView::goto_next_note () use_next = true; continue; } else if (use_next) { - unique_select (*i); - // pos = _region->position() + beats_to_frames ((*i)->note()->time()); + if (!add_to_selection) { + unique_select (*i); + } else { + note_selected (*i, true, false); + } return; } } @@ -3170,9 +3176,8 @@ MidiRegionView::goto_next_note () } void -MidiRegionView::goto_previous_note () +MidiRegionView::goto_previous_note (bool add_to_selection) { - // framepos_t pos = -1; bool use_next = false; if (_events.front()->selected()) { @@ -3186,8 +3191,11 @@ MidiRegionView::goto_previous_note () use_next = true; continue; } else if (use_next) { - unique_select (*i); - // pos = _region->position() + beats_to_frames ((*i)->note()->time()); + if (!add_to_selection) { + unique_select (*i); + } else { + note_selected (*i, true, false); + } return; } } diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 116f210ee1..6dfcd08e0b 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -258,8 +258,8 @@ public: /** Convert a timestamp in frames to beats (both relative to region start) */ double frames_to_beats(framepos_t) const; - void goto_previous_note (); - void goto_next_note (); + void goto_previous_note (bool add_to_selection); + void goto_next_note (bool add_to_selection); void change_note_lengths (bool, bool, Evoral::MusicalTime beats, bool start, bool end); void change_velocities (bool up, bool fine, bool allow_smush); void transpose (bool up, bool fine, bool allow_smush);