From afe74bb460b464352633d28906080cb59b2a602e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 7 Oct 2023 11:10:40 -0600 Subject: [PATCH] use Meter::round_to_bar() rather than BBT_Time::round_(up|down)_to_bar this gives slightly better behavior when dragging a meter marker --- libs/temporal/tempo.cc | 17 ++++------------- libs/temporal/temporal/tempo.h | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index a93b00b00d..2374a9dea7 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -1920,7 +1920,7 @@ TempoMap::reset_section (Points::iterator& begin, Points::iterator& end, supercl bool -TempoMap::move_meter (MeterPoint const & mp, timepos_t const & when, bool earlier, bool push) +TempoMap::move_meter (MeterPoint const & mp, timepos_t const & when, bool push) { TEMPO_MAP_ASSERT (!_tempos.empty()); TEMPO_MAP_ASSERT (!_meters.empty()); @@ -1933,16 +1933,9 @@ TempoMap::move_meter (MeterPoint const & mp, timepos_t const & when, bool earlie superclock_t sc; Beats beats; BBT_Time bbt; - bool round_up; beats = when.beats (); - if (earlier) { - round_up = false; - } else { - round_up = true; - } - /* Do not allow moving a meter marker to the same position as * an existing one. */ @@ -1965,11 +1958,8 @@ TempoMap::move_meter (MeterPoint const & mp, timepos_t const & when, bool earlie TempoMetric metric (*prev_t, *prev_m); bbt = metric.bbt_at (beats); - if (round_up) { - bbt = bbt.round_up_to_bar (); - } else { - bbt = bbt.round_down_to_bar (); - } + bbt = metric.round_to_bar (bbt); + /* Now find the correct TempoMetric for the new BBT position (which may * differ from the one we determined earlier. * @@ -1982,6 +1972,7 @@ TempoMap::move_meter (MeterPoint const & mp, timepos_t const & when, bool earlie for (t = _tempos.begin(), prev_t = _tempos.end(); t != _tempos.end() && t->bbt() < bbt && t->beats() < beats; ++t) { prev_t = t; } for (m = _meters.begin(), prev_m = _meters.end(); m != _meters.end() && m->bbt() < bbt && *m != mp; ++m) { prev_m = m; } + if (prev_m == _meters.end()) { return false; } diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h index 9414874cbf..888be4ad3c 100644 --- a/libs/temporal/temporal/tempo.h +++ b/libs/temporal/temporal/tempo.h @@ -803,7 +803,7 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible /* these are a convenience method that just wrap some odd semantics */ LIBTEMPORAL_API bool move_tempo (TempoPoint const & point, timepos_t const & destination, bool push = false); - LIBTEMPORAL_API bool move_meter (MeterPoint const & point, timepos_t const & destination, bool earlier, bool push = false); + LIBTEMPORAL_API bool move_meter (MeterPoint const & point, timepos_t const & destination, bool push = false); LIBTEMPORAL_API int set_state (XMLNode const&, int version);