From ece438d73d8ccb58f2257a095476eed86d1eae7f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 11 Mar 2023 20:22:09 -0700 Subject: [PATCH] editor: refactor snap to bbt to allow specifying non-grid-setting grid type --- gtk2_ardour/editor.cc | 8 +++++++- gtk2_ardour/editor.h | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 6f9774af68..f69da2fc60 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -2952,6 +2952,12 @@ Editor::snap_to_cd_frames (timepos_t const & presnap, Temporal::RoundMode direct timepos_t Editor::snap_to_bbt (timepos_t const & presnap, Temporal::RoundMode direction, SnapPref gpref) +{ + return _snap_to_bbt (presnap, direction, gpref, _grid_type); +} + +timepos_t +Editor::_snap_to_bbt (timepos_t const & presnap, Temporal::RoundMode direction, SnapPref gpref, GridType grid_type) { timepos_t ret(presnap); TempoMap::SharedPtr tmap (TempoMap::use()); @@ -2963,7 +2969,7 @@ Editor::snap_to_bbt (timepos_t const & presnap, Temporal::RoundMode direction, S * nearby grid and walk towards the next bar point. */ - if (_grid_type == GridTypeBar) { + if (grid_type == GridTypeBar) { TempoMetric m (tmap->metric_at (presnap)); BBT_Argument bbt (m.bbt_at (presnap)); switch (direction) { diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index fa38dbf625..610a995c14 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -2387,6 +2387,11 @@ private: Temporal::RoundMode direction, ARDOUR::SnapPref gpref); + Temporal::timepos_t _snap_to_bbt (Temporal::timepos_t const & start, + Temporal::RoundMode direction, + ARDOUR::SnapPref gpref, + Editing::GridType grid_type); + void snap_to_internal (Temporal::timepos_t& first, Temporal::RoundMode direction = Temporal::RoundNearest, ARDOUR::SnapPref gpref = ARDOUR::SnapToAny_Visual,