- _editor->selection->set (new_views);
- }
-
- for (set<boost::shared_ptr<Playlist> >::iterator p = frozen_playlists.begin(); p != frozen_playlists.end(); ++p) {
- (*p)->thaw();
- }
-
- out:
- for (vector<StatefulDiffCommand*>::iterator i = sdc.begin(); i != sdc.end(); ++i) {
- _editor->session()->add_command (*i);
- }
-
- _editor->commit_reversible_command ();
-
- for (vector<RegionView*>::iterator x = copies.begin(); x != copies.end(); ++x) {
- delete *x;
- }
-}
-
-void
-RegionMoveDrag::aborted ()
-{
- if (_copy) {
-
- for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
- delete i->view;
- }
-
- _views.clear ();
-
- } else {
- RegionMotionDrag::aborted ();
- }
-}
-
-void
-RegionMotionDrag::aborted ()
-{
- for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
- RegionView* rv = i->view;
- TimeAxisView* tv = &(rv->get_time_axis_view ());
- RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
- assert (rtv);
- rv->get_canvas_group()->reparent (*rtv->view()->canvas_item());
- rv->get_canvas_group()->property_y() = 0;
- rv->get_time_axis_view().reveal_dependent_views (*rv);
- rv->fake_set_opaque (false);
- rv->move (-_total_x_delta, 0);
- rv->set_height (rtv->view()->child_height ());
- }
-
- _editor->update_canvas_now ();
-}
-
-
-bool
-RegionMotionDrag::x_move_allowed () const
-{
- if (Config->get_edit_mode() == Lock) {
- /* in locked edit mode, reverse the usual meaning of _x_constrained */
- return _x_constrained;
- }
-
- return !_x_constrained;
-}
-
-void
-RegionMotionDrag::copy_regions (GdkEvent* event)
-{
- /* duplicate the regionview(s) and region(s) */
-
- list<DraggingView> new_regionviews;
-
- for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
-
- RegionView* rv = i->view;
- AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
- MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(rv);
-
- const boost::shared_ptr<const Region> original = rv->region();
- boost::shared_ptr<Region> region_copy = RegionFactory::create (original);
- region_copy->set_position (original->position(), this);
-
- RegionView* nrv;
- if (arv) {
- boost::shared_ptr<AudioRegion> audioregion_copy
- = boost::dynamic_pointer_cast<AudioRegion>(region_copy);
-
- nrv = new AudioRegionView (*arv, audioregion_copy);
- } else if (mrv) {
- boost::shared_ptr<MidiRegion> midiregion_copy
- = boost::dynamic_pointer_cast<MidiRegion>(region_copy);
- nrv = new MidiRegionView (*mrv, midiregion_copy);
- } else {
- continue;
- }
-
- nrv->get_canvas_group()->show ();
- new_regionviews.push_back (DraggingView (nrv));
-
- /* swap _primary to the copy */
-
- if (rv == _primary) {
- _primary = nrv;
- }
-
- /* ..and deselect the one we copied */
-
- rv->set_selected (false);
- }
-
- if (new_regionviews.empty()) {
- return;
- }
-
- /* reflect the fact that we are dragging the copies */
-
- _views = new_regionviews;
-
- swap_grab (new_regionviews.front().view->get_canvas_group (), 0, event ? event->motion.time : 0);
-
- /*
- sync the canvas to what we think is its current state
- without it, the canvas seems to
- "forget" to update properly after the upcoming reparent()
- ..only if the mouse is in rapid motion at the time of the grab.
- something to do with regionview creation taking so long?
- */
- _editor->update_canvas_now();
-}
-
-bool
-RegionMotionDrag::check_possible (RouteTimeAxisView** tv, layer_t* layer)
-{
- /* Which trackview is this ? */
-
- pair<TimeAxisView*, int> const tvp = _editor->trackview_by_y_position (_drags->current_pointer_y ());
- (*tv) = dynamic_cast<RouteTimeAxisView*> (tvp.first);
- (*layer) = tvp.second;
-
- if (*tv && (*tv)->layer_display() == Overlaid) {
- *layer = 0;
- }
-
- /* The region motion is only processed if the pointer is over
- an audio track.
- */
-
- if (!(*tv) || !(*tv)->is_track()) {
- /* To make sure we hide the verbose canvas cursor when the mouse is
- not held over and audiotrack.
- */
- _editor->hide_verbose_canvas_cursor ();
- return false;