Try to make new layering stuff play nicely with undo.

git-svn-id: svn://localhost/ardour2/branches/3.0@11097 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2011-12-27 20:21:00 +00:00
parent 86cb9348e8
commit f440f91849
5 changed files with 113 additions and 7 deletions

View File

@ -1099,6 +1099,15 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void toggle_solo_isolate ();
void toggle_mute ();
void toggle_region_lock_style ();
enum LayerOperation {
Raise,
RaiseToTop,
Lower,
LowerToBottom
};
void do_layer_operation (LayerOperation);
void raise_region ();
void raise_region_to_top ();
void change_region_layering_order (bool from_context_menu);

View File

@ -2133,28 +2133,101 @@ Editor::loop_location (Location& location)
}
}
void
Editor::do_layer_operation (LayerOperation op)
{
if (selection->regions.empty ()) {
return;
}
bool const multiple = selection->regions.size() > 1;
switch (op) {
case Raise:
if (multiple) {
begin_reversible_command (_("raise regions"));
} else {
begin_reversible_command (_("raise region"));
}
break;
case RaiseToTop:
if (multiple) {
begin_reversible_command (_("raise regions to top"));
} else {
begin_reversible_command (_("raise region to top"));
}
break;
case Lower:
if (multiple) {
begin_reversible_command (_("lower regions"));
} else {
begin_reversible_command (_("lower region"));
}
break;
case LowerToBottom:
if (multiple) {
begin_reversible_command (_("lower regions to bottom"));
} else {
begin_reversible_command (_("lower region"));
}
break;
}
set<boost::shared_ptr<Playlist> > playlists = selection->regions.playlists ();
for (set<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
(*i)->clear_owned_changes ();
}
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
boost::shared_ptr<Region> r = (*i)->region ();
switch (op) {
case Raise:
r->raise ();
break;
case RaiseToTop:
r->raise_to_top ();
break;
case Lower:
r->lower ();
break;
case LowerToBottom:
r->lower_to_bottom ();
}
}
for (set<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
vector<Command*> cmds;
(*i)->rdiff (cmds);
_session->add_commands (cmds);
}
commit_reversible_command ();
}
void
Editor::raise_region ()
{
selection->foreach_region (&Region::raise);
do_layer_operation (Raise);
}
void
Editor::raise_region_to_top ()
{
selection->foreach_region (&Region::raise_to_top);
do_layer_operation (RaiseToTop);
}
void
Editor::lower_region ()
{
selection->foreach_region (&Region::lower);
do_layer_operation (Lower);
}
void
Editor::lower_region_to_bottom ()
{
selection->foreach_region (&Region::lower_to_bottom);
do_layer_operation (LowerToBottom);
}
/** Show the region editor for the selected regions */

View File

@ -274,3 +274,15 @@ RegionSelection::end_frame () const
return e;
}
/** @return the playlists that the regions in the selection are on */
set<boost::shared_ptr<Playlist> >
RegionSelection::playlists () const
{
set<boost::shared_ptr<Playlist> > pl;
for (RegionSelection::const_iterator i = begin(); i != end(); ++i) {
pl.insert ((*i)->region()->playlist ());
}
return pl;
}

View File

@ -25,6 +25,10 @@
#include "pbd/signals.h"
#include "ardour/types.h"
namespace ARDOUR {
class Playlist;
}
class RegionView;
class TimeAxisView;
@ -57,6 +61,8 @@ class RegionSelection : public std::list<RegionView*>
void by_position (std::list<RegionView*>&) const;
void by_track (std::list<RegionView*>&) const;
std::set<boost::shared_ptr<ARDOUR::Playlist> > playlists () const;
private:
void remove_it (RegionView*);

View File

@ -646,10 +646,14 @@ Playlist::flush_notifications (bool from_undo)
RegionsExtended (pending_region_extensions);
}
if (!regions_to_relayer.empty ()) {
if (!regions_to_relayer.empty () && !from_undo) {
relayer (regions_to_relayer);
}
if (pending_layering) {
LayeringChanged (); /* EMIT SIGNAL */
}
clear_pending ();
in_flush = false;
@ -1571,6 +1575,10 @@ Playlist::flush_notifications (bool from_undo)
notify_region_start_trimmed (region);
}
if (what_changed.contains (Properties::layer)) {
notify_layering_changed ();
}
if (what_changed.contains (our_interests)) {
save = true;
}
@ -2536,8 +2544,6 @@ Playlist::commit_temporary_layers (TemporaryLayers const & temporary_layers)
DEBUG_TRACE (DEBUG::Layering, string_compose ("\t%1 temporary %2 committed %3\n", (*i)->name(), temporary_layers.get (*i), (*i)->layer()));
}
notify_layering_changed ();
}
/** Relayer a list of regions.