Remove unnecessary _have_transaction flag in TrimDrag. Fix undo when a trim of one region affects the previous or next regions too (#3632).
git-svn-id: svn://localhost/ardour2/branches/3.0@8348 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
3d0c3ffb6a
commit
84b4dd94e3
@ -339,7 +339,7 @@ Drag::abort ()
|
||||
_item->ungrab (0);
|
||||
}
|
||||
|
||||
aborted ();
|
||||
aborted (_move_threshold_passed);
|
||||
|
||||
_editor->stop_canvas_autoscroll ();
|
||||
_editor->hide_verbose_canvas_cursor ();
|
||||
@ -1133,7 +1133,7 @@ RegionMoveDrag::add_stateful_diff_commands_for_playlists (PlaylistSet const & pl
|
||||
|
||||
|
||||
void
|
||||
RegionMoveDrag::aborted ()
|
||||
RegionMoveDrag::aborted (bool movement_occurred)
|
||||
{
|
||||
if (_copy) {
|
||||
|
||||
@ -1144,12 +1144,12 @@ RegionMoveDrag::aborted ()
|
||||
_views.clear ();
|
||||
|
||||
} else {
|
||||
RegionMotionDrag::aborted ();
|
||||
RegionMotionDrag::aborted (movement_occurred);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RegionMotionDrag::aborted ()
|
||||
RegionMotionDrag::aborted (bool)
|
||||
{
|
||||
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
||||
RegionView* rv = i->view;
|
||||
@ -1231,7 +1231,7 @@ RegionInsertDrag::finished (GdkEvent *, bool)
|
||||
}
|
||||
|
||||
void
|
||||
RegionInsertDrag::aborted ()
|
||||
RegionInsertDrag::aborted (bool)
|
||||
{
|
||||
delete _primary;
|
||||
_primary = 0;
|
||||
@ -1330,7 +1330,7 @@ RegionSpliceDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
RegionSpliceDrag::aborted ()
|
||||
RegionSpliceDrag::aborted (bool)
|
||||
{
|
||||
/* XXX: TODO */
|
||||
}
|
||||
@ -1391,7 +1391,7 @@ RegionCreateDrag::add_region ()
|
||||
}
|
||||
|
||||
void
|
||||
RegionCreateDrag::aborted ()
|
||||
RegionCreateDrag::aborted (bool)
|
||||
{
|
||||
/* XXX */
|
||||
}
|
||||
@ -1479,7 +1479,7 @@ NoteResizeDrag::finished (GdkEvent*, bool /*movement_occurred*/)
|
||||
}
|
||||
|
||||
void
|
||||
NoteResizeDrag::aborted ()
|
||||
NoteResizeDrag::aborted (bool)
|
||||
{
|
||||
/* XXX: TODO */
|
||||
}
|
||||
@ -1503,14 +1503,13 @@ RegionGainDrag::finished (GdkEvent *, bool)
|
||||
}
|
||||
|
||||
void
|
||||
RegionGainDrag::aborted ()
|
||||
RegionGainDrag::aborted (bool)
|
||||
{
|
||||
/* XXX: TODO */
|
||||
}
|
||||
|
||||
TrimDrag::TrimDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v)
|
||||
: RegionDrag (e, i, p, v)
|
||||
, _have_transaction (false)
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::Drags, "New TrimDrag\n");
|
||||
}
|
||||
@ -1602,13 +1601,12 @@ TrimDrag::motion (GdkEvent* event, bool first_move)
|
||||
}
|
||||
|
||||
_editor->begin_reversible_command (trim_type);
|
||||
_have_transaction = true;
|
||||
|
||||
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
||||
RegionView* rv = i->view;
|
||||
rv->fake_set_opaque (false);
|
||||
rv->enable_display (false);
|
||||
rv->region()->clear_changes ();
|
||||
rv->region()->playlist()->clear_owned_changes ();
|
||||
|
||||
AudioRegionView* const arv = dynamic_cast<AudioRegionView*> (rv);
|
||||
|
||||
@ -1706,12 +1704,24 @@ TrimDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
_primary->thaw_after_trim ();
|
||||
} else {
|
||||
|
||||
set<boost::shared_ptr<Playlist> > diffed_playlists;
|
||||
|
||||
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
||||
i->view->thaw_after_trim ();
|
||||
i->view->enable_display (true);
|
||||
i->view->fake_set_opaque (true);
|
||||
if (_have_transaction) {
|
||||
_editor->session()->add_command (new StatefulDiffCommand (i->view->region()));
|
||||
|
||||
/* Trimming one region may affect others on the playlist, so we need
|
||||
to get undo Commands from the whole playlist rather than just the
|
||||
region. Use diffed_playlists to make sure we don't diff a given
|
||||
playlist more than once.
|
||||
*/
|
||||
boost::shared_ptr<Playlist> p = i->view->region()->playlist ();
|
||||
if (diffed_playlists.find (p) == diffed_playlists.end()) {
|
||||
vector<Command*> cmds;
|
||||
p->rdiff (cmds);
|
||||
_editor->session()->add_commands (cmds);
|
||||
diffed_playlists.insert (p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1720,9 +1730,7 @@ TrimDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
}
|
||||
|
||||
_editor->motion_frozen_playlists.clear ();
|
||||
if (_have_transaction) {
|
||||
_editor->commit_reversible_command();
|
||||
}
|
||||
|
||||
} else {
|
||||
/* no mouse movement */
|
||||
@ -1739,7 +1747,7 @@ TrimDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
TrimDrag::aborted ()
|
||||
TrimDrag::aborted (bool movement_occurred)
|
||||
{
|
||||
/* Our motion method is changing model state, so use the Undo system
|
||||
to cancel. Perhaps not ideal, as this will leave an Undo point
|
||||
@ -1748,7 +1756,7 @@ TrimDrag::aborted ()
|
||||
|
||||
finished (0, true);
|
||||
|
||||
if (_have_transaction) {
|
||||
if (movement_occurred) {
|
||||
_editor->undo ();
|
||||
}
|
||||
|
||||
@ -1879,7 +1887,7 @@ MeterMarkerDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
MeterMarkerDrag::aborted ()
|
||||
MeterMarkerDrag::aborted (bool)
|
||||
{
|
||||
_marker->set_position (_marker->meter().frame ());
|
||||
}
|
||||
@ -1973,7 +1981,7 @@ TempoMarkerDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
TempoMarkerDrag::aborted ()
|
||||
TempoMarkerDrag::aborted (bool)
|
||||
{
|
||||
_marker->set_position (_marker->tempo().frame());
|
||||
}
|
||||
@ -2071,7 +2079,7 @@ CursorDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
CursorDrag::aborted ()
|
||||
CursorDrag::aborted (bool)
|
||||
{
|
||||
if (_editor->_dragging_playhead) {
|
||||
_editor->session()->request_resume_timecode_transmission ();
|
||||
@ -2186,7 +2194,7 @@ FadeInDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
FadeInDrag::aborted ()
|
||||
FadeInDrag::aborted (bool)
|
||||
{
|
||||
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
||||
AudioRegionView* tmp = dynamic_cast<AudioRegionView*> (i->view);
|
||||
@ -2309,7 +2317,7 @@ FadeOutDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
FadeOutDrag::aborted ()
|
||||
FadeOutDrag::aborted (bool)
|
||||
{
|
||||
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
||||
AudioRegionView* tmp = dynamic_cast<AudioRegionView*> (i->view);
|
||||
@ -2646,7 +2654,7 @@ MarkerDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
MarkerDrag::aborted ()
|
||||
MarkerDrag::aborted (bool)
|
||||
{
|
||||
/* XXX: TODO */
|
||||
}
|
||||
@ -2769,7 +2777,7 @@ ControlPointDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
ControlPointDrag::aborted ()
|
||||
ControlPointDrag::aborted (bool)
|
||||
{
|
||||
_point->line().reset ();
|
||||
}
|
||||
@ -2879,7 +2887,7 @@ LineDrag::finished (GdkEvent* event, bool)
|
||||
}
|
||||
|
||||
void
|
||||
LineDrag::aborted ()
|
||||
LineDrag::aborted (bool)
|
||||
{
|
||||
_line->reset ();
|
||||
}
|
||||
@ -2949,7 +2957,7 @@ FeatureLineDrag::finished (GdkEvent*, bool)
|
||||
}
|
||||
|
||||
void
|
||||
FeatureLineDrag::aborted ()
|
||||
FeatureLineDrag::aborted (bool)
|
||||
{
|
||||
//_line->reset ();
|
||||
}
|
||||
@ -3063,7 +3071,7 @@ RubberbandSelectDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
RubberbandSelectDrag::aborted ()
|
||||
RubberbandSelectDrag::aborted (bool)
|
||||
{
|
||||
_editor->rubberband_rect->hide ();
|
||||
}
|
||||
@ -3134,7 +3142,7 @@ TimeFXDrag::finished (GdkEvent* /*event*/, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
TimeFXDrag::aborted ()
|
||||
TimeFXDrag::aborted (bool)
|
||||
{
|
||||
_primary->get_time_axis_view().hide_timestretch ();
|
||||
}
|
||||
@ -3167,7 +3175,7 @@ ScrubDrag::finished (GdkEvent* /*event*/, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
ScrubDrag::aborted ()
|
||||
ScrubDrag::aborted (bool)
|
||||
{
|
||||
/* XXX: TODO */
|
||||
}
|
||||
@ -3435,7 +3443,7 @@ SelectionDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
SelectionDrag::aborted ()
|
||||
SelectionDrag::aborted (bool)
|
||||
{
|
||||
/* XXX: TODO */
|
||||
}
|
||||
@ -3641,7 +3649,7 @@ RangeMarkerBarDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
RangeMarkerBarDrag::aborted ()
|
||||
RangeMarkerBarDrag::aborted (bool)
|
||||
{
|
||||
/* XXX: TODO */
|
||||
}
|
||||
@ -3729,7 +3737,7 @@ MouseZoomDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
MouseZoomDrag::aborted ()
|
||||
MouseZoomDrag::aborted (bool)
|
||||
{
|
||||
_editor->zoom_rect->hide ();
|
||||
}
|
||||
@ -3871,7 +3879,7 @@ NoteDrag::finished (GdkEvent* ev, bool moved)
|
||||
}
|
||||
|
||||
void
|
||||
NoteDrag::aborted ()
|
||||
NoteDrag::aborted (bool)
|
||||
{
|
||||
/* XXX: TODO */
|
||||
}
|
||||
@ -4074,7 +4082,7 @@ AutomationRangeDrag::finished (GdkEvent* event, bool)
|
||||
}
|
||||
|
||||
void
|
||||
AutomationRangeDrag::aborted ()
|
||||
AutomationRangeDrag::aborted (bool)
|
||||
{
|
||||
for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
|
||||
i->line->clear_always_in_view ();
|
||||
@ -4136,7 +4144,7 @@ PatchChangeDrag::finished (GdkEvent* ev, bool movement_occurred)
|
||||
}
|
||||
|
||||
void
|
||||
PatchChangeDrag::aborted ()
|
||||
PatchChangeDrag::aborted (bool)
|
||||
{
|
||||
_patch_change->move (-_cumulative_dx, 0);
|
||||
}
|
||||
|
@ -147,8 +147,9 @@ public:
|
||||
|
||||
/** Called to abort a drag and return things to how
|
||||
* they were before it started.
|
||||
* @param m true if some movement occurred, otherwise false.
|
||||
*/
|
||||
virtual void aborted () = 0;
|
||||
virtual void aborted (bool m) = 0;
|
||||
|
||||
/** @param m Mouse mode.
|
||||
* @return true if this drag should happen in this mouse mode.
|
||||
@ -289,7 +290,7 @@ public:
|
||||
virtual void start_grab (GdkEvent *, Gdk::Cursor *);
|
||||
virtual void motion (GdkEvent *, bool);
|
||||
virtual void finished (GdkEvent *, bool) = 0;
|
||||
virtual void aborted ();
|
||||
virtual void aborted (bool);
|
||||
|
||||
/** @return true if the regions being `moved' came from somewhere on the canvas;
|
||||
* false if they came from outside (e.g. from the region list).
|
||||
@ -320,7 +321,7 @@ public:
|
||||
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool regions_came_from_canvas () const {
|
||||
return true;
|
||||
@ -376,7 +377,7 @@ public:
|
||||
RegionInsertDrag (Editor *, boost::shared_ptr<ARDOUR::Region>, RouteTimeAxisView*, ARDOUR::framepos_t);
|
||||
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool regions_came_from_canvas () const {
|
||||
return false;
|
||||
@ -391,7 +392,7 @@ public:
|
||||
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
};
|
||||
|
||||
/** Drags to create regions */
|
||||
@ -402,7 +403,7 @@ public:
|
||||
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
private:
|
||||
MidiTimeAxisView* _view;
|
||||
@ -419,7 +420,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
private:
|
||||
MidiRegionView* region;
|
||||
@ -436,7 +437,7 @@ class NoteDrag : public Drag
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
private:
|
||||
|
||||
@ -459,7 +460,7 @@ public:
|
||||
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool y_movement_matters () const {
|
||||
return false;
|
||||
@ -485,7 +486,7 @@ public:
|
||||
return (m == Editing::MouseGain);
|
||||
}
|
||||
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
};
|
||||
|
||||
/** Drag to trim region(s) */
|
||||
@ -503,7 +504,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool y_movement_matters () const {
|
||||
return false;
|
||||
@ -514,7 +515,6 @@ public:
|
||||
private:
|
||||
|
||||
Operation _operation;
|
||||
bool _have_transaction; ///< true if a transaction has been started, false otherwise. Must be set true by derived class.
|
||||
};
|
||||
|
||||
/** Meter marker drag */
|
||||
@ -526,7 +526,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool allow_vertical_autoscroll () const {
|
||||
return false;
|
||||
@ -552,7 +552,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool allow_vertical_autoscroll () const {
|
||||
return false;
|
||||
@ -579,7 +579,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool active (Editing::MouseMode) {
|
||||
return true;
|
||||
@ -608,7 +608,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool y_movement_matters () const {
|
||||
return false;
|
||||
@ -626,7 +626,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool y_movement_matters () const {
|
||||
return false;
|
||||
@ -645,7 +645,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool allow_vertical_autoscroll () const {
|
||||
return false;
|
||||
@ -675,7 +675,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool active (Editing::MouseMode m);
|
||||
|
||||
@ -698,7 +698,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool active (Editing::MouseMode) {
|
||||
return true;
|
||||
@ -723,7 +723,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool active (Editing::MouseMode) {
|
||||
return true;
|
||||
@ -750,7 +750,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
|
||||
return std::make_pair (8, 1);
|
||||
@ -766,7 +766,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
};
|
||||
|
||||
/** Scrub drag in audition mode */
|
||||
@ -778,7 +778,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
};
|
||||
|
||||
/** Drag in range select mode */
|
||||
@ -797,7 +797,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
void setup_pointer_frame_offset ();
|
||||
|
||||
@ -824,7 +824,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool allow_vertical_autoscroll () const {
|
||||
return false;
|
||||
@ -851,7 +851,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
|
||||
return std::make_pair (4, 4);
|
||||
@ -870,7 +870,7 @@ public:
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
void finished (GdkEvent *, bool);
|
||||
void aborted ();
|
||||
void aborted (bool);
|
||||
|
||||
bool x_movement_matters () const {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user