summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2016-12-13 09:20:44 +1000
committerTim Mayberry <mojofunk@gmail.com>2016-12-13 12:25:03 +1000
commit89623923bdc475381bfb8b0d318b7284920e05fc (patch)
tree1e3c019e950803bb91cff301bebd44c2dfa3c88b
parent989f934c3825fb600decc467770fea6f802a60b1 (diff)
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
-rw-r--r--gtk2_ardour/ardour.menus.in1
-rw-r--r--gtk2_ardour/editing.h6
-rw-r--r--gtk2_ardour/editor.cc4
-rw-r--r--gtk2_ardour/editor.h3
-rw-r--r--gtk2_ardour/editor_actions.cc3
-rw-r--r--gtk2_ardour/editor_ops.cc66
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 @@
<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'/>
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<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