From 901432f030f3120d420f3ea245a8c0b2ef0353f5 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Sat, 26 Aug 2017 21:05:40 -0500 Subject: [PATCH] Editor zooming: refactor zoom-limiting code into editor::session_gui_extents. --- gtk2_ardour/editor_ops.cc | 49 +++++---------------------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index e2a378759d..a0370d0d7e 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -1789,49 +1789,12 @@ Editor::temporal_zoom_step_scale (bool zoom_out, double scale) } } - // 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 rl = _session->get_routes(); - for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) { - boost::shared_ptr tr = boost::dynamic_pointer_cast (*r); - if (tr) { - boost::shared_ptr pl = tr->playlist(); - if (pl) { - pair 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; - } + //zoom-behavior-tweaks + //limit our maximum zoom to the session gui extents value (+10%) + std::pair ext = session_gui_extents(); + framecnt_t session_extents_pp = ( ext.second - ext.first ) / _visible_canvas_width; + if (nspp > session_extents_pp * 1.1) + nspp = session_extents_pp * 1.1; temporal_zoom (nspp); }