From: Ben Loftis Date: Sun, 27 Aug 2017 04:06:29 +0000 (-0500) Subject: Editor zoom: add zoom_to_extents() X-Git-Tag: 5.12~73 X-Git-Url: https://main.carlh.net/gitweb/?p=ardour.git;a=commitdiff_plain;h=631629b8e7d3ca826fc55901653c1c795a8a5083 Editor zoom: add zoom_to_extents() --- diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index 668df5c905..855f5679f4 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -449,6 +449,7 @@ + diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index d525761140..210f6350be 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -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))); } } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index b43beff9bc..68ba110123 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -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 session_gui_extents() const; + std::pair 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); diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index 14d82fc3ce..8a447beecf 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -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)); diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index 729034a204..56571c3de8 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -582,7 +582,7 @@ Editor::autoscroll_active () const } std::pair -Editor::session_gui_extents () const +Editor::session_gui_extents ( bool use_extra ) const { if (!_session) { return std::pair (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; diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index f8c7a9c546..41fe50d6ef 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -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 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) {