[Summary] Introducing the reworks in part of editor's command to keep implementation of undoable commands in form of special methods. Intention is to keep the code easy to maintain and "implement new things". As well all the command names for Undo/Redo menu items should be assured in terms of TRACKs.

This commit is contained in:
VKamyshniy 2015-02-19 01:50:10 +02:00
parent fdc72c1894
commit b20f4eaf8c
5 changed files with 108 additions and 30 deletions

View file

@ -174,6 +174,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void undo (uint32_t n = 1);
void redo (uint32_t n = 1);
// UNDOable commands:
void move_markers_command (std::list<Marker*>&, const std::list<ARDOUR::Location*>&);
XMLNode& get_state ();
int set_state (const XMLNode&, int version);

View file

@ -3710,32 +3710,7 @@ MarkerDrag::finished (GdkEvent* event, bool movement_occurred)
}
_editor->_dragging_edit_point = false;
XMLNode &before = _editor->session()->locations()->get_state();
MarkerSelection::iterator i;
CopiedLocationInfo::iterator x;
for (i = _editor->selection->markers.begin(), x = _copied_locations.begin();
x != _copied_locations.end() && i != _editor->selection->markers.end();
++i, ++x) {
Location* location = (*i)->location ();
Location* copy = (*x).location;
if (location && !location->locked()) {
if (location->is_mark()) {
location->set_start (copy->start());
} else {
location->set (copy->start(), copy->end());
}
}
}
_editor->begin_reversible_command ( _("move marker") );
XMLNode &after = _editor->session()->locations()->get_state();
_editor->session()->add_command(new MementoCommand<Locations>(*(_editor->session()->locations()), &before, &after));
_editor->commit_reversible_command ();
_editor->move_markers_command (_editor->selection->markers, _copied_locations.locations ());
}
void

View file

@ -814,12 +814,24 @@ private:
CopiedLocationMarkerInfo (ARDOUR::Location* l, Marker* m);
};
typedef std::list<CopiedLocationMarkerInfo> CopiedLocationInfo;
CopiedLocationInfo _copied_locations;
class CopiedLocationInfo : public std::list<CopiedLocationMarkerInfo>
{
public:
std::list<ARDOUR::Location*> locations () {
std::list<ARDOUR::Location*> result;
for (std::list<CopiedLocationMarkerInfo>::iterator i = begin ();
i != end ();
++i) {
result.push_back ((*i).location);
}
return result;
}
};
CopiedLocationInfo _copied_locations;
void show_drag_text (ARDOUR::Location*) const;
void show_drag_text (ARDOUR::Location*) const;
static sigc::connection timeout_connection;
static sigc::connection timeout_connection;
};
/** Control point drag */

View file

@ -0,0 +1,86 @@
/*
Copyright (C) 2000-2015 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gio/gio.h>
#include <gtk/gtkiconfactory.h>
#include "pbd/memento_command.h"
#include "pbd/file_utils.h"
#include "gtkmm2ext/utils.h"
#include "ardour/filesystem_paths.h"
#include "ardour/profile.h"
#include "ardour/session.h"
#include "ardour/types.h"
#include "canvas/canvas.h"
#include "canvas/pixbuf.h"
#include "actions.h"
#include "ardour_ui.h"
#include "editing.h"
#include "editor.h"
#include "gui_thread.h"
#include "time_axis_view.h"
#include "utils.h"
#include "i18n.h"
void
Editor::move_markers_command (std::list<Marker*>&markers, const std::list<ARDOUR::Location*>& locations)
{
const size_t markers_count = markers.size ();
if (markers_count != locations.size ()) {
WavesMessageDialog (_("Move Markers"), _("MOVE MARKERS: Invalid argument!")).run ();
return;
}
std::list<Marker*>::iterator mi;
std::list<ARDOUR::Location*>::const_iterator li;
for (mi = markers.begin (); mi != markers.end (); ++mi) {
ARDOUR::Location* location = (*mi)->location ();
if (location && !location->locked ()) {
break;
}
}
if (mi == markers.end ()) {
return;
}
begin_reversible_command (_("move marker"));
XMLNode &before = session()->locations()->get_state();
for (mi = markers.begin (), li = locations.begin (); mi != markers.end (); ++mi, ++li) {
ARDOUR::Location* location = (*mi)->location ();
ARDOUR::Location* copy = (*li);
if (location && !location->locked()) {
if (location->is_mark()) {
location->set_start (copy->start());
} else {
location->set (copy->start(), copy->end());
}
}
}
XMLNode &after = session()->locations()->get_state();
session()->add_command(new MementoCommand<ARDOUR::Locations>(*(session()->locations()), &before, &after));
commit_reversible_command ();
}

View file

@ -95,6 +95,7 @@ gtk2_ardour_sources = [
'edit_note_dialog.cc',
'editing.cc',
'editor.cc',
'editor_undoable.cc',
'editor_actions.cc',
'editor_audio_import.cc',
'editor_audiotrack.cc',