From 7ddd2a06920ecaaa3c61672bc1c1d213677426c9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 26 Jul 2023 13:11:22 -0600 Subject: [PATCH] automation control: allow single level of push/pop control group --- libs/ardour/ardour/automation_control.h | 3 +++ libs/ardour/ardour/control_group_member.h | 2 ++ libs/ardour/automation_control.cc | 26 +++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/libs/ardour/ardour/automation_control.h b/libs/ardour/ardour/automation_control.h index 932b2bba5d..b63ff886fa 100644 --- a/libs/ardour/ardour/automation_control.h +++ b/libs/ardour/ardour/automation_control.h @@ -126,6 +126,7 @@ public: protected: std::shared_ptr _group; + std::shared_ptr _pushed_group; const ParameterDescriptor _desc; @@ -156,6 +157,8 @@ private: */ friend class ControlGroup; void set_group (std::shared_ptr); + bool push_group (std::shared_ptr); + bool pop_group (); PBD::ScopedConnection _state_changed_connection; bool _no_session; }; diff --git a/libs/ardour/ardour/control_group_member.h b/libs/ardour/ardour/control_group_member.h index da17bad613..4729278dec 100644 --- a/libs/ardour/ardour/control_group_member.h +++ b/libs/ardour/ardour/control_group_member.h @@ -33,6 +33,8 @@ class LIBARDOUR_API ControlGroupMember mediated by the ControlGroup, not by operating on the member. */ virtual void set_group (std::shared_ptr) = 0; + virtual bool push_group (std::shared_ptr) = 0; + virtual bool pop_group () = 0; }; } /* namespace */ diff --git a/libs/ardour/automation_control.cc b/libs/ardour/automation_control.cc index 446d50b0ac..786be7cb19 100644 --- a/libs/ardour/automation_control.cc +++ b/libs/ardour/automation_control.cc @@ -370,6 +370,32 @@ AutomationControl::get_user_string () const return ARDOUR::value_as_string (_desc, get_value()); } +bool +AutomationControl::push_group (std::shared_ptr cg) +{ + if (_pushed_group) { + return false; + } + + _pushed_group = _group; + _group = cg; + + return true; +} + +bool +AutomationControl::pop_group () +{ + if (!_pushed_group) { + return false; + } + + _group = _pushed_group; + _pushed_group.reset (); + + return true; +} + void AutomationControl::set_group (std::shared_ptr cg) {