Editor zoom: add zoom_to_extents()
authorBen Loftis <ben@harrisonconsoles.com>
Sun, 27 Aug 2017 04:06:29 +0000 (23:06 -0500)
committerBen Loftis <ben@harrisonconsoles.com>
Sun, 27 Aug 2017 04:06:29 +0000 (23:06 -0500)
gtk2_ardour/ardour.menus.in
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_canvas.cc
gtk2_ardour/editor_ops.cc

index 668df5c905ff088b0d6c99a26410aebcd407c2a0..855f5679f44804ef4c78b1f35e345a29b06f3440 100644 (file)
         <menuitem action='temporal-zoom-in'/>
         <menuitem action='temporal-zoom-out'/>
         <menuitem action='zoom-to-session'/>
+        <menuitem action='zoom-to-extents'/>
         <menuitem action='zoom-to-selection'/>
         <menuitem action='zoom-to-selection-horiz'/>
         <menuitem action='fit-selection'/>
index d525761140384c43e4fa42f62ba05cf14d06d60e..210f6350befe8e38c7ab4f938a0f15c9987b69e8 100644 (file)
@@ -3782,6 +3782,7 @@ Editor::build_track_count_menu ()
                zoom_preset_selector.AddMenuElem (MenuElem (_("Zoom to 8 hours"), sigc::bind (sigc::mem_fun(*this, &Editor::set_zoom_preset), 8 * 60 * 60 * 1000)));
                zoom_preset_selector.AddMenuElem (MenuElem (_("Zoom to 24 hours"), sigc::bind (sigc::mem_fun(*this, &Editor::set_zoom_preset), 24 * 60 * 60 * 1000)));
                zoom_preset_selector.AddMenuElem (MenuElem (_("Zoom to Session"), sigc::mem_fun(*this, &Editor::temporal_zoom_session)));
+               zoom_preset_selector.AddMenuElem (MenuElem (_("Zoom to Extents"), sigc::mem_fun(*this, &Editor::temporal_zoom_extents)));
                zoom_preset_selector.AddMenuElem (MenuElem (_("Zoom to Range/Region Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_selection), Horizontal)));
        }
 }
index b43beff9bc4c0818d680f7ec70804a46c391ae38..68ba1101234b985522252bf44a7b63ce0affc96c 100644 (file)
@@ -365,7 +365,7 @@ public:
        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; 
+       std::pair <framepos_t,framepos_t> session_gui_extents( bool use_extra = true ) const; 
 
        /* fades */
 
@@ -1342,6 +1342,7 @@ private:
        void calc_extra_zoom_edges(framepos_t &start, framepos_t &end);
        void temporal_zoom_selection (Editing::ZoomAxis);
        void temporal_zoom_session ();
+       void temporal_zoom_extents ();
        void temporal_zoom (framecnt_t samples_per_pixel);
        void temporal_zoom_by_frame (framepos_t start, framepos_t end);
        void temporal_zoom_to_frame (bool coarser, framepos_t frame);
index 14d82fc3cec462e61772777569e5c554460c13a7..8a447beecf1f98898d3b7344fb4e26e8a5602b73 100644 (file)
@@ -276,6 +276,7 @@ Editor::register_actions ()
        reg_sens (editor_actions, "temporal-zoom-out", _("Zoom Out"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_step), true));
        reg_sens (editor_actions, "temporal-zoom-in", _("Zoom In"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_step), false));
        reg_sens (editor_actions, "zoom-to-session", _("Zoom to Session"), sigc::mem_fun(*this, &Editor::temporal_zoom_session));
+       reg_sens (editor_actions, "zoom-to-extents", _("Zoom to Extents"), sigc::mem_fun(*this, &Editor::temporal_zoom_extents));
        reg_sens (editor_actions, "zoom-to-selection", _("Zoom to Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_selection), Both));
        reg_sens (editor_actions, "zoom-to-selection-horiz", _("Zoom to Selection (Horizontal)"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_selection), Horizontal));
        reg_sens (editor_actions, "toggle-zoom", _("Toggle Zoom State"), sigc::mem_fun(*this, &Editor::swap_visual_state));
index 729034a2049d24228918b5b7d68a7d389dc009ea..56571c3de886e7c36d52c6fd0bd69f784bb3c820 100644 (file)
@@ -582,7 +582,7 @@ Editor::autoscroll_active () const
 }
 
 std::pair <framepos_t,framepos_t>
-Editor::session_gui_extents () const
+Editor::session_gui_extents ( bool use_extra ) const
 {
        if (!_session) {
                return std::pair <framepos_t,framepos_t>(max_framepos,0);
@@ -616,10 +616,12 @@ Editor::session_gui_extents () const
        //ToDo: also incorporate automation regions (in case the session has no audio/midi but is just used for automating plugins or the like)
 
        //add additional time to the ui extents ( user-defined in config )
-       framecnt_t const extra = UIConfiguration::instance().get_extra_ui_extents_time() * 60 * _session->nominal_frame_rate();
-       session_extent_end += extra;
-       session_extent_start -= extra;
-               
+       if (use_extra) {
+               framecnt_t const extra = UIConfiguration::instance().get_extra_ui_extents_time() * 60 * _session->nominal_frame_rate();
+               session_extent_end += extra;
+               session_extent_start -= extra;
+       }
+                       
        //range-check
        if (session_extent_end > max_framepos) {
                session_extent_end = max_framepos;
index f8c7a9c5467538f3294e26d54b568641fa190902..41fe50d6ef59b79db0853c9807733588500bc128 100644 (file)
@@ -2058,6 +2058,39 @@ Editor::temporal_zoom_session ()
        }
 }
 
+void
+Editor::temporal_zoom_extents ()
+{
+       ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_extents)
+
+       if (_session) {
+               std::pair<framepos_t, framepos_t> ext = session_gui_extents( false );  //in this case we want to zoom to the extents explicitly; ignore the users prefs for extra padding
+
+               framecnt_t start = ext.first;
+               framecnt_t end = ext.second;
+
+               if (_session->actively_recording () ) {
+                       framepos_t cur = playhead_cursor->current_frame ();
+                       if (cur > end) {
+                               /* recording beyond the end marker; zoom out
+                                * by 5 seconds more so that if 'follow
+                                * playhead' is active we don't immediately
+                                * scroll.
+                                */
+                               end = cur + _session->frame_rate() * 5;
+                       }
+               }
+
+               if ((start == 0 && end == 0) || end < start) {
+                       return;
+               }
+
+               calc_extra_zoom_edges(start, end);
+
+               temporal_zoom_by_frame (start, end);
+       }
+}
+
 void
 Editor::temporal_zoom_by_frame (framepos_t start, framepos_t end)
 {