summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorBen Loftis <ben@harrisonconsoles.com>2017-07-19 15:10:20 -0500
committerBen Loftis <ben@harrisonconsoles.com>2017-07-19 15:37:59 -0500
commit53fba8326c7ab5d64d5f72f952674e34137dfaab (patch)
treeec30837904c044a4c98011856a0950cd6a13704d /gtk2_ardour
parent9992ea10b35caacc2f061cd176d0dc3910eb7453 (diff)
Rationalize Editor Zooming: make it harder for user to step into ridiculous zoom-out scales.
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor_ops.cc46
1 files changed, 45 insertions, 1 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index ea3e3ac74f..8f94a2b02d 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -1771,7 +1771,51 @@ Editor::temporal_zoom_step_scale (bool zoom_out, double scale)
nspp /= 2.0;
}
}
-
+
+ // ToDo: encapsulate all of this into something like editor::get_session_extents() or editor::leftmost(), rightmost()
+ {
+ //ToDo: also incorporate automation regions (in case the session has no audio/midi but is just used for automating plugins or the like)
+
+ //calculate the extents of all regions in every playlist
+ framecnt_t session_extent_start = 0;
+ framecnt_t session_extent_end = 0;
+ {
+ boost::shared_ptr<RouteList> rl = _session->get_routes();
+ for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
+ boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*r);
+ if (tr) {
+ boost::shared_ptr<Playlist> pl = tr->playlist();
+ if (pl) {
+ pair<framepos_t, framepos_t> e;
+ e = pl->get_extent();
+ if (e.first < session_extent_start) {
+ session_extent_start = e.first;
+ }
+ if (e.second > session_extent_end) {
+ session_extent_end = e.second;
+ }
+ }
+ }
+ }
+ }
+ framecnt_t session_extents = session_extent_end - session_extent_start;
+
+ //in a session with no regions, use the start/end markers to set max zoom
+ framecnt_t const session_length = _session->current_end_frame() - _session->current_start_frame ();
+ if ( session_length > session_extents )
+ session_extents = session_length;
+
+ //in a session with no regions or start/end markers, use 2 minutes to set max zoom
+ framecnt_t const min_length = _session->nominal_frame_rate()*60*2;
+ if ( min_length > session_extents )
+ session_extents = min_length;
+
+ //convert to samples-per-pixel and limit our zoom to this value
+ framecnt_t session_extents_pp = session_extents / _visible_canvas_width;
+ if (nspp > session_extents_pp)
+ nspp = session_extents_pp;
+ }
+
temporal_zoom (nspp);
}