13
0

use Meter::round_to_bar() rather than BBT_Time::round_(up|down)_to_bar

this gives slightly better behavior when dragging a meter marker
This commit is contained in:
Paul Davis 2023-10-07 11:10:40 -06:00
parent 64458c2430
commit afe74bb460
2 changed files with 5 additions and 14 deletions

View File

@ -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;
}

View File

@ -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);