Change Zoom to Selection action (Z key) to zoom on both axes
authorTim Mayberry <mojofunk@gmail.com>
Mon, 12 Dec 2016 23:20:44 +0000 (09:20 +1000)
committerTim Mayberry <mojofunk@gmail.com>
Tue, 13 Dec 2016 02:25:03 +0000 (12:25 +1000)
Add Zoom to Selection (Horizontal) action to access previous behavior.

Remove Editor::temporal_zoom_region as it was duplicate code and broken for
both_axes

Should Resolve: #7112

gtk2_ardour/ardour.menus.in
gtk2_ardour/editing.h
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_ops.cc

index e15474a6a9542e0459aa1c12d55fe9aba51330f1..4325749e38c98939eca92c9554b026fe66b841aa 100644 (file)
         <menuitem action='temporal-zoom-out'/>
         <menuitem action='zoom-to-session'/>
         <menuitem action='zoom-to-selection'/>
+        <menuitem action='zoom-to-selection-horiz'/>
         <menuitem action='fit-selection'/>
         <menuitem action='toggle-zoom'/>
         <menuitem action='expand-tracks'/>
index 8dd6f2ed6c3587266fa694dca9ff6bd29d1d507d..8b6f6d9f6717e7fbb4be8592b17e361baf0cccae 100644 (file)
@@ -215,6 +215,12 @@ enum EditIgnoreOption {
        EDIT_IGNORE_MARKER
 };
 
+enum ZoomAxis {
+       Vertical,
+       Horizontal,
+       Both
+};
+
 } // namespace Editing
 
 #endif // __gtk_ardour_editing_h__
index c7ad5b49c540748bdc9673abcd042df3fee12c5b..07969f4c078405c995bde5ea294b228c48596031 100644 (file)
@@ -1947,7 +1947,7 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
        edit_items.push_back (MenuElem (_("Loop Range"), sigc::bind (sigc::mem_fun(*this, &Editor::set_loop_from_selection), true)));
 
        edit_items.push_back (SeparatorElem());
-       edit_items.push_back (MenuElem (_("Zoom to Range"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_selection), false)));
+       edit_items.push_back (MenuElem (_("Zoom to Range"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_selection), ZoomAxis::Horizontal)));
 
        edit_items.push_back (SeparatorElem());
        edit_items.push_back (MenuElem (_("Loudness Analysis"), sigc::mem_fun(*this, &Editor::loudness_analyze_range_selection)));
@@ -3794,7 +3794,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 Range/Region Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_selection), false)));
+               zoom_preset_selector.AddMenuElem (MenuElem (_("Zoom to Range/Region Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_selection), ZoomAxis::Horizontal)));
        }
 }
 
index 4b2fc8222de6cf2971a62e522a67d4ecd47a4db1..68c9814556eb70fa2e28d3e0849e8ea502362d92 100644 (file)
@@ -1304,8 +1304,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void loop_location (ARDOUR::Location&);
 
        void calc_extra_zoom_edges(framepos_t &start, framepos_t &end);
-       void temporal_zoom_selection (bool both_axes = false);
-       void temporal_zoom_region (bool both_axes);
+       void temporal_zoom_selection (Editing::ZoomAxis);
        void temporal_zoom_session ();
        void temporal_zoom (framecnt_t samples_per_pixel);
        void temporal_zoom_by_frame (framepos_t start, framepos_t end);
index c2f5d1516234cd6a62fc8f73f2d5aa44a9474af6..43169f7d497cad4d1cdd70d9979ce64f9d9b4bd2 100644 (file)
@@ -276,7 +276,8 @@ 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-selection", _("Zoom to Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_selection), false));
+       reg_sens (editor_actions, "zoom-to-selection", _("Zoom to Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_selection), ZoomAxis::Both));
+       reg_sens (editor_actions, "zoom-to-selection-horiz", _("Zoom to Selection (Horizontal)"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_selection), ZoomAxis::Horizontal));
        reg_sens (editor_actions, "toggle-zoom", _("Toggle Zoom State"), sigc::mem_fun(*this, &Editor::swap_visual_state));
 
        reg_sens (editor_actions, "expand-tracks", _("Expand Track Height"), sigc::bind (sigc::mem_fun (*this, &Editor::tav_zoom_step), false));
index 6171c77d2e680e17f7a101cea06bc8adcbad8d05..370f57d848120a3e50dfbd619014f82b57814ca2 100644 (file)
@@ -1922,53 +1922,6 @@ Editor::calc_extra_zoom_edges(framepos_t &start, framepos_t &end)
        }
 }
 
-void
-Editor::temporal_zoom_region (bool both_axes)
-{
-       framepos_t start = max_framepos;
-       framepos_t end = 0;
-       set<TimeAxisView*> tracks;
-
-       if ( !get_selection_extents(start, end) )
-               return;
-
-       calc_extra_zoom_edges (start, end);
-
-       /* if we're zooming on both axes we need to save track heights etc.
-        */
-
-       undo_visual_stack.push_back (current_visual_state (both_axes));
-
-       PBD::Unwinder<bool> nsv (no_save_visual, true);
-
-       temporal_zoom_by_frame (start, end);
-
-       if (both_axes) {
-               uint32_t per_track_height = (uint32_t) floor ((_visible_canvas_height - 10.0) / tracks.size());
-
-               /* set visible track heights appropriately */
-
-               for (set<TimeAxisView*>::iterator t = tracks.begin(); t != tracks.end(); ++t) {
-                       (*t)->set_height (per_track_height);
-               }
-
-               /* hide irrelevant tracks */
-
-               DisplaySuspender ds;
-
-               for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
-                       if (find (tracks.begin(), tracks.end(), (*i)) == tracks.end()) {
-                               hide_track_in_display (*i);
-                       }
-               }
-
-               vertical_adjustment.set_value (0.0);
-       }
-
-       redo_visual_stack.push_back (current_visual_state (both_axes));
-}
-
-
 bool
 Editor::get_selection_extents (framepos_t &start, framepos_t &end) const
 {
@@ -2010,7 +1963,7 @@ Editor::get_selection_extents (framepos_t &start, framepos_t &end) const
 
 
 void
-Editor::temporal_zoom_selection (bool both_axes)
+Editor::temporal_zoom_selection (Editing::ZoomAxis axes)
 {
        if (!selection) return;
 
@@ -2018,23 +1971,18 @@ Editor::temporal_zoom_selection (bool both_axes)
 
        //ToDo:  if control points are selected, zoom to that
 
-       //if region(s) are selected, zoom to that
-       if ( !selection->regions.empty() )
-               temporal_zoom_region (both_axes);
-
-       //if a range is selected, zoom to that
-       if (!selection->time.empty()) {
+       if (axes == Horizontal || axes == Both) {
 
-               framepos_t start,  end;
+               framepos_t start, end;
                if (get_selection_extents (start, end)) {
-                       calc_extra_zoom_edges(start, end);
+                       calc_extra_zoom_edges (start, end);
                        temporal_zoom_by_frame (start, end);
                }
-
-               if (both_axes)
-                       fit_selection();
        }
 
+       if (axes == Vertical || axes == Both) {
+               fit_selection ();
+       }
 }
 
 void