use RegionCommand for same-track region drags

git-svn-id: svn://localhost/ardour2/branches/3.0@6653 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2010-02-08 19:41:43 +00:00
parent e2baff4f7d
commit 30dd55bccd
4 changed files with 14 additions and 10 deletions

View file

@ -661,7 +661,7 @@ AudioStreamView::update_rec_regions ()
region->freeze (); region->freeze ();
region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this); region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this);
region->set_length (nlen, this); region->set_length (nlen, this);
region->thaw ("updated"); region->thaw ();
if (origlen == 1) { if (origlen == 1) {
/* our special initial length */ /* our special initial length */
@ -686,7 +686,7 @@ AudioStreamView::update_rec_regions ()
region->freeze (); region->freeze ();
region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this); region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this);
region->set_length (nlen, this); region->set_length (nlen, this);
region->thaw ("updated"); region->thaw ();
if (origlen == 1) { if (origlen == 1) {
/* our special initial length */ /* our special initial length */

View file

@ -22,6 +22,7 @@
#include "pbd/memento_command.h" #include "pbd/memento_command.h"
#include "pbd/basename.h" #include "pbd/basename.h"
#include "ardour/diskstream.h" #include "ardour/diskstream.h"
#include "ardour/region_command.h"
#include "ardour/session.h" #include "ardour/session.h"
#include "ardour/dB.h" #include "ardour/dB.h"
#include "ardour/region_factory.h" #include "ardour/region_factory.h"
@ -949,6 +950,8 @@ RegionMoveDrag::finished (GdkEvent* /*event*/, bool movement_occurred)
} }
} else { } else {
RegionCommand* rcmd = new RegionCommand (rv->region());
/* /*
motion on the same track. plonk the previously reparented region motion on the same track. plonk the previously reparented region
back to its original canvas group (its streamview). back to its original canvas group (its streamview).
@ -962,10 +965,12 @@ RegionMoveDrag::finished (GdkEvent* /*event*/, bool movement_occurred)
/* just change the model */ /* just change the model */
boost::shared_ptr<Playlist> playlist = dest_rtv->playlist(); boost::shared_ptr<Playlist> playlist = dest_rtv->playlist();
if (dest_rtv->view()->layer_display() == Stacked) { if (dest_rtv->view()->layer_display() == Stacked) {
layer_t old_layer = rv->region()->layer();
rv->region()->set_layer (dest_layer); rv->region()->set_layer (dest_layer);
rv->region()->set_pending_explicit_relayer (true); rv->region()->set_pending_explicit_relayer (true);
rcmd->add_property_change (RegionCommand::Layer, old_layer, dest_layer);
} }
/* freeze playlist to avoid lots of relayering in the case of a multi-region drag */ /* freeze playlist to avoid lots of relayering in the case of a multi-region drag */
@ -976,10 +981,11 @@ RegionMoveDrag::finished (GdkEvent* /*event*/, bool movement_occurred)
playlist->freeze(); playlist->freeze();
} }
XMLNode& before (rv->region()->get_state()); nframes64_t old_pos = rv->region()->position();
rv->region()->set_position (where, (void*) this); rv->region()->set_position (where, (void*) this);
_editor->session()->add_command (new MementoCommand<Region>(*rv->region(), &before, &playlist->get_state())); rcmd->add_property_change (RegionCommand::Position, old_pos, where);
_editor->session()->add_command (rcmd);
} }
if (changed_tracks && !_copy) { if (changed_tracks && !_copy) {

View file

@ -2354,7 +2354,7 @@ Editor::thaw_region_after_trim (RegionView& rv)
return; return;
} }
region->thaw (_("trimmed region")); region->thaw ();
AudioRegionView* arv = dynamic_cast<AudioRegionView*>(&rv); AudioRegionView* arv = dynamic_cast<AudioRegionView*>(&rv);
@ -2488,8 +2488,6 @@ Editor::add_region_drag (ArdourCanvas::Item* item, GdkEvent* event, RegionView*
_drags->add (new RegionMoveDrag (this, item, region_view, s.by_layer(), false, false)); _drags->add (new RegionMoveDrag (this, item, region_view, s.by_layer(), false, false));
} }
begin_reversible_command (_("move region(s)"));
/* sync the canvas to what we think is its current state */ /* sync the canvas to what we think is its current state */
update_canvas_now(); update_canvas_now();
} }

View file

@ -554,7 +554,7 @@ MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, nframes_t
region->freeze (); region->freeze ();
region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this); region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this);
region->set_length (start + dur - region->position(), this); region->set_length (start + dur - region->position(), this);
region->thaw ("updated"); region->thaw ();
if (origlen == 1) { if (origlen == 1) {
/* our special initial length */ /* our special initial length */
@ -618,7 +618,7 @@ MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, nframes_t
region->freeze (); region->freeze ();
region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this); region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this);
region->set_length (nlen, this); region->set_length (nlen, this);
region->thaw ("updated"); region->thaw ();
if (origlen == 1) { if (origlen == 1) {
/* our special initial length */ /* our special initial length */