Add motorised attribute to DeviceInfo for generic MIDI maps so that
[ardour.git] / gtk2_ardour / editor_tempodisplay.cc
index 89832c5d1367a7e2701c4a608ac0ebc50f720e4c..005e7ff6fdce45dde21ba208ec7733b0dbbc205f 100644 (file)
@@ -114,7 +114,7 @@ Editor::tempo_map_changed (const PropertyChange& /*ignored*/)
                tempo_lines->tempo_map_changed();
        }
 
-       compute_current_bbt_points(leftmost_frame, leftmost_frame + current_page_frames());
+       compute_current_bbt_points (leftmost_frame, leftmost_frame + current_page_frames());
        _session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks); // redraw metric markers
        redraw_measures ();
        update_tempo_based_rulers ();
@@ -148,31 +148,10 @@ Editor::compute_current_bbt_points (framepos_t leftmost, framepos_t rightmost)
                return;
        }
 
-       Timecode::BBT_Time previous_beat, next_beat; // the beats previous to the leftmost frame and after the rightmost frame
+       /* prevent negative values of leftmost from creeping into tempomap
+        */
 
-       _session->bbt_time(leftmost, previous_beat);
-       _session->bbt_time(rightmost, next_beat);
-
-       if (previous_beat.beats > 1) {
-               previous_beat.beats -= 1;
-       } else if (previous_beat.bars > 1) {
-               previous_beat.bars--;
-               previous_beat.beats += 1;
-       }
-       previous_beat.ticks = 0;
-
-       if (_session->tempo_map().meter_at(rightmost).divisions_per_bar () > next_beat.beats + 1) {
-               next_beat.beats += 1;
-       } else {
-               next_beat.bars += 1;
-               next_beat.beats = 1;
-       }
-       next_beat.ticks = 0;
-
-       delete current_bbt_points;
-       current_bbt_points = 0;
-
-       current_bbt_points = _session->tempo_map().get_points (_session->tempo_map().frame_time (previous_beat), _session->tempo_map().frame_time (next_beat) + 1);
+       _session->tempo_map().get_grid (current_bbt_points_begin, current_bbt_points_end, max (leftmost, (framepos_t) 0), rightmost);
 }
 
 void
@@ -192,8 +171,7 @@ Editor::redraw_measures ()
 void
 Editor::draw_measures ()
 {
-       if (_session == 0 || _show_measures == false ||
-           !current_bbt_points || current_bbt_points->empty()) {
+       if (_session == 0 || _show_measures == false || distance (current_bbt_points_begin, current_bbt_points_end) == 0) {
                return;
        }
 
@@ -201,7 +179,7 @@ Editor::draw_measures ()
                tempo_lines = new TempoLines(*track_canvas, time_line_group, physical_screen_height(get_window()));
        }
 
-       tempo_lines->draw(*current_bbt_points, frames_per_unit);
+       tempo_lines->draw (current_bbt_points_begin, current_bbt_points_end, frames_per_unit);
 }
 
 void