SelectionDrag::SelectionDrag (Editor* e, ArdourCanvas::Item* i, Operation o)
: Drag (e, i)
, _operation (o)
- , _copy (false)
+ , _add (false)
+ , _extend (false)
, _original_pointer_time_axis (-1)
, _last_pointer_time_axis (-1)
, _time_selection_at_start (!_editor->get_selection().time.empty())
{
DEBUG_TRACE (DEBUG::Drags, "New SelectionDrag\n");
+
+ if (_time_selection_at_start) {
+ start_at_start = _editor->get_selection().time.start();
+ end_at_start = _editor->get_selection().time.end_frame();
+ }
}
void
switch (_operation) {
case CreateSelection:
- if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) {
- _copy = true;
+ if (Keyboard::modifier_state_equals (event->button.state, Keyboard::CopyModifier)) {
+ _add = true;
} else {
- _copy = false;
+ _add = false;
}
cursor = _editor->cursors()->selector;
Drag::start_grab (event, cursor);
case SelectionMove:
Drag::start_grab (event, cursor);
break;
+
+ case SelectionExtend:
+ Drag::start_grab (event, cursor);
+ break;
}
if (_operation == SelectionMove) {
case SelectionEndTrim:
_pointer_frame_offset = raw_grab_frame() - _editor->selection->time[_editor->clicked_selection].end;
break;
+
+ case SelectionExtend:
+ break;
}
}
{
framepos_t start = 0;
framepos_t end = 0;
- framecnt_t length;
+ framecnt_t length = 0;
+ framecnt_t distance = 0;
pair<TimeAxisView*, int> const pending_time_axis = _editor->trackview_by_y_position (_drags->current_pointer_y ());
if (pending_time_axis.first == 0) {
if (first_move) {
- if (_copy) {
+ if (_add) {
/* adding to the selection */
_editor->set_selected_track_as_side_effect (Selection::Add);
//_editor->selection->add (_editor->clicked_axisview);
_editor->clicked_selection = _editor->selection->add (start, end);
- _copy = false;
+ _add = false;
} else {
/* new selection */
}
break;
-
+
case SelectionMove:
start = _editor->selection->time[_editor->clicked_selection].start;
end = _editor->selection->time[_editor->clicked_selection].end;
length = end - start;
-
+ distance = pending_position - start;
start = pending_position;
_editor->snap_to (start);
end = start + length;
break;
+
+ case SelectionExtend:
+ break;
}
if (event->button.x >= _editor->horizontal_position() + _editor->_canvas_width) {
}
if (start != end) {
- _editor->selection->replace (_editor->clicked_selection, start, end);
+ switch (_operation) {
+ case SelectionMove:
+ if (_time_selection_at_start) {
+ _editor->selection->move_time (distance);
+ }
+ break;
+ default:
+ _editor->selection->replace (_editor->clicked_selection, start, end);
+ }
}
if (_operation == SelectionMove) {
} else {
/* just a click, no pointer movement.
*/
- _editor->selection->clear_time();
+
+ if (_operation == SelectionExtend) {
+ if (_time_selection_at_start) {
+ framepos_t pos = adjusted_current_frame (event, false);
+ framepos_t start = min (pos, start_at_start);
+ framepos_t end = max (pos, end_at_start);
+ _editor->selection->set (start, end);
+ }
+ } else {
+ if (Keyboard::modifier_state_equals (event->button.state, Keyboard::CopyModifier)) {
+ if (_editor->clicked_selection) {
+ _editor->selection->remove (_editor->clicked_selection);
+ }
+ } else {
+ if (!_editor->clicked_selection) {
+ _editor->selection->clear_time();
+ }
+ }
+ }
if (_editor->clicked_axisview && !_editor->selection->selected (_editor->clicked_axisview)) {
_editor->selection->set (_editor->clicked_axisview);
}
-
+
if (s && s->get_play_range () && s->transport_rolling()) {
s->request_stop (false, false);
}
CreateSelection,
SelectionStartTrim,
SelectionEndTrim,
- SelectionMove
+ SelectionMove,
+ SelectionExtend
};
SelectionDrag (Editor *, ArdourCanvas::Item *, Operation);
private:
Operation _operation;
- bool _copy;
+ bool _add;
+ bool _extend;
int _original_pointer_time_axis;
int _last_pointer_time_axis;
std::list<TimeAxisView*> _added_time_axes;
bool _time_selection_at_start;
+ framepos_t start_at_start;
+ framepos_t end_at_start;
};
/** Range marker drag */
switch (item_type) {
case RegionItem:
- if (press) {
- if (mouse_mode != MouseRange) {
- set_selected_regionview_from_click (press, op);
+ if (!get_smart_mode() || (_join_object_range_state == JOIN_OBJECT_RANGE_OBJECT)) {
+ if (press) {
+ if (mouse_mode != MouseRange) {
+ set_selected_regionview_from_click (press, op);
+ } else {
+ /* don't change the selection unless the
+ clicked track is not currently selected. if
+ so, "collapse" the selection to just this
+ track
+ */
+ if (!selection->selected (clicked_axisview)) {
+ set_selected_track_as_side_effect (Selection::Set);
+ }
+ }
} else {
- /* don't change the selection unless the
- clicked track is not currently selected. if
- so, "collapse" the selection to just this
- track
- */
- if (!selection->selected (clicked_axisview)) {
- set_selected_track_as_side_effect (Selection::Set);
+ if (mouse_mode != MouseRange) {
+ set_selected_regionview_from_click (press, op);
}
}
- } else {
- if (mouse_mode != MouseRange) {
- set_selected_regionview_from_click (press, op);
- }
}
break;
break;
case SelectionItem:
- if (Keyboard::modifier_state_contains
- (event->button.state, Keyboard::ModifierMask(Keyboard::PrimaryModifier))) {
- // contains and not equals because I can't use alt as a modifier alone.
+ if (Keyboard::modifier_state_contains (event->button.state, Keyboard::ModifierMask(Keyboard::PrimaryModifier|Keyboard::SecondaryModifier))) {
start_selection_grab (item, event);
} else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::SecondaryModifier)) {
/* grab selection for moving */
return true;
}
} else {
- _drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event);
+ if (Keyboard::modifier_state_equals (event->button.state, Keyboard::RangeSelectModifier)) {
+ _drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionExtend), event);
+ } else {
+ _drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event);
+ }
return true;
}
break;
default:
if (!internal_editing()) {
- _drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event);
+ if (Keyboard::modifier_state_equals (event->button.state, Keyboard::RangeSelectModifier)) {
+ _drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionExtend), event);
+ } else {
+ _drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event);
+ }
}
}
return true;
return next_time_id - 1;
}
+void
+Selection::move_time (framecnt_t distance)
+{
+ if (distance == 0) {
+ return;
+ }
+
+ for (list<AudioRange>::iterator i = time.begin(); i != time.end(); ++i) {
+ (*i).start += distance;
+ (*i).end += distance;
+ }
+
+ TimeChanged ();
+}
+
void
Selection::replace (uint32_t sid, framepos_t start, framepos_t end)
{
void remove_regions (TimeAxisView *);
+ void move_time (framecnt_t);
+
void replace (uint32_t time_index, framepos_t start, framepos_t end);
/*