From 1f35010713eee53c2ed02e08a40f2396246de114 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 28 May 2024 22:07:13 -0600 Subject: [PATCH] extend libardour API to include possible flags when searching for prev/next mark --- libs/ardour/ardour/location.h | 11 +++++++++-- libs/ardour/location.cc | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h index 600cb6d222..2f9bf841e9 100644 --- a/libs/ardour/ardour/location.h +++ b/libs/ardour/ardour/location.h @@ -301,8 +301,15 @@ public: void set_clock_origin (Location*, void *src); - timepos_t first_mark_before (timepos_t const &, bool include_special_ranges = false); - timepos_t first_mark_after (timepos_t const &, bool include_special_ranges = false); + timepos_t first_mark_before_flagged (timepos_t const &, bool include_special_ranges = false, Location::Flags whitelist = Location::Flags (0), Location::Flags blacklist = Location::Flags (0), Location::Flags equalist = Location::Flags (0)); + timepos_t first_mark_after_flagged (timepos_t const &, bool include_special_ranges = false, Location::Flags whitelist = Location::Flags (0), Location::Flags blacklist = Location::Flags (0), Location::Flags equalist = Location::Flags (0)); + + timepos_t first_mark_after (timepos_t const & t, bool include_special_ranges = false) { + return first_mark_after_flagged (t, include_special_ranges); + } + timepos_t first_mark_before (timepos_t const & t, bool include_special_ranges = false) { + return first_mark_before_flagged (t, include_special_ranges); + } Location* next_section (Location*, timepos_t&, timepos_t&) const; Location* next_section_iter (Location*, timepos_t&, timepos_t&, std::vector& cache) const; diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index 4d9d86310d..c7ce3cec6b 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -1417,7 +1417,7 @@ struct LocationStartLaterComparison }; timepos_t -Locations::first_mark_before (timepos_t const & pos, bool include_special_ranges) +Locations::first_mark_before_flagged (timepos_t const & pos, bool include_special_ranges, Location::Flags whitelist, Location::Flags blacklist, Location::Flags equalist) { vector locs; { @@ -1443,6 +1443,21 @@ Locations::first_mark_before (timepos_t const & pos, bool include_special_ranges if (!include_special_ranges && ((*i).second->is_auto_loop() || (*i).second->is_auto_punch())) { continue; } + if (whitelist != Location::Flags (0)) { + if (!((*i).second->flags() & whitelist)) { + continue; + } + } + if (blacklist != Location::Flags (0)) { + if ((*i).second->flags() & blacklist) { + continue; + } + } + if (equalist != Location::Flags (0)) { + if (!((*i).second->flags() == equalist)) { + continue; + } + } if ((*i).first < pos) { return (*i).first; } @@ -1490,7 +1505,7 @@ Locations::mark_at (timepos_t const & pos, timecnt_t const & slop) const } timepos_t -Locations::first_mark_after (timepos_t const & pos, bool include_special_ranges) +Locations::first_mark_after_flagged (timepos_t const & pos, bool include_special_ranges, Location::Flags whitelist, Location::Flags blacklist, Location::Flags equalist) { vector locs; @@ -1517,6 +1532,21 @@ Locations::first_mark_after (timepos_t const & pos, bool include_special_ranges) if (!include_special_ranges && ((*i).second->is_auto_loop() || (*i).second->is_auto_punch())) { continue; } + if (whitelist != Location::Flags (0)) { + if (!((*i).second->flags() & whitelist)) { + continue; + } + } + if (blacklist != Location::Flags (0)) { + if ((*i).second->flags() & blacklist) { + continue; + } + } + if (equalist != Location::Flags (0)) { + if (!((*i).second->flags() == equalist)) { + continue; + } + } if ((*i).first > pos) { return (*i).first; }