From de731940505dff6a9ba4cd624c2cd721b8970a63 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 23 Jun 2017 15:51:46 +0200 Subject: Implement undo for merging VCA-master automation/value on disconnect. --- libs/ardour/slavable_automation_control.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libs/ardour') diff --git a/libs/ardour/slavable_automation_control.cc b/libs/ardour/slavable_automation_control.cc index 6558637383..3128543dde 100644 --- a/libs/ardour/slavable_automation_control.cc +++ b/libs/ardour/slavable_automation_control.cc @@ -21,6 +21,7 @@ #include "pbd/enumwriter.h" #include "pbd/error.h" +#include "pbd/memento_command.h" #include "pbd/types_convert.h" #include "pbd/i18n.h" @@ -366,6 +367,7 @@ SlavableAutomationControl::remove_master (boost::shared_ptr m /* ..and update automation */ if (_list) { + XMLNode* before = &alist ()->get_state (); if (master->automation_playback () && master->list()) { _list->list_merge (*master->list().get(), boost::bind (&SlavableAutomationControl::scale_automation_callback, this, _1, _2)); _list->y_transform (boost::bind (&SlavableAutomationControl::scale_automation_callback, this, _1, list_ratio)); @@ -373,6 +375,11 @@ SlavableAutomationControl::remove_master (boost::shared_ptr m // do we need to freeze/thaw the list? probably no: iterators & positions don't change _list->y_transform (boost::bind (&SlavableAutomationControl::scale_automation_callback, this, _1, master_ratio)); } + XMLNode* after = &alist ()->get_state (); + if (*before != *after) { + _session.begin_reversible_command (string_compose (_("Merge VCA automation into %1"), name ())); + _session.commit_reversible_command (alist()->memento_command (before, after)); + } } } @@ -432,6 +439,7 @@ SlavableAutomationControl::clear_masters () /* ..and update automation */ if (_list) { + XMLNode* before = &alist ()->get_state (); if (!masters.empty()) { for (ControlList::const_iterator m = masters.begin(); m != masters.end(); ++m) { _list->list_merge (*(*m)->list().get(), boost::bind (&SlavableAutomationControl::scale_automation_callback, this, _1, _2)); @@ -440,6 +448,11 @@ SlavableAutomationControl::clear_masters () } else { _list->y_transform (boost::bind (&SlavableAutomationControl::scale_automation_callback, this, _1, master_ratio)); } + XMLNode* after = &alist ()->get_state (); + if (*before != *after) { + _session.begin_reversible_command (string_compose (_("Merge VCA automation into %1"), name ())); + _session.commit_reversible_command (alist()->memento_command (before, after)); + } } } -- cgit v1.2.3