From 89623923bdc475381bfb8b0d318b7284920e05fc Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Tue, 13 Dec 2016 09:20:44 +1000 Subject: Change Zoom to Selection action (Z key) to zoom on both axes 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 | 1 + gtk2_ardour/editing.h | 6 ++++ gtk2_ardour/editor.cc | 4 +-- gtk2_ardour/editor.h | 3 +- gtk2_ardour/editor_actions.cc | 3 +- gtk2_ardour/editor_ops.cc | 66 +++++-------------------------------------- 6 files changed, 19 insertions(+), 64 deletions(-) diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index e15474a6a9..4325749e38 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -455,6 +455,7 @@ + diff --git a/gtk2_ardour/editing.h b/gtk2_ardour/editing.h index 8dd6f2ed6c..8b6f6d9f67 100644 --- a/gtk2_ardour/editing.h +++ b/gtk2_ardour/editing.h @@ -215,6 +215,12 @@ enum EditIgnoreOption { EDIT_IGNORE_MARKER }; +enum ZoomAxis { + Vertical, + Horizontal, + Both +}; + } // namespace Editing #endif // __gtk_ardour_editing_h__ diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index c7ad5b49c5..07969f4c07 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -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))); } } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 4b2fc8222d..68c9814556 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -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); diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index c2f5d15162..43169f7d49 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -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)); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 6171c77d2e..370f57d848 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -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 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 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::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 -- cgit v1.2.3