mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 08:36:32 +01:00
add begin/end undo/redo signals so that playlist can freeze/thaw itself around potentially NxM region property changes; clean up debug output; don't connect streamview to Playlist::ContentsChanged because there appears to be no need for it - we catch add/remove region, and region property changes are handled by RegionView
git-svn-id: svn://localhost/ardour2/branches/3.0@6702 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
fa701b8c06
commit
d9d1a4a5cf
8 changed files with 95 additions and 56 deletions
|
|
@ -254,19 +254,13 @@ AudioStreamView::playlist_layered (boost::weak_ptr<Diskstream> wds)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cerr << "AS, call SV::modified @ " << get_microseconds() << endl;
|
|
||||||
|
|
||||||
StreamView::playlist_layered (wds);
|
StreamView::playlist_layered (wds);
|
||||||
|
|
||||||
cerr << "AS, done with SV::modified @ " << get_microseconds() << endl;
|
|
||||||
|
|
||||||
/* make sure xfades are on top and all the regionviews are stacked correctly. */
|
/* make sure xfades are on top and all the regionviews are stacked correctly. */
|
||||||
|
|
||||||
cerr << "AS, raise xfades @ " << get_microseconds() << endl;
|
|
||||||
for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) {
|
for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) {
|
||||||
i->second->get_canvas_group()->raise_to_top();
|
i->second->get_canvas_group()->raise_to_top();
|
||||||
}
|
}
|
||||||
cerr << "AS, done with xfades @ " << get_microseconds() << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,7 @@ StreamView::playlist_switched (boost::weak_ptr<Diskstream> wds)
|
||||||
ds->playlist()->LayeringChanged.connect (playlist_connections, boost::bind (&StreamView::playlist_layered, this, boost::weak_ptr<Diskstream>(ds)), gui_context());
|
ds->playlist()->LayeringChanged.connect (playlist_connections, boost::bind (&StreamView::playlist_layered, this, boost::weak_ptr<Diskstream>(ds)), gui_context());
|
||||||
ds->playlist()->RegionAdded.connect (playlist_connections, ui_bind (&StreamView::add_region_view, this, _1), gui_context());
|
ds->playlist()->RegionAdded.connect (playlist_connections, ui_bind (&StreamView::add_region_view, this, _1), gui_context());
|
||||||
ds->playlist()->RegionRemoved.connect (playlist_connections, ui_bind (&StreamView::remove_region_view, this, _1), gui_context());
|
ds->playlist()->RegionRemoved.connect (playlist_connections, ui_bind (&StreamView::remove_region_view, this, _1), gui_context());
|
||||||
ds->playlist()->ContentsChanged.connect (playlist_connections, boost::bind (&StreamView::redisplay_diskstream, this), gui_context());
|
// ds->playlist()->ContentsChanged.connect (playlist_connections, boost::bind (&StreamView::redisplay_diskstream, this), gui_context());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -296,6 +296,8 @@ class Playlist : public SessionObject
|
||||||
int move_region_to_layer (layer_t, boost::shared_ptr<Region> r, int dir);
|
int move_region_to_layer (layer_t, boost::shared_ptr<Region> r, int dir);
|
||||||
void relayer ();
|
void relayer ();
|
||||||
|
|
||||||
|
void begin_undo ();
|
||||||
|
void end_undo ();
|
||||||
void unset_freeze_parent (Playlist*);
|
void unset_freeze_parent (Playlist*);
|
||||||
void unset_freeze_child (Playlist*);
|
void unset_freeze_child (Playlist*);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -625,8 +625,6 @@ AudioRegion::_set_state (const XMLNode& node, int version, PropertyChange& what_
|
||||||
_envelope->set_max_xval (_length);
|
_envelope->set_max_xval (_length);
|
||||||
_envelope->truncate_end (_length);
|
_envelope->truncate_end (_length);
|
||||||
|
|
||||||
cerr << _name << " envelope changd\n";
|
|
||||||
|
|
||||||
|
|
||||||
} else if (child->name() == "FadeIn") {
|
} else if (child->name() == "FadeIn") {
|
||||||
|
|
||||||
|
|
@ -648,7 +646,6 @@ AudioRegion::_set_state (const XMLNode& node, int version, PropertyChange& what_
|
||||||
set_fade_in_active (false);
|
set_fade_in_active (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cerr << _name << " fadein changd\n";
|
|
||||||
|
|
||||||
} else if (child->name() == "FadeOut") {
|
} else if (child->name() == "FadeOut") {
|
||||||
|
|
||||||
|
|
@ -670,7 +667,6 @@ AudioRegion::_set_state (const XMLNode& node, int version, PropertyChange& what_
|
||||||
set_fade_out_active (false);
|
set_fade_out_active (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cerr << _name << " fadeout changd\n";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,9 @@ Playlist::init (bool hide)
|
||||||
freeze_length = 0;
|
freeze_length = 0;
|
||||||
_explicit_relayering = false;
|
_explicit_relayering = false;
|
||||||
|
|
||||||
|
_session.history().BeginUndoRedo.connect_same_thread (*this, boost::bind (&Playlist::begin_undo, this));
|
||||||
|
_session.history().EndUndoRedo.connect_same_thread (*this, boost::bind (&Playlist::end_undo, this));
|
||||||
|
|
||||||
ContentsChanged.connect_same_thread (*this, boost::bind (&Playlist::mark_session_dirty, this));
|
ContentsChanged.connect_same_thread (*this, boost::bind (&Playlist::mark_session_dirty, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -320,6 +323,18 @@ Playlist::set_name (const string& str)
|
||||||
the lock (e.g. to read from the playlist).
|
the lock (e.g. to read from the playlist).
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
void
|
||||||
|
Playlist::begin_undo ()
|
||||||
|
{
|
||||||
|
freeze ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Playlist::end_undo ()
|
||||||
|
{
|
||||||
|
thaw ();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Playlist::freeze ()
|
Playlist::freeze ()
|
||||||
{
|
{
|
||||||
|
|
@ -357,9 +372,7 @@ Playlist::notify_contents_changed ()
|
||||||
pending_contents_change = true;
|
pending_contents_change = true;
|
||||||
} else {
|
} else {
|
||||||
pending_contents_change = false;
|
pending_contents_change = false;
|
||||||
cerr << _name << "send contents change @ " << get_microseconds() << endl;
|
|
||||||
ContentsChanged(); /* EMIT SIGNAL */
|
ContentsChanged(); /* EMIT SIGNAL */
|
||||||
cerr << _name << "done with cc @ " << get_microseconds() << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -370,9 +383,7 @@ Playlist::notify_layering_changed ()
|
||||||
pending_layering = true;
|
pending_layering = true;
|
||||||
} else {
|
} else {
|
||||||
pending_layering = false;
|
pending_layering = false;
|
||||||
cerr << _name << "send layering @ " << get_microseconds() << endl;
|
|
||||||
LayeringChanged(); /* EMIT SIGNAL */
|
LayeringChanged(); /* EMIT SIGNAL */
|
||||||
cerr << _name << "done with layering @ " << get_microseconds() << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -429,9 +440,7 @@ Playlist::notify_region_added (boost::shared_ptr<Region> r)
|
||||||
LengthChanged (); /* EMIT SIGNAL */
|
LengthChanged (); /* EMIT SIGNAL */
|
||||||
pending_contents_change = false;
|
pending_contents_change = false;
|
||||||
RegionAdded (boost::weak_ptr<Region> (r)); /* EMIT SIGNAL */
|
RegionAdded (boost::weak_ptr<Region> (r)); /* EMIT SIGNAL */
|
||||||
cerr << _name << "send3 contents changed @ " << get_microseconds() << endl;
|
|
||||||
ContentsChanged (); /* EMIT SIGNAL */
|
ContentsChanged (); /* EMIT SIGNAL */
|
||||||
cerr << _name << "done contents changed @ " << get_microseconds() << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -444,9 +453,7 @@ Playlist::notify_length_changed ()
|
||||||
pending_length = false;
|
pending_length = false;
|
||||||
LengthChanged(); /* EMIT SIGNAL */
|
LengthChanged(); /* EMIT SIGNAL */
|
||||||
pending_contents_change = false;
|
pending_contents_change = false;
|
||||||
cerr << _name << "send4 contents change @ " << get_microseconds() << endl;
|
|
||||||
ContentsChanged (); /* EMIT SIGNAL */
|
ContentsChanged (); /* EMIT SIGNAL */
|
||||||
cerr << _name << "done contents change @ " << get_microseconds() << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -491,12 +498,12 @@ Playlist::flush_notifications ()
|
||||||
|
|
||||||
for (s = pending_removes.begin(); s != pending_removes.end(); ++s) {
|
for (s = pending_removes.begin(); s != pending_removes.end(); ++s) {
|
||||||
remove_dependents (*s);
|
remove_dependents (*s);
|
||||||
cerr << _name << " sends RegionRemoved\n";
|
// cerr << _name << " sends RegionRemoved\n";
|
||||||
RegionRemoved (boost::weak_ptr<Region> (*s)); /* EMIT SIGNAL */
|
RegionRemoved (boost::weak_ptr<Region> (*s)); /* EMIT SIGNAL */
|
||||||
}
|
}
|
||||||
|
|
||||||
for (s = pending_adds.begin(); s != pending_adds.end(); ++s) {
|
for (s = pending_adds.begin(); s != pending_adds.end(); ++s) {
|
||||||
cerr << _name << " sends RegionAdded\n";
|
// cerr << _name << " sends RegionAdded\n";
|
||||||
RegionAdded (boost::weak_ptr<Region> (*s)); /* EMIT SIGNAL */
|
RegionAdded (boost::weak_ptr<Region> (*s)); /* EMIT SIGNAL */
|
||||||
dependent_checks_needed.insert (*s);
|
dependent_checks_needed.insert (*s);
|
||||||
}
|
}
|
||||||
|
|
@ -504,13 +511,13 @@ Playlist::flush_notifications ()
|
||||||
if (check_length) {
|
if (check_length) {
|
||||||
if (old_length != _get_maximum_extent()) {
|
if (old_length != _get_maximum_extent()) {
|
||||||
pending_length = true;
|
pending_length = true;
|
||||||
cerr << _name << " length has changed\n";
|
// cerr << _name << " length has changed\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pending_length || (freeze_length != _get_maximum_extent())) {
|
if (pending_length || (freeze_length != _get_maximum_extent())) {
|
||||||
pending_length = false;
|
pending_length = false;
|
||||||
cerr << _name << " sends LengthChanged\n";
|
// cerr << _name << " sends LengthChanged\n";
|
||||||
LengthChanged(); /* EMIT SIGNAL */
|
LengthChanged(); /* EMIT SIGNAL */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -519,9 +526,9 @@ Playlist::flush_notifications ()
|
||||||
relayer ();
|
relayer ();
|
||||||
}
|
}
|
||||||
pending_contents_change = false;
|
pending_contents_change = false;
|
||||||
cerr << _name << " sends 5 contents change @ " << get_microseconds() << endl;
|
// cerr << _name << " sends 5 contents change @ " << get_microseconds() << endl;
|
||||||
ContentsChanged (); /* EMIT SIGNAL */
|
ContentsChanged (); /* EMIT SIGNAL */
|
||||||
cerr << _name << "done contents change @ " << get_microseconds() << endl;
|
// cerr << _name << "done contents change @ " << get_microseconds() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (s = dependent_checks_needed.begin(); s != dependent_checks_needed.end(); ++s) {
|
for (s = dependent_checks_needed.begin(); s != dependent_checks_needed.end(); ++s) {
|
||||||
|
|
@ -529,7 +536,7 @@ Playlist::flush_notifications ()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pending_range_moves.empty ()) {
|
if (!pending_range_moves.empty ()) {
|
||||||
cerr << _name << " sends RangesMoved\n";
|
// cerr << _name << " sends RangesMoved\n";
|
||||||
RangesMoved (pending_range_moves);
|
RangesMoved (pending_range_moves);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1530,9 +1537,7 @@ Playlist::clear (bool with_signals)
|
||||||
pending_length = false;
|
pending_length = false;
|
||||||
LengthChanged ();
|
LengthChanged ();
|
||||||
pending_contents_change = false;
|
pending_contents_change = false;
|
||||||
cerr << _name << "send2 contents change @ " << get_microseconds() << endl;
|
|
||||||
ContentsChanged ();
|
ContentsChanged ();
|
||||||
cerr << _name << "done with contents changed @ " << get_microseconds() << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1144,8 +1144,6 @@ Region::_set_state (const XMLNode& node, int version, PropertyChange& what_chang
|
||||||
{
|
{
|
||||||
const XMLProperty* prop;
|
const XMLProperty* prop;
|
||||||
|
|
||||||
cerr << "about to call ::set_properties for an XMLNode\n";
|
|
||||||
|
|
||||||
what_changed = set_properties (node);
|
what_changed = set_properties (node);
|
||||||
|
|
||||||
if ((prop = node.property (X_("id")))) {
|
if ((prop = node.property (X_("id")))) {
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,8 @@ class UndoHistory : public PBD::ScopedConnectionList
|
||||||
void set_depth (uint32_t);
|
void set_depth (uint32_t);
|
||||||
|
|
||||||
PBD::Signal0<void> Changed;
|
PBD::Signal0<void> Changed;
|
||||||
|
PBD::Signal0<void> BeginUndoRedo;
|
||||||
|
PBD::Signal0<void> EndUndoRedo;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _clearing;
|
bool _clearing;
|
||||||
|
|
|
||||||
|
|
@ -122,25 +122,15 @@ UndoTransaction::operator() ()
|
||||||
void
|
void
|
||||||
UndoTransaction::undo ()
|
UndoTransaction::undo ()
|
||||||
{
|
{
|
||||||
struct timeval start, end, diff;
|
|
||||||
gettimeofday (&start, 0);
|
|
||||||
for (list<Command*>::reverse_iterator i = actions.rbegin(); i != actions.rend(); ++i) {
|
for (list<Command*>::reverse_iterator i = actions.rbegin(); i != actions.rend(); ++i) {
|
||||||
(*i)->undo();
|
(*i)->undo();
|
||||||
}
|
}
|
||||||
gettimeofday (&end, 0);
|
|
||||||
timersub (&end, &start, &diff);
|
|
||||||
cerr << "Undo took " << diff.tv_sec << '.' << diff.tv_usec << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UndoTransaction::redo ()
|
UndoTransaction::redo ()
|
||||||
{
|
{
|
||||||
struct timeval start, end, diff;
|
|
||||||
gettimeofday (&start, 0);
|
|
||||||
(*this)();
|
(*this)();
|
||||||
gettimeofday (&end, 0);
|
|
||||||
timersub (&end, &start, &diff);
|
|
||||||
cerr << "Undo took " << diff.tv_sec << '.' << diff.tv_usec << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLNode &UndoTransaction::get_state()
|
XMLNode &UndoTransaction::get_state()
|
||||||
|
|
@ -161,6 +151,20 @@ XMLNode &UndoTransaction::get_state()
|
||||||
return *node;
|
return *node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class UndoRedoSignaller {
|
||||||
|
public:
|
||||||
|
UndoRedoSignaller (UndoHistory& uh)
|
||||||
|
: _history (uh) {
|
||||||
|
_history.BeginUndoRedo();
|
||||||
|
}
|
||||||
|
~UndoRedoSignaller() {
|
||||||
|
_history.EndUndoRedo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
UndoHistory& _history;
|
||||||
|
};
|
||||||
|
|
||||||
UndoHistory::UndoHistory ()
|
UndoHistory::UndoHistory ()
|
||||||
{
|
{
|
||||||
_clearing = false;
|
_clearing = false;
|
||||||
|
|
@ -242,32 +246,70 @@ UndoHistory::remove (UndoTransaction* const ut)
|
||||||
void
|
void
|
||||||
UndoHistory::undo (unsigned int n)
|
UndoHistory::undo (unsigned int n)
|
||||||
{
|
{
|
||||||
while (n--) {
|
if (n == 0) {
|
||||||
if (UndoList.size() == 0) {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
UndoTransaction* ut = UndoList.back ();
|
|
||||||
UndoList.pop_back ();
|
|
||||||
ut->undo ();
|
|
||||||
RedoList.push_back (ut);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct timeval start, end, diff;
|
||||||
|
gettimeofday (&start, 0);
|
||||||
|
|
||||||
|
{
|
||||||
|
UndoRedoSignaller exception_safe_signaller (*this);
|
||||||
|
|
||||||
|
while (n--) {
|
||||||
|
if (UndoList.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UndoTransaction* ut = UndoList.back ();
|
||||||
|
UndoList.pop_back ();
|
||||||
|
ut->undo ();
|
||||||
|
RedoList.push_back (ut);
|
||||||
|
}
|
||||||
|
gettimeofday (&end, 0);
|
||||||
|
timersub (&end, &start, &diff);
|
||||||
|
cerr << "Undo-pre-signals took " << diff.tv_sec << '.' << diff.tv_usec << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
gettimeofday (&end, 0);
|
||||||
|
timersub (&end, &start, &diff);
|
||||||
|
cerr << "Undo took " << diff.tv_sec << '.' << diff.tv_usec << endl;
|
||||||
|
|
||||||
Changed (); /* EMIT SIGNAL */
|
Changed (); /* EMIT SIGNAL */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UndoHistory::redo (unsigned int n)
|
UndoHistory::redo (unsigned int n)
|
||||||
{
|
{
|
||||||
while (n--) {
|
if (n == 0) {
|
||||||
if (RedoList.size() == 0) {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
UndoTransaction* ut = RedoList.back ();
|
|
||||||
RedoList.pop_back ();
|
|
||||||
ut->redo ();
|
|
||||||
UndoList.push_back (ut);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct timeval start, end, diff;
|
||||||
|
gettimeofday (&start, 0);
|
||||||
|
|
||||||
|
{
|
||||||
|
UndoRedoSignaller exception_safe_signaller (*this);
|
||||||
|
|
||||||
|
while (n--) {
|
||||||
|
if (RedoList.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UndoTransaction* ut = RedoList.back ();
|
||||||
|
RedoList.pop_back ();
|
||||||
|
ut->redo ();
|
||||||
|
UndoList.push_back (ut);
|
||||||
|
}
|
||||||
|
gettimeofday (&end, 0);
|
||||||
|
timersub (&end, &start, &diff);
|
||||||
|
cerr << "Redo-pre-signals took " << diff.tv_sec << '.' << diff.tv_usec << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
gettimeofday (&end, 0);
|
||||||
|
timersub (&end, &start, &diff);
|
||||||
|
cerr << "Redo took " << diff.tv_sec << '.' << diff.tv_usec << endl;
|
||||||
|
|
||||||
|
EndUndoRedo (); /* EMIT SIGNAL */
|
||||||
Changed (); /* EMIT SIGNAL */
|
Changed (); /* EMIT SIGNAL */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue