diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2012-01-03 18:43:58 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2012-01-03 18:43:58 +0000 |
commit | 2a200bdc0ead3d2a2a0481db44b0bc080529aa69 (patch) | |
tree | 2dc854572ed60513668647c2416707c89c68c3ea /gtk2_ardour/editor_rulers.cc | |
parent | 0d4658e0afb35329fe4ba135a20df92691f8b639 (diff) |
return two iterators into the Bars|Beats list of the tempo map rather than making a copy; use iterators in the GUI
git-svn-id: svn://localhost/ardour2/branches/3.0@11146 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_rulers.cc')
-rw-r--r-- | gtk2_ardour/editor_rulers.cc | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc index 36eb84797f..1d5dac091b 100644 --- a/gtk2_ardour/editor_rulers.cc +++ b/gtk2_ardour/editor_rulers.cc @@ -1147,7 +1147,8 @@ Editor::compute_bbt_ruler_scale (framepos_t lower, framepos_t upper) if (_session == 0) { return; } - TempoMap::BBTPointList::iterator i; + + TempoMap::BBTPointList::const_iterator i; Timecode::BBT_Time lower_beat, upper_beat; // the beats at each end of the ruler _session->bbt_time (lower, lower_beat); @@ -1224,18 +1225,18 @@ Editor::compute_bbt_ruler_scale (framepos_t lower, framepos_t upper) break; } - if (current_bbt_points.empty()) { + if (distance (current_bbt_points_begin, current_bbt_points_end) == 0) { return; } - i = current_bbt_points.end(); + i = current_bbt_points_end; i--; - if ((*i).beat >= (*current_bbt_points.begin()).beat) { - bbt_bars = (*i).bar - (*current_bbt_points.begin()).bar; + if ((*i).beat >= (*current_bbt_points_begin).beat) { + bbt_bars = (*i).bar - (*current_bbt_points_begin).bar; } else { - bbt_bars = (*i).bar - (*current_bbt_points.begin()).bar - 1; + bbt_bars = (*i).bar - (*current_bbt_points_begin).bar - 1; } - beats = current_bbt_points.size() - bbt_bars; + beats = distance (current_bbt_points_begin, current_bbt_points_end) - bbt_bars; /* Only show the bar helper if there aren't many bars on the screen */ if ((bbt_bars < 2) || (beats < 5)) { @@ -1272,7 +1273,7 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp return 0; } - TempoMap::BBTPointList::iterator i; + TempoMap::BBTPointList::const_iterator i; char buf[64]; gint n = 0; @@ -1291,14 +1292,14 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp bool i_am_accented = false; bool helper_active = false; - if (current_bbt_points.empty()) { + if (distance (current_bbt_points_begin, current_bbt_points_end) == 0) { return 0; } switch (bbt_ruler_scale) { case bbt_show_beats: - beats = current_bbt_points.size(); + beats = distance (current_bbt_points_begin, current_bbt_points_end); bbt_nmarks = beats + 2; *marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * bbt_nmarks); @@ -1306,8 +1307,8 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp (*marks)[0].label = g_strdup(" "); (*marks)[0].position = lower; (*marks)[0].style = GtkCustomRulerMarkMicro; - - for (n = 1, i = current_bbt_points.begin(); n < bbt_nmarks && i != current_bbt_points.end(); ++i) { + + for (n = 1, i = current_bbt_points_begin; n < bbt_nmarks && i != current_bbt_points_end; ++i) { if ((*i).frame < lower && (bbt_bar_helper_on)) { snprintf (buf, sizeof(buf), "<%" PRIu32 "|%" PRIu32, (*i).bar, (*i).beat); @@ -1334,7 +1335,7 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp case bbt_show_ticks: - beats = current_bbt_points.size(); + beats = distance (current_bbt_points_begin, current_bbt_points_end); bbt_nmarks = (beats + 2) * bbt_beat_subdivision; bbt_position_of_helper = lower + (30 * Editor::get_current_zoom ()); @@ -1344,7 +1345,7 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp (*marks)[0].position = lower; (*marks)[0].style = GtkCustomRulerMarkMicro; - for (n = 1, i = current_bbt_points.begin(); n < bbt_nmarks && i != current_bbt_points.end(); ++i) { + for (n = 1, i = current_bbt_points_begin; n < bbt_nmarks && i != current_bbt_points_end; ++i) { if ((*i).frame < lower && (bbt_bar_helper_on)) { snprintf (buf, sizeof(buf), "<%" PRIu32 "|%" PRIu32, (*i).bar, (*i).beat); @@ -1424,7 +1425,7 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp case bbt_show_ticks_detail: - beats = current_bbt_points.size(); + beats = distance (current_bbt_points_begin, current_bbt_points_end); bbt_nmarks = (beats + 2) * bbt_beat_subdivision; bbt_position_of_helper = lower + (30 * Editor::get_current_zoom ()); @@ -1434,7 +1435,7 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp (*marks)[0].position = lower; (*marks)[0].style = GtkCustomRulerMarkMicro; - for (n = 1, i = current_bbt_points.begin(); n < bbt_nmarks && i != current_bbt_points.end(); ++i) { + for (n = 1, i = current_bbt_points_begin; n < bbt_nmarks && i != current_bbt_points_end; ++i) { if ((*i).frame < lower && (bbt_bar_helper_on)) { snprintf (buf, sizeof(buf), "<%" PRIu32 "|%" PRIu32, (*i).bar, (*i).beat); @@ -1519,7 +1520,7 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp case bbt_show_ticks_super_detail: - beats = current_bbt_points.size(); + beats = distance (current_bbt_points_begin, current_bbt_points_end); bbt_nmarks = (beats + 2) * bbt_beat_subdivision; bbt_position_of_helper = lower + (30 * Editor::get_current_zoom ()); @@ -1529,7 +1530,7 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp (*marks)[0].position = lower; (*marks)[0].style = GtkCustomRulerMarkMicro; - for (n = 1, i = current_bbt_points.begin(); n < bbt_nmarks && i != current_bbt_points.end(); ++i) { + for (n = 1, i = current_bbt_points_begin; n < bbt_nmarks && i != current_bbt_points_end; ++i) { if ((*i).frame < lower && (bbt_bar_helper_on)) { snprintf (buf, sizeof(buf), "<%" PRIu32 "|%" PRIu32, (*i).bar, (*i).beat); @@ -1626,7 +1627,7 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp case bbt_show_64: bbt_nmarks = (gint) (bbt_bars / 64) + 1; *marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * bbt_nmarks); - for (n = 0, i = current_bbt_points.begin(); i != current_bbt_points.end() && n < bbt_nmarks; i++) { + for (n = 0, i = current_bbt_points_begin; i != current_bbt_points_end && n < bbt_nmarks; i++) { if ((*i).type == TempoMap::Bar) { if ((*i).bar % 64 == 1) { if ((*i).bar % 256 == 1) { @@ -1651,7 +1652,7 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp case bbt_show_16: bbt_nmarks = (bbt_bars / 16) + 1; *marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * bbt_nmarks); - for (n = 0, i = current_bbt_points.begin(); i != current_bbt_points.end() && n < bbt_nmarks; i++) { + for (n = 0, i = current_bbt_points_begin; i != current_bbt_points_end && n < bbt_nmarks; i++) { if ((*i).type == TempoMap::Bar) { if ((*i).bar % 16 == 1) { if ((*i).bar % 64 == 1) { @@ -1676,7 +1677,7 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp case bbt_show_4: bbt_nmarks = (bbt_bars / 4) + 1; *marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * bbt_nmarks); - for (n = 0, i = current_bbt_points.begin(); i != current_bbt_points.end() && n < bbt_nmarks; ++i) { + for (n = 0, i = current_bbt_points_begin; i != current_bbt_points_end && n < bbt_nmarks; ++i) { if ((*i).type == TempoMap::Bar) { if ((*i).bar % 4 == 1) { if ((*i).bar % 16 == 1) { @@ -1702,7 +1703,7 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp // default: bbt_nmarks = bbt_bars + 2; *marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * bbt_nmarks ); - for (n = 0, i = current_bbt_points.begin(); i != current_bbt_points.end() && n < bbt_nmarks; i++) { + for (n = 0, i = current_bbt_points_begin; i != current_bbt_points_end && n < bbt_nmarks; i++) { if ((*i).type == TempoMap::Bar) { if ((*i).bar % 4 == 1) { snprintf (buf, sizeof(buf), "%" PRIu32, (*i).bar); |