Editor zooming:
authorBen Loftis <ben@harrisonconsoles.com>
Sun, 27 Aug 2017 02:00:45 +0000 (21:00 -0500)
committerBen Loftis <ben@harrisonconsoles.com>
Sun, 27 Aug 2017 03:44:58 +0000 (22:44 -0500)
New function session_gui_extents() reports the extents of all playlists.
  ToDo: include region playlists, when they become available.
also:  slow-down autoscroll (ToDo:  make a config variable for this)

gtk2_ardour/editor.h
gtk2_ardour/editor_canvas.cc

index 1e3f4c9a990273e4fcb66c2d43edb78b55652c6e..b43beff9bc4c0818d680f7ec70804a46c391ae38 100644 (file)
@@ -364,6 +364,9 @@ public:
        void set_group_tabs ();
        void toggle_measure_visibility ();
 
+       /* returns the left-most and right-most time that the gui should allow the user to scroll to */
+       std::pair <framepos_t,framepos_t> session_gui_extents() const; 
+
        /* fades */
 
        void toggle_region_fades (int dir);
index 3ff0cf4c4a50b2380bb7029aeefe79a053322e7c..43b97a36f7fb928244b017ccad8aaea66f5cb310 100644 (file)
@@ -581,6 +581,45 @@ Editor::autoscroll_active () const
        return autoscroll_connection.connected ();
 }
 
+std::pair <framepos_t,framepos_t>
+Editor::session_gui_extents () const
+{
+       framecnt_t session_extent_start = _session->current_start_frame();
+       framecnt_t session_extent_end = _session->current_end_frame();
+
+       //calculate the extents of all regions in every playlist
+       //NOTE:  we should listen to playlists, and cache these values so we don't calculate them every time.
+       {
+               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 && !pl->all_regions_empty() ) {
+                                       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;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       //ToDo: also incorporate automation regions (in case the session has no audio/midi but is just used for automating plugins or the like)
+
+       //if all else fails, give us 2 minutes
+       framecnt_t const min_length = _session->nominal_frame_rate()*60*2;
+       if ( session_extent_end < min_length )
+               session_extent_end = min_length;
+       
+       std::pair <framepos_t,framepos_t> ret (session_extent_start, session_extent_end);
+       return ret;
+}
+
 bool
 Editor::autoscroll_canvas ()
 {
@@ -612,6 +651,8 @@ Editor::autoscroll_canvas ()
                        dx += 10 + (2 * (autoscroll_cnt/2));
 
                        dx = pixel_to_sample (dx);
+                       
+                       dx /= 10;  //ToDo:  make a config variable for scroll speed  zoom-behavior-tweaks
 
                        if (leftmost_frame < max_framepos - dx) {
                                new_frame = leftmost_frame + dx;
@@ -628,6 +669,8 @@ Editor::autoscroll_canvas ()
 
                        dx = pixel_to_sample (dx);
 
+                       dx /= 10;  //ToDo:  make a config variable for scroll speed  zoom-behavior-tweaks
+
                        if (leftmost_frame >= dx) {
                                new_frame = leftmost_frame - dx;
                        } else {