From 0f6aa118f0f4657f23b2b7063ad8c87941abeb9a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 2 Jan 2022 17:09:58 -0700 Subject: [PATCH] triggerbox: add Forward/ReverseTrigger follow actions Live's Next/Prev do not skip empty slots or wrap. So do both-and --- libs/ardour/ardour/triggerbox.h | 2 ++ libs/ardour/enums.cc | 2 ++ libs/ardour/triggerbox.cc | 22 +++++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index a6a6d0db25..a817438587 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -171,6 +171,8 @@ class LIBARDOUR_API Trigger : public PBD::Stateful { QueuedTrigger, /* DP-style */ NextTrigger, /* Live-style, and below */ PrevTrigger, + ForwardTrigger, /* any "next" skipping empties */ + ReverseTrigger, /* any "prev" skipping empties */ FirstTrigger, LastTrigger, AnyTrigger, diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc index a1ca52b6b4..a180e305ea 100644 --- a/libs/ardour/enums.cc +++ b/libs/ardour/enums.cc @@ -859,6 +859,8 @@ setup_enum_writer () REGISTER_CLASS_ENUM (Trigger, QueuedTrigger); REGISTER_CLASS_ENUM (Trigger, NextTrigger); REGISTER_CLASS_ENUM (Trigger, PrevTrigger); + REGISTER_CLASS_ENUM (Trigger, ForwardTrigger); + REGISTER_CLASS_ENUM (Trigger, ReverseTrigger); REGISTER_CLASS_ENUM (Trigger, FirstTrigger); REGISTER_CLASS_ENUM (Trigger, LastTrigger); REGISTER_CLASS_ENUM (Trigger, AnyTrigger); diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 2486132285..192e341371 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -2695,7 +2695,26 @@ TriggerBox::determine_next_trigger (uint32_t current) case Trigger::Again: return current; + case Trigger::NextTrigger: + n = current + 1; + if (n < all_triggers.size()) { + if (all_triggers[n]->region()) { + return n; + } + } + break; + + case Trigger::PrevTrigger: + if (current > 0) { + n = current - 1; + if (all_triggers[n]->region()) { + return n; + } + } + break; + + case Trigger::ForwardTrigger: n = current; while (true) { ++n; @@ -2715,7 +2734,8 @@ TriggerBox::determine_next_trigger (uint32_t current) } } break; - case Trigger::PrevTrigger: + + case Trigger::ReverseTrigger: n = current; while (true) { if (n == 0) {