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
This commit is contained in:
parent
989f934c38
commit
89623923bd
|
@ -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'/>
|
||||
|
|
|
@ -215,6 +215,12 @@ enum EditIgnoreOption {
|
|||
EDIT_IGNORE_MARKER
|
||||
};
|
||||
|
||||
enum ZoomAxis {
|
||||
Vertical,
|
||||
Horizontal,
|
||||
Both
|
||||
};
|
||||
|
||||
} // namespace Editing
|
||||
|
||||
#endif // __gtk_ardour_editing_h__
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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 (axes == Horizontal || axes == Both) {
|
||||
|
||||
//if a range is selected, zoom to that
|
||||
if (!selection->time.empty()) {
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue