diff --git a/gtk2_ardour/ardour.keys.in b/gtk2_ardour/ardour.keys.in index 9fa05aa8b6..c421947ecf 100644 --- a/gtk2_ardour/ardour.keys.in +++ b/gtk2_ardour/ardour.keys.in @@ -209,7 +209,7 @@ This mode provides many different operations on both regions and control points, @edit|Editor/multi-duplicate| <@SECONDARY@>d|duplicate (multi) @select|Editor/select-all-in-punch-range| <@TERTIARY@>d|select all in punch range @vis|Editor/fit-selection| f|fit selection vertically -@edit|Editor/toggle-follow-playhead| <@PRIMARY@>f|toggle playhead tracking +@edit|Editing/toggle-follow-playhead| <@PRIMARY@>f|toggle playhead tracking @edit|Editor/toggle-stationary-playhead| <@TERTIARY@>f|toggle stationary playhead @rop|Region/show-rhythm-ferret| <@SECONDARY@>f|show rhythm ferret window @wvis|Common/ToggleMaximalEditor| <@PRIMARY@><@SECONDARY@>f|maximise editor space diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index c0ff58d659..25ddc0289d 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -186,7 +186,7 @@ - + diff --git a/gtk2_ardour/cue_editor.cc b/gtk2_ardour/cue_editor.cc index 474414d801..ee96e4b5ac 100644 --- a/gtk2_ardour/cue_editor.cc +++ b/gtk2_ardour/cue_editor.cc @@ -198,13 +198,6 @@ CueEditor::step_mouse_mode (bool next) { } - -void -CueEditor::reset_x_origin_to_follow_playhead () -{ -} - - Gdk::Cursor* CueEditor::get_canvas_cursor () const { diff --git a/gtk2_ardour/cue_editor.h b/gtk2_ardour/cue_editor.h index ee275f8521..7f58dbc4e2 100644 --- a/gtk2_ardour/cue_editor.h +++ b/gtk2_ardour/cue_editor.h @@ -97,8 +97,6 @@ class CueEditor : public EditingContext, public PBD::HistoryOwner void end_local_tempo_map (std::shared_ptr); protected: - void reset_x_origin_to_follow_playhead (); - void do_undo (uint32_t n); void do_redo (uint32_t n); diff --git a/gtk2_ardour/editing_context.cc b/gtk2_ardour/editing_context.cc index a86a3e57e6..839f39f758 100644 --- a/gtk2_ardour/editing_context.cc +++ b/gtk2_ardour/editing_context.cc @@ -40,6 +40,7 @@ #include "edit_note_dialog.h" #include "editing_context.h" #include "editing_convert.h" +#include "editor_cursors.h" #include "editor_drag.h" #include "grid_lines.h" #include "gui_thread.h" @@ -310,6 +311,8 @@ EditingContext::register_common_actions (Bindings* common_bindings, std::string reg_sens (_common_actions, "temporal-zoom-out", _("Zoom Out"), sigc::bind (sigc::mem_fun (*this, &EditingContext::temporal_zoom_step), true)); reg_sens (_common_actions, "temporal-zoom-in", _("Zoom In"), sigc::bind (sigc::mem_fun (*this, &EditingContext::temporal_zoom_step), false)); + toggle_reg_sens (_common_actions, "toggle-follow-playhead", _("Follow Playhead"), (sigc::mem_fun(*this, &EditingContext::toggle_follow_playhead))); + undo_action = reg_sens (_common_actions, "undo", S_("Command|Undo"), sigc::bind (sigc::mem_fun (*this, &EditingContext::undo), 1U)); redo_action = reg_sens (_common_actions, "redo", _("Redo"), sigc::bind (sigc::mem_fun (*this, &EditingContext::redo), 1U)); alternate_redo_action = reg_sens (_common_actions, "alternate-redo", _("Redo"), sigc::bind (sigc::mem_fun (*this, &EditingContext::redo), 1U)); @@ -1315,7 +1318,7 @@ EditingContext::time_domain () const void EditingContext::toggle_follow_playhead () { - RefPtr tact = ActionManager::get_toggle_action (X_("Editor"), X_("toggle-follow-playhead")); + RefPtr tact = ActionManager::get_toggle_action ((_name + X_("Editing")).c_str(), X_("toggle-follow-playhead")); set_follow_playhead (tact->get_active()); } @@ -2166,7 +2169,7 @@ EditingContext::bind_mouse_mode_buttons () act = ActionManager::get_action ((_name + X_("Editing")).c_str(), X_("temporal-zoom-out")); zoom_out_button.set_related_action (act); - act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead")); + act = ActionManager::get_action ((_name + X_("Editing")).c_str(), X_("toggle-follow-playhead")); follow_playhead_button.set_related_action (act); act = ActionManager::get_action (X_("Transport"), X_("ToggleFollowEdits")); @@ -3395,3 +3398,83 @@ EditingContext::allow_trim_cursors () const { return mouse_mode == MouseContent || mouse_mode == MouseTimeFX || mouse_mode == MouseDraw; } + +/** Queue a change for the Editor viewport x origin to follow the playhead */ +void +EditingContext::reset_x_origin_to_follow_playhead () +{ + assert (_session); + + samplepos_t const sample = _playhead_cursor->current_sample (); + + if (sample < _leftmost_sample || sample > _leftmost_sample + current_page_samples()) { + + if (_session->transport_speed() < 0) { + + if (sample > (current_page_samples() / 2)) { + center_screen (sample-(current_page_samples()/2)); + } else { + center_screen (current_page_samples()/2); + } + + } else { + + samplepos_t l = 0; + + if (sample < _leftmost_sample) { + /* moving left */ + if (_session->transport_rolling()) { + /* rolling; end up with the playhead at the right of the page */ + l = sample - current_page_samples (); + } else { + /* not rolling: end up with the playhead 1/4 of the way along the page */ + l = sample - current_page_samples() / 4; + } + } else { + /* moving right */ + if (_session->transport_rolling()) { + /* rolling: end up with the playhead on the left of the page */ + l = sample; + } else { + /* not rolling: end up with the playhead 3/4 of the way along the page */ + l = sample - 3 * current_page_samples() / 4; + } + } + + if (l < 0) { + l = 0; + } + + center_screen_internal (l + (current_page_samples() / 2), current_page_samples ()); + } + } +} + + +void +EditingContext::center_screen (samplepos_t sample) +{ + samplecnt_t const page = _visible_canvas_width * samples_per_pixel; + + /* if we're off the page, then scroll. + */ + + if (sample < _leftmost_sample || sample >= _leftmost_sample + page) { + center_screen_internal (sample, page); + } +} + +void +EditingContext::center_screen_internal (samplepos_t sample, float page) +{ + page /= 2; + + if (sample > page) { + sample -= (samplepos_t) page; + } else { + sample = 0; + } + + reset_x_origin (sample); +} + diff --git a/gtk2_ardour/editing_context.h b/gtk2_ardour/editing_context.h index d07be95c19..f9d16a7df0 100644 --- a/gtk2_ardour/editing_context.h +++ b/gtk2_ardour/editing_context.h @@ -494,6 +494,9 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider, virtual bool allow_trim_cursors () const; virtual void make_a_region() {} + void center_screen (samplepos_t); + void reset_x_origin_to_follow_playhead (); + protected: std::string _name; bool within_track_canvas; @@ -592,7 +595,6 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider, EditorCursor* _snapped_cursor; bool _follow_playhead; - virtual void reset_x_origin_to_follow_playhead () = 0; /* selection process */ @@ -813,4 +815,7 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider, static Glib::RefPtr reg_sens (Glib::RefPtr group, char const* name, char const* label, sigc::slot slot); static void toggle_reg_sens (Glib::RefPtr group, char const* name, char const* label, sigc::slot slot); static void radio_reg_sens (Glib::RefPtr action_group, Gtk::RadioAction::Group& radio_group, char const* name, char const* label, sigc::slot slot); + + void center_screen_internal (samplepos_t, float); + }; diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 8bb6f1f541..f3b49b40ac 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -661,6 +661,7 @@ Editor::Editor () load_bindings (); register_actions (); + bind_mouse_mode_buttons (); setup_toolbar (); @@ -1161,34 +1162,6 @@ Editor::map_position_change (samplepos_t sample) update_section_box (); } -void -Editor::center_screen (samplepos_t sample) -{ - samplecnt_t const page = _visible_canvas_width * samples_per_pixel; - - /* if we're off the page, then scroll. - */ - - if (sample < _leftmost_sample || sample >= _leftmost_sample + page) { - center_screen_internal (sample, page); - } -} - -void -Editor::center_screen_internal (samplepos_t sample, float page) -{ - page /= 2; - - if (sample > page) { - sample -= (samplepos_t) page; - } else { - sample = 0; - } - - reset_x_origin (sample); -} - - void Editor::update_title () { @@ -2360,7 +2333,7 @@ Editor::set_state (const XMLNode& node, int version) */ RefPtr tact; - tact = ActionManager::get_toggle_action (X_("Editor"), X_("toggle-follow-playhead")); + tact = ActionManager::get_toggle_action ((editor_name () + X_("Editing")).c_str(), X_("toggle-follow-playhead")); yn = _follow_playhead; if (tact->get_active() != yn) { tact->set_active (yn); @@ -5223,55 +5196,6 @@ Editor::scroll_release () _scroll_connection.disconnect (); } -/** Queue a change for the Editor viewport x origin to follow the playhead */ -void -Editor::reset_x_origin_to_follow_playhead () -{ - samplepos_t const sample = _playhead_cursor->current_sample (); - - if (sample < _leftmost_sample || sample > _leftmost_sample + current_page_samples()) { - - if (_session->transport_speed() < 0) { - - if (sample > (current_page_samples() / 2)) { - center_screen (sample-(current_page_samples()/2)); - } else { - center_screen (current_page_samples()/2); - } - - } else { - - samplepos_t l = 0; - - if (sample < _leftmost_sample) { - /* moving left */ - if (_session->transport_rolling()) { - /* rolling; end up with the playhead at the right of the page */ - l = sample - current_page_samples (); - } else { - /* not rolling: end up with the playhead 1/4 of the way along the page */ - l = sample - current_page_samples() / 4; - } - } else { - /* moving right */ - if (_session->transport_rolling()) { - /* rolling: end up with the playhead on the left of the page */ - l = sample; - } else { - /* not rolling: end up with the playhead 3/4 of the way along the page */ - l = sample - 3 * current_page_samples() / 4; - } - } - - if (l < 0) { - l = 0; - } - - center_screen_internal (l + (current_page_samples() / 2), current_page_samples ()); - } - } -} - void Editor::super_rapid_screen_update () { diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 058f6eb89b..639a5b4ace 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -372,8 +372,6 @@ public: double get_y_origin () const; void reposition_and_zoom (samplepos_t, double); - void reset_x_origin_to_follow_playhead (); - void toggle_meter_updating(); void show_rhythm_ferret(); @@ -408,8 +406,6 @@ public: void get_regionviews_by_id (PBD::ID const id, RegionSelection & regions) const; void get_per_region_note_selection (std::list > > > >&) const; - void center_screen (samplepos_t); - TrackViewList axis_views_from_routes (std::shared_ptr) const; void set_snapped_cursor_position (Temporal::timepos_t const & pos); @@ -1099,7 +1095,6 @@ private: sigc::connection _tvl_redisplay_connection; sigc::connection super_rapid_screen_update_connection; - void center_screen_internal (samplepos_t, float); void super_rapid_screen_update (); diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index 434c10cbf7..3b2c68b3d6 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -472,7 +472,6 @@ Editor::register_actions () sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), true, true) ); - toggle_reg_sens (editor_actions, "toggle-follow-playhead", _("Follow Playhead"), (sigc::mem_fun(*this, &Editor::toggle_follow_playhead))); act = reg_sens (editor_actions, "remove-last-capture", _("Remove Last Capture"), (sigc::mem_fun(*this, &Editor::remove_last_capture))); act = reg_sens (editor_actions, "tag-last-capture", _("Tag Last Capture"), (sigc::mem_fun(*this, &Editor::tag_last_capture))); @@ -545,8 +544,6 @@ Editor::register_actions () act->set_sensitive (false); } - bind_mouse_mode_buttons (); - ActionManager::register_action (editor_actions, "step-mouse-mode", _("Step Mouse Mode"), sigc::bind (sigc::mem_fun(*this, &Editor::step_mouse_mode), true)); RadioAction::Group edit_point_group; diff --git a/gtk2_ardour/pianoroll.cc b/gtk2_ardour/pianoroll.cc index 1a29ff8d2f..cb6136b822 100644 --- a/gtk2_ardour/pianoroll.cc +++ b/gtk2_ardour/pianoroll.cc @@ -92,6 +92,7 @@ Pianoroll::Pianoroll (std::string const & name, bool with_transport) load_bindings (); register_actions (); + bind_mouse_mode_buttons (); set_mouse_mode (Editing::MouseContent, true); } @@ -755,6 +756,10 @@ Pianoroll::maybe_update () } else { _playhead_cursor->set_position (0); } + + if (_follow_playhead) { + reset_x_origin_to_follow_playhead (); + } } bool diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index b1dda8def2..295a0081a6 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -397,8 +397,6 @@ public: virtual void set_current_trimmable (std::shared_ptr) = 0; virtual void set_current_movable (std::shared_ptr) = 0; - virtual void center_screen (samplepos_t) = 0; - virtual TrackViewList const & get_track_views () const = 0; virtual MixerStrip* get_current_mixer_strip () const = 0;