13
0

editor markers: refactor ::reassociate_metric_marks() to be able to process one marker at a time

This commit is contained in:
Paul Davis 2022-01-15 20:04:03 -07:00
parent 9ee4c14bce
commit 7ea072a4f4
2 changed files with 40 additions and 33 deletions

View File

@ -1846,6 +1846,7 @@ private:
void compute_current_bbt_points (Temporal::TempoMapPoints& grid, samplepos_t left, samplepos_t right); void compute_current_bbt_points (Temporal::TempoMapPoints& grid, samplepos_t left, samplepos_t right);
void reassociate_metric_markers (Temporal::TempoMap::SharedPtr const &); void reassociate_metric_markers (Temporal::TempoMap::SharedPtr const &);
void reassociate_metric_marker (Temporal::TempoMap::SharedPtr const & tmap, Temporal::TempoMap::Metrics & metric, ArdourMarker& marker);
void tempo_map_changed (); void tempo_map_changed ();
void redisplay_grid (bool immediate_redraw); void redisplay_grid (bool immediate_redraw);

View File

@ -96,6 +96,14 @@ Editor::reassociate_metric_markers (TempoMap::SharedPtr const & tmap)
TempoMap::Metrics metrics; TempoMap::Metrics metrics;
tmap->get_metrics (metrics); tmap->get_metrics (metrics);
for (auto & marker : metric_marks) {
reassociate_metric_marker (tmap, metrics, *marker);
}
}
void
Editor::reassociate_metric_marker (TempoMap::SharedPtr const & tmap, TempoMap::Metrics & metrics, ArdourMarker& marker)
{
TempoMarker* tm; TempoMarker* tm;
MeterMarker* mm; MeterMarker* mm;
BBTMarker* bm; BBTMarker* bm;
@ -104,46 +112,44 @@ Editor::reassociate_metric_markers (TempoMap::SharedPtr const & tmap)
Temporal::MeterPoint* mp; Temporal::MeterPoint* mp;
Temporal::MusicTimePoint* mtp; Temporal::MusicTimePoint* mtp;
for (Marks::iterator x = metric_marks.begin(); x != metric_marks.end(); ++x) { if ((tm = dynamic_cast<TempoMarker*> (&marker)) != 0) {
if ((tm = dynamic_cast<TempoMarker*> (*x)) != 0) { for (TempoMap::Metrics::iterator m = metrics.begin(); m != metrics.end(); ++m) {
if ((mtp = dynamic_cast<Temporal::MusicTimePoint*>(*m)) != 0) {
for (TempoMap::Metrics::iterator m = metrics.begin(); m != metrics.end(); ++m) { /* do nothing .. but we had to catch
if ((mtp = dynamic_cast<Temporal::MusicTimePoint*>(*m)) != 0) { this first because MusicTimePoint
/* do nothing .. but we had to catch IS-A TempoPoint
this first because MusicTimePoint */
IS-A TempoPoint } else if ((tp = dynamic_cast<Temporal::TempoPoint*>(*m)) != 0) {
*/ if (tm->tempo() == *tp) {
} else if ((tp = dynamic_cast<Temporal::TempoPoint*>(*m)) != 0) { tm->reset_tempo (*tp);
if (tm->tempo() == *tp) { break;
tm->reset_tempo (*tp);
break;
}
} }
} }
} else if ((mm = dynamic_cast<MeterMarker*> (*x)) != 0) { }
for (TempoMap::Metrics::iterator m = metrics.begin(); m != metrics.end(); ++m) { } else if ((mm = dynamic_cast<MeterMarker*> (&marker)) != 0) {
if ((mtp = dynamic_cast<Temporal::MusicTimePoint*>(*m)) != 0) { for (TempoMap::Metrics::iterator m = metrics.begin(); m != metrics.end(); ++m) {
/* do nothing .. but we had to catch if ((mtp = dynamic_cast<Temporal::MusicTimePoint*>(*m)) != 0) {
this first because MusicTimePoint /* do nothing .. but we had to catch
IS-A TempoPoint this first because MusicTimePoint
*/ IS-A TempoPoint
*/
} else if ((mp = dynamic_cast<Temporal::MeterPoint*>(*m)) != 0) { } else if ((mp = dynamic_cast<Temporal::MeterPoint*>(*m)) != 0) {
if (mm->meter() == *mp) { if (mm->meter() == *mp) {
mm->reset_meter (*mp); mm->reset_meter (*mp);
break; break;
}
} }
} }
} else if ((bm = dynamic_cast<BBTMarker*> (*x)) != 0) { }
for (TempoMap::Metrics::iterator m = metrics.begin(); m != metrics.end(); ++m) { } else if ((bm = dynamic_cast<BBTMarker*> (&marker)) != 0) {
if ((mtp = dynamic_cast<Temporal::MusicTimePoint*>(*m)) != 0) {
if (bm->point() == *mtp) { for (TempoMap::Metrics::iterator m = metrics.begin(); m != metrics.end(); ++m) {
bm->reset_point (*mtp); if ((mtp = dynamic_cast<Temporal::MusicTimePoint*>(*m)) != 0) {
break; if (bm->point() == *mtp) {
} bm->reset_point (*mtp);
break;
} }
} }
} }