13
0

ResizeNoteDrag selection click behaves as NoteDrag's does.

This commit is contained in:
nick_m 2015-10-24 01:19:00 +11:00
parent 96524d863b
commit c9864b71a0
2 changed files with 63 additions and 6 deletions

View File

@ -2340,6 +2340,7 @@ NoteResizeDrag::NoteResizeDrag (Editor* e, ArdourCanvas::Item* i)
, region (0) , region (0)
, relative (false) , relative (false)
, at_front (true) , at_front (true)
, _was_selected (false)
, _snap_delta (0) , _snap_delta (0)
{ {
DEBUG_TRACE (DEBUG::Drags, "New NoteResizeDrag\n"); DEBUG_TRACE (DEBUG::Drags, "New NoteResizeDrag\n");
@ -2382,11 +2383,26 @@ NoteResizeDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*ignored*/)
relative = true; relative = true;
} }
/* select this note; if it is already selected, preserve the existing selection, if (!(_was_selected = cnote->selected())) {
otherwise make this note the only one selected.
*/ /* tertiary-click means extend selection - we'll do that on button release,
_editor->get_selection().clear_points(); so don't add it here, because otherwise we make it hard to figure
region->note_selected (cnote, cnote->selected ()); out the "extend-to" range.
*/
bool extend = Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier);
if (!extend) {
bool add = Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier);
if (add) {
region->note_selected (cnote, true);
} else {
_editor->get_selection().clear_points();
region->unique_select (cnote);
}
}
}
} }
void void
@ -2444,6 +2460,46 @@ void
NoteResizeDrag::finished (GdkEvent* event, bool movement_occurred) NoteResizeDrag::finished (GdkEvent* event, bool movement_occurred)
{ {
if (!movement_occurred) { if (!movement_occurred) {
/* no motion - select note */
NoteBase* cnote = reinterpret_cast<NoteBase*> (_item->get_data ("notebase"));
if (_editor->current_mouse_mode() == Editing::MouseContent ||
_editor->current_mouse_mode() == Editing::MouseDraw) {
bool changed = false;
if (_was_selected) {
bool add = Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier);
if (add) {
region->note_deselected (cnote);
changed = true;
} else {
_editor->get_selection().clear_points();
region->unique_select (cnote);
changed = true;
}
} else {
bool extend = Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier);
bool add = Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier);
if (!extend && !add && region->selection_size() > 1) {
_editor->get_selection().clear_points();
region->unique_select (cnote);
changed = true;
} else if (extend) {
region->note_selected (cnote, true, true);
changed = true;
} else {
/* it was added during button press */
changed = true;
}
}
if (changed) {
_editor->begin_reversible_selection_op(X_("Resize Select Note Release"));
_editor->commit_reversible_selection_op();
}
}
return; return;
} }

View File

@ -533,6 +533,7 @@ private:
MidiRegionView* region; MidiRegionView* region;
bool relative; bool relative;
bool at_front; bool at_front;
bool _was_selected;
double _snap_delta; double _snap_delta;
}; };
@ -556,7 +557,7 @@ class NoteDrag : public Drag
NoteBase* _primary; NoteBase* _primary;
double _cumulative_dx; double _cumulative_dx;
double _cumulative_dy; double _cumulative_dy;
bool _was_selected; bool _was_selected;
double _note_height; double _note_height;
}; };