From 2000bc6ea0f99904cbfa0b2f10d774976ff88970 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 26 Sep 2021 21:59:15 -0600 Subject: [PATCH] triggerbox: add use_follow and start using actual Properties for trigger properties --- libs/ardour/ardour/triggerbox.h | 10 ++++++++-- libs/ardour/triggerbox.cc | 24 +++++++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index 6cc4d50c47..141b56dd34 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -28,8 +28,9 @@ #include #include "pbd/pcg_rand.h" -#include "pbd/stateful.h" +#include "pbd/properties.h" #include "pbd/ringbuffer.h" +#include "pbd/stateful.h" #include "temporal/beats.h" #include "temporal/bbt_time.h" @@ -42,6 +43,7 @@ class XMLNode; namespace ARDOUR { namespace Properties { + LIBARDOUR_API extern PBD::PropertyDescriptor use_follow; LIBARDOUR_API extern PBD::PropertyDescriptor running; LIBARDOUR_API extern PBD::PropertyDescriptor legato; } @@ -84,6 +86,9 @@ class LIBARDOUR_API Trigger : public PBD::Stateful { /* this accepts timepos_t because the origin is assumed to be the start */ virtual void set_length (timepos_t const &) = 0; + void set_use_follow (bool yn); + bool use_follow() const { return _use_follow; } + timepos_t start_offset () const; /* offset from start of data */ timepos_t end() const; /* offset from start of data */ virtual timepos_t current_length() const = 0; /* offset from start() */ @@ -179,11 +184,12 @@ class LIBARDOUR_API Trigger : public PBD::Stateful { uint64_t _index; int _next_trigger; LaunchStyle _launch_style; + PBD::Property _use_follow; FollowAction _follow_action[2]; int _follow_action_probability; boost::shared_ptr _region; Temporal::BBT_Offset _quantization; - bool _legato; + PBD::Property _legato; std::string _name; void* _ui; diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 3a31118074..ac36adc0e5 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -22,6 +22,7 @@ #include "ardour/source_factory.h" #include "ardour/sndfilesource.h" #include "ardour/triggerbox.h" +#include "ardour/types_convert.h" using namespace PBD; using namespace ARDOUR; @@ -31,6 +32,7 @@ using std::endl; namespace ARDOUR { namespace Properties { + PBD::PropertyDescriptor use_follow; PBD::PropertyDescriptor running; PBD::PropertyDescriptor legato; } @@ -44,12 +46,22 @@ Trigger::Trigger (uint64_t n, TriggerBox& b) , _unbang (0) , _index (n) , _launch_style (Toggle) + , _use_follow (Properties::use_follow, true) , _follow_action { NextTrigger, Stop } , _follow_action_probability (100) , _quantization (Temporal::BBT_Offset (0, 1, 0)) - , _legato (true) + , _legato (Properties::legato, true) , _ui (0) { + add_property (_legato); + add_property (_use_follow); +} + +void +Trigger::set_use_follow (bool yn) +{ + _use_follow = yn; + PropertyChanged (Properties::legato); } void @@ -98,7 +110,10 @@ Trigger::get_state (void) { XMLNode* node = new XMLNode (X_("Trigger")); - node->set_property (X_("legato"), _legato); + for (OwnedPropertyList::iterator i = _properties->begin(); i != _properties->end(); ++i) { + i->second->get_value (*node); + } + node->set_property (X_("launch-style"), enum_2_string (_launch_style)); node->set_property (X_("follow-action-0"), enum_2_string (_follow_action[0])); node->set_property (X_("follow-action-1"), enum_2_string (_follow_action[1])); @@ -116,7 +131,10 @@ Trigger::get_state (void) int Trigger::set_state (const XMLNode& node, int version) { - node.get_property (X_("legato"), _legato); + PropertyChange what_changed; + + what_changed = set_values (node); + node.get_property (X_("launch-style"), _launch_style); node.get_property (X_("follow-action-0"), _follow_action[0]); node.get_property (X_("follow-action-1"), _follow_action[1]);