summaryrefslogtreecommitdiff
path: root/gtk2_ardour/tempo_lines.cc
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-10-19 03:56:43 +1100
committernick_m <mainsbridge@gmail.com>2016-10-19 03:56:43 +1100
commit715b17813026c6baf8a4adb4442c8586e114452c (patch)
treee75622cb7aaf71514518fbaf463735afa5d3b56c /gtk2_ardour/tempo_lines.cc
parent208cb967e579d9177dce92086103c50f00b45b34 (diff)
Improve bbt ruler drawing performance for large time ranges.
- when the timeline displays many bars, zoom/autoscroll speed is improved by calculating the bbt ruler scale first then requesting a suitably scaled grid.
Diffstat (limited to 'gtk2_ardour/tempo_lines.cc')
-rw-r--r--gtk2_ardour/tempo_lines.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/gtk2_ardour/tempo_lines.cc b/gtk2_ardour/tempo_lines.cc
index 630e476adf..508ae84ed9 100644
--- a/gtk2_ardour/tempo_lines.cc
+++ b/gtk2_ardour/tempo_lines.cc
@@ -110,9 +110,22 @@ TempoLines::draw (std::vector<ARDOUR::TempoMap::BBTPoint>& grid,
i = grid.end();
i--;
bars = (*i).bar - (*grid.begin()).bar;
- beats = distance (grid.begin(), grid.end()) - bars;
- beat_density = (beats * 10.0f) / lines.canvas()->width();
+ if (bars < distance (grid.begin(), grid.end()) - 1) {
+ /* grid contains beats and bars */
+ beats = distance (grid.begin(), grid.end()) - bars;
+ } else {
+ /* grid contains only bars */
+ beats = distance (grid.begin(), grid.end());
+ }
+
+ double canvas_width_used = 1.0;
+ if (leftmost_frame < grid.front().frame) {
+ const framecnt_t frame_distance = max ((framecnt_t) 1, grid.back().frame - grid.front().frame);
+ canvas_width_used = 1.0 - ((grid.front().frame - leftmost_frame) / (double) (frame_distance + grid.front().frame));
+ }
+
+ beat_density = (beats * 10.0f) / (lines.canvas()->width() * canvas_width_used);
if (beat_density > 2.0f) {
/* if the lines are too close together, they become useless */