13
0

control group: implement ::fill_from_selection and ::size()

This commit is contained in:
Paul Davis 2023-07-26 16:41:54 -06:00
parent eba8eb07d3
commit f6664570d4
2 changed files with 31 additions and 3 deletions

View File

@ -47,7 +47,7 @@ class LIBARDOUR_API ControlGroup : public std::enable_shared_from_this<ControlGr
Inverted = 0x2,
};
void fill_from_selection (CoreSelection const &);
void fill_from_selection (CoreSelection const &, Evoral::Parameter const &);
int add_control (std::shared_ptr<AutomationControl>, bool push = false);
int remove_control (std::shared_ptr<AutomationControl>, bool pop = false);
@ -82,8 +82,10 @@ class LIBARDOUR_API ControlGroup : public std::enable_shared_from_this<ControlGr
}
}
protected:
typedef std::map<PBD::ID,std::shared_ptr<AutomationControl> > ControlMap;
ControlMap::size_type size() const { Glib::Threads::RWLock::ReaderLock lm (controls_lock); return _controls.size(); }
protected:
Evoral::Parameter _parameter;
mutable Glib::Threads::RWLock controls_lock;
ControlMap _controls;

View File

@ -23,6 +23,7 @@
#include "ardour/control_group.h"
#include "ardour/gain_control.h"
#include "ardour/selection.h"
#include "ardour/stripable.h"
using namespace ARDOUR;
using namespace PBD;
@ -213,8 +214,33 @@ ControlGroup::set_group_value (std::shared_ptr<AutomationControl> control, doubl
}
void
ControlGroup::fill_from_selection (CoreSelection const & sel)
ControlGroup::fill_from_selection (CoreSelection const & sel, Evoral::Parameter const & p)
{
CoreSelection::StripableAutomationControls stripables;
Evoral::Parameter gain_p (GainAutomation);
sel.get_stripables (stripables);
/* Very unfortunate that gain control is special cased. Routes do not
* call ::add_control() for their gain control, but instead pass it to
* their Amp processor which takes a certain kind of ownership of it.
*/
if (p == gain_p) {
for (auto & s : stripables) {
std::shared_ptr<AutomationControl> ac = s.stripable->gain_control ();
if (ac) {
push (ac);
}
}
} else {
for (auto & s : stripables) {
std::shared_ptr<AutomationControl> ac = s.stripable->automation_control (p, true);
if (ac) {
push (ac);
}
}
}
}
bool