summaryrefslogtreecommitdiff
path: root/gtk2_ardour/midi_region_view.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-10-23 10:38:50 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-10-23 10:38:50 -0400
commit4f9e46976c45ad60007d87903a48f32cff48227f (patch)
tree716a3ed8a52e331a14926354f32d87f875521b6c /gtk2_ardour/midi_region_view.cc
parentfca33f903db7786cb69435cda6ea34871faae921 (diff)
make middle-click on piano roll track header more usefully select/unselect notes
Diffstat (limited to 'gtk2_ardour/midi_region_view.cc')
-rw-r--r--gtk2_ardour/midi_region_view.cc37
1 files changed, 22 insertions, 15 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index d681bb43de..ffd09b76a8 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -2135,32 +2135,39 @@ MidiRegionView::invert_selection ()
void
MidiRegionView::select_matching_notes (uint8_t notenum, uint16_t channel_mask, bool add, bool extend)
{
+ bool have_selection = !_selection.empty();
uint8_t low_note = 127;
uint8_t high_note = 0;
MidiModel::Notes& notes (_model->notes());
_optimization_iterator = _events.begin();
+
+ if (extend && !have_selection) {
+ extend = false;
+ }
+ /* scan existing selection to get note range */
+
+ for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
+ if ((*i)->note()->note() < low_note) {
+ low_note = (*i)->note()->note();
+ }
+ if ((*i)->note()->note() > high_note) {
+ high_note = (*i)->note()->note();
+ }
+ }
+
if (!add) {
clear_selection ();
- }
- if (extend && _selection.empty()) {
- extend = false;
+ if (!extend && (low_note == high_note) && (high_note == notenum)) {
+ /* only note previously selected is the one we are
+ * reselecting. treat this as cancelling the selection.
+ */
+ return;
+ }
}
if (extend) {
-
- /* scan existing selection to get note range */
-
- for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
- if ((*i)->note()->note() < low_note) {
- low_note = (*i)->note()->note();
- }
- if ((*i)->note()->note() > high_note) {
- high_note = (*i)->note()->note();
- }
- }
-
low_note = min (low_note, notenum);
high_note = max (high_note, notenum);
}