}
}
-TrimDrag::TrimDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v)
+TrimDrag::TrimDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v, bool preserve_fade_anchor)
: RegionDrag (e, i, p, v)
{
DEBUG_TRACE (DEBUG::Drags, "New TrimDrag\n");
+ _preserve_fade_anchor = preserve_fade_anchor;
}
void
switch (_operation) {
case StartTrim:
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
- i->view->trim_front (i->initial_position + dt, non_overlap_trim);
+ bool changed = i->view->trim_front (i->initial_position + dt, non_overlap_trim);
+ if (changed && _preserve_fade_anchor) {
+ AudioRegionView* arv = dynamic_cast<AudioRegionView*> (i->view);
+ if (arv) {
+ double distance;
+ double new_length;
+ framecnt_t len;
+ boost::shared_ptr<AudioRegion> ar (arv->audio_region());
+ distance = _drags->current_pointer_x() - grab_x();
+ len = ar->fade_in()->back()->when;
+ new_length = len - _editor->unit_to_frame (distance);
+ new_length = ar->verify_xfade_bounds (new_length, true /*START*/ );
+ arv->reset_fade_in_shape_width (ar, new_length); //the grey shape
+ }
+ }
}
break;
case EndTrim:
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
- i->view->trim_end (i->initial_end + dt, non_overlap_trim);
+ bool changed = i->view->trim_end (i->initial_end + dt, non_overlap_trim);
+ if (changed && _preserve_fade_anchor) {
+ AudioRegionView* arv = dynamic_cast<AudioRegionView*> (i->view);
+ if (arv) {
+ double distance;
+ double new_length;
+ framecnt_t len;
+ boost::shared_ptr<AudioRegion> ar (arv->audio_region());
+ distance = grab_x() - _drags->current_pointer_x();
+ len = ar->fade_out()->back()->when;
+ new_length = len - _editor->unit_to_frame (distance);
+ new_length = ar->verify_xfade_bounds (new_length, false /*END*/ );
+ arv->reset_fade_out_shape_width (ar, new_length); //the grey shape
+ }
+ }
}
break;
if (movement_occurred) {
motion (event, false);
- /* This must happen before the region's StatefulDiffCommand is created, as it may
- `correct' (ahem) the region's _start from being negative to being zero. It
- needs to be zero in the undo record.
- */
if (_operation == StartTrim) {
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
- i->view->trim_front_ending ();
+ {
+ /* This must happen before the region's StatefulDiffCommand is created, as it may
+ `correct' (ahem) the region's _start from being negative to being zero. It
+ needs to be zero in the undo record.
+ */
+ i->view->trim_front_ending ();
+ }
+ if (_preserve_fade_anchor) {
+ AudioRegionView* arv = dynamic_cast<AudioRegionView*> (i->view);
+ if (arv) {
+ double distance;
+ double new_length;
+ framecnt_t len;
+ boost::shared_ptr<AudioRegion> ar (arv->audio_region());
+ distance = _drags->current_pointer_x() - grab_x();
+ len = ar->fade_in()->back()->when;
+ new_length = len - _editor->unit_to_frame (distance);
+ new_length = ar->verify_xfade_bounds (new_length, true /*START*/ );
+ ar->set_fade_in_length(new_length);
+ }
+ }
+ }
+ } else if (_operation == EndTrim) {
+ for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
+ if (_preserve_fade_anchor) {
+ AudioRegionView* arv = dynamic_cast<AudioRegionView*> (i->view);
+ if (arv) {
+ double distance;
+ double new_length;
+ framecnt_t len;
+ boost::shared_ptr<AudioRegion> ar (arv->audio_region());
+ distance = _drags->current_pointer_x() - grab_x();
+ len = ar->fade_out()->back()->when;
+ new_length = len - _editor->unit_to_frame (distance);
+ new_length = ar->verify_xfade_bounds (new_length, false /*END*/ );
+ ar->set_fade_out_length(new_length);
+ }
+ }
}
}
-
+
if (_operation == StartTrim) {
_editor->maybe_locate_with_edit_preroll ( _views.begin()->view->region()->position() );
}
}
}
}
+
for (set<boost::shared_ptr<Playlist> >::iterator p = _editor->motion_frozen_playlists.begin(); p != _editor->motion_frozen_playlists.end(); ++p) {
(*p)->thaw ();
}
_editor->motion_frozen_playlists.clear ();
_editor->commit_reversible_command();
- for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
- i->view->drag_end ();
- }
-
} else {
/* no mouse movement */
_editor->point_trim (event, adjusted_current_frame (event));
boost::shared_ptr<AudioRegion> const r = arv->audio_region ();
show_verbose_cursor_duration (r->position(), r->position() + r->fade_in()->back()->when, 32);
-
- arv->show_fade_line((framepos_t) r->fade_in()->back()->when);
}
void
continue;
}
- tmp->reset_fade_in_shape_width (fade_length);
- tmp->show_fade_line((framecnt_t) fade_length);
+ tmp->reset_fade_in_shape_width (tmp->audio_region(), fade_length);
}
show_verbose_cursor_duration (region->position(), region->position() + fade_length, 32);
tmp->audio_region()->set_fade_in_length (fade_length);
tmp->audio_region()->set_fade_in_active (true);
- tmp->hide_fade_line();
XMLNode &after = alist->get_state();
_editor->session()->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &after));
continue;
}
- tmp->reset_fade_in_shape_width (tmp->audio_region()->fade_in()->back()->when);
- tmp->hide_fade_line();
+ tmp->reset_fade_in_shape_width (tmp->audio_region(), tmp->audio_region()->fade_in()->back()->when);
}
}
boost::shared_ptr<AudioRegion> r = arv->audio_region ();
show_verbose_cursor_duration (r->last_frame() - r->fade_out()->back()->when, r->last_frame());
-
- arv->show_fade_line(r->length() - r->fade_out()->back()->when);
}
void
continue;
}
- tmp->reset_fade_out_shape_width (fade_length);
- tmp->show_fade_line(region->length() - fade_length);
+ tmp->reset_fade_out_shape_width (tmp->audio_region(), fade_length);
}
show_verbose_cursor_duration (region->last_frame() - fade_length, region->last_frame());
tmp->audio_region()->set_fade_out_length (fade_length);
tmp->audio_region()->set_fade_out_active (true);
- tmp->hide_fade_line();
XMLNode &after = alist->get_state();
_editor->session()->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &after));
continue;
}
- tmp->reset_fade_out_shape_width (tmp->audio_region()->fade_out()->back()->when);
- tmp->hide_fade_line();
+ tmp->reset_fade_out_shape_width (tmp->audio_region(), tmp->audio_region()->fade_out()->back()->when);
}
}
_editor->verbose_cursor()->show ();
+ _pushing = Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier);
+
if (!_point->can_slide ()) {
_x_constrained = true;
}
cx_frames = min (cx_frames, _point->line().maximum_time());
float const fraction = 1.0 - (cy / _point->line().height());
- bool const push = Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier);
- _point->line().drag_motion (_editor->frame_to_unit_unrounded (cx_frames), fraction, false, push);
+ _point->line().drag_motion (_editor->frame_to_unit_unrounded (cx_frames), fraction, false, _pushing, _final_index);
_editor->verbose_cursor()->set_text (_point->line().get_verbose_cursor_string (fraction));
}
motion (event, false);
}
- _point->line().end_drag ();
+ _point->line().end_drag (_pushing, _final_index);
_editor->session()->commit_reversible_command ();
}
cy = min ((double) _line->height(), cy);
double const fraction = 1.0 - (cy / _line->height());
- bool const push = !Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier);
+ uint32_t ignored;
/* we are ignoring x position for this drag, so we can just pass in anything */
- _line->drag_motion (0, fraction, true, push);
+ _line->drag_motion (0, fraction, true, false, ignored);
_editor->verbose_cursor()->set_text (_line->get_verbose_cursor_string (fraction));
}
LineDrag::finished (GdkEvent* event, bool)
{
motion (event, false);
- _line->end_drag ();
+ _line->end_drag (false, 0);
_editor->session()->commit_reversible_command ();
}
}
}
- if (do_deselect) {
+ /* do not deselect if Primary or Tertiary (toggle-select or
+ * extend-select are pressed.
+ */
+
+ if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier) &&
+ !Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier) &&
+ do_deselect) {
deselect_things ();
}
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);
}
}
_editor->stop_canvas_autoscroll ();
+ _editor->clicked_selection = 0;
}
void
for (list<Line>::iterator l = _lines.begin(); l != _lines.end(); ++l) {
float const f = y_fraction (l->line, _drags->current_pointer_y());
/* we are ignoring x position for this drag, so we can just pass in anything */
- l->line->drag_motion (0, f, true, false);
+ uint32_t ignored;
+ l->line->drag_motion (0, f, true, false, ignored);
show_verbose_cursor_text (l->line->get_verbose_cursor_relative_string (l->original_fraction, f));
}
}
motion (event, false);
for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
- i->line->end_drag ();
+ i->line->end_drag (false, 0);
}
_editor->session()->commit_reversible_command ();
, arv (rv)
, start (start_yn)
{
+ std::cout << ("CrossfadeEdgeDrag is DEPRECATED. See TrimDrag::preserve_fade_anchor") << endl;
}
void