summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_tempodisplay.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gtk2_ardour/editor_tempodisplay.cc')
-rw-r--r--gtk2_ardour/editor_tempodisplay.cc75
1 files changed, 33 insertions, 42 deletions
diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc
index 7817e419be..df4613f7be 100644
--- a/gtk2_ardour/editor_tempodisplay.cc
+++ b/gtk2_ardour/editor_tempodisplay.cc
@@ -48,7 +48,7 @@
#include "rgb_macros.h"
#include "gui_thread.h"
#include "time_axis_view.h"
-#include "tempo_lines.h"
+#include "grid_lines.h"
#include "ui_config.h"
#include "pbd/i18n.h"
@@ -180,18 +180,12 @@ Editor::tempo_map_changed (const PropertyChange& /*ignored*/)
ENSURE_GUI_THREAD (*this, &Editor::tempo_map_changed, ignored);
- if (tempo_lines) {
- tempo_lines->tempo_map_changed(_session->tempo_map().music_origin());
- }
-
compute_bbt_ruler_scale (_leftmost_sample, _leftmost_sample + current_page_samples());
- std::vector<TempoMap::BBTPoint> grid;
- if (bbt_ruler_scale != bbt_show_many) {
- compute_current_bbt_points (grid, _leftmost_sample, _leftmost_sample + current_page_samples());
- }
+
_session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks); // redraw metric markers
- draw_measures (grid);
update_tempo_based_rulers ();
+
+ maybe_draw_grid_lines ();
}
void
@@ -203,10 +197,6 @@ Editor::tempometric_position_changed (const PropertyChange& /*ignored*/)
ENSURE_GUI_THREAD (*this, &Editor::tempo_map_changed);
- if (tempo_lines) {
- tempo_lines->tempo_map_changed(_session->tempo_map().music_origin());
- }
-
TempoSection* prev_ts = 0;
double max_tempo = 0.0;
double min_tempo = DBL_MAX;
@@ -281,18 +271,14 @@ Editor::tempometric_position_changed (const PropertyChange& /*ignored*/)
}
compute_bbt_ruler_scale (_leftmost_sample, _leftmost_sample + current_page_samples());
- std::vector<TempoMap::BBTPoint> grid;
-
- if (bbt_ruler_scale != bbt_show_many) {
- compute_current_bbt_points (grid, _leftmost_sample, _leftmost_sample + current_page_samples());
- }
- draw_measures (grid);
update_tempo_based_rulers ();
+
+ maybe_draw_grid_lines ();
}
void
-Editor::redisplay_tempo (bool immediate_redraw)
+Editor::redisplay_grid (bool immediate_redraw)
{
if (!_session) {
return;
@@ -300,20 +286,12 @@ Editor::redisplay_tempo (bool immediate_redraw)
if (immediate_redraw) {
-//only recalculate bbt_ruler_scale on a zoom or snap-change; not every redraw; if a case is found where this is necessary, uncomment this line.
-// compute_bbt_ruler_scale (_leftmost_sample, _leftmost_sample + current_page_samples());
-
- std::vector<TempoMap::BBTPoint> grid;
-
- if (bbt_ruler_scale != bbt_show_many) {
- compute_current_bbt_points (grid, _leftmost_sample, _leftmost_sample + current_page_samples());
- }
-
- draw_measures (grid);
- update_tempo_based_rulers (); // redraw rulers and measure lines
+ update_tempo_based_rulers ();
+ update_grid();
+
} else {
- Glib::signal_idle().connect (sigc::bind_return (sigc::bind (sigc::mem_fun (*this, &Editor::redisplay_tempo), true), false));
+ Glib::signal_idle().connect (sigc::bind_return (sigc::bind (sigc::mem_fun (*this, &Editor::redisplay_grid), true), false));
}
}
void
@@ -379,26 +357,39 @@ Editor::compute_current_bbt_points (std::vector<TempoMap::BBTPoint>& grid, sampl
}
void
-Editor::hide_measures ()
+Editor::hide_grid_lines ()
{
- if (tempo_lines) {
- tempo_lines->hide();
+ if (grid_lines) {
+ grid_lines->hide();
}
}
void
-Editor::draw_measures (std::vector<ARDOUR::TempoMap::BBTPoint>& grid)
+Editor::maybe_draw_grid_lines ()
{
- if (_session == 0 || _show_measures == false || distance (grid.begin(), grid.end()) == 0) {
+ if ( _session == 0 ) {
return;
}
- if (tempo_lines == 0) {
- tempo_lines = new TempoLines (time_line_group, ArdourCanvas::LineSet::Vertical, new BeatsSamplesConverter (_session->tempo_map(), _session->tempo_map().music_origin()));
+ if (grid_lines == 0) {
+ grid_lines = new GridLines (time_line_group, ArdourCanvas::LineSet::Vertical);
+ }
+
+ grid_marks.clear();
+ samplepos_t rightmost_sample = _leftmost_sample + current_page_samples();
+
+ if ( grid_musical() ) {
+ metric_get_bbt (grid_marks, _leftmost_sample, rightmost_sample, 12);
+ } else if (_grid_type== GridTypeSmpte) {
+ metric_get_timecode (grid_marks, _leftmost_sample, rightmost_sample, 12);
+ } else if (_grid_type == GridTypeSamples) {
+ metric_get_samples (grid_marks, _leftmost_sample, rightmost_sample, 12);
+ } else if (_grid_type == GridTypeMinSec) {
+ metric_get_minsec (grid_marks, _leftmost_sample, rightmost_sample, 12);
}
- const unsigned divisions = get_grid_beat_divisions(_leftmost_sample);
- tempo_lines->draw (grid, divisions, _leftmost_sample, _session->sample_rate());
+ grid_lines->draw ( grid_marks );
+ grid_lines->show();
}
void