From 4f5848d85c968e1a1158bfd53108127e5846049b Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 8 Aug 2025 11:35:14 -0600 Subject: [PATCH] action-ify stationary playhead mgmt; fix up follow-playhead action handling --- gtk2_ardour/ardour.keys.in | 4 +-- gtk2_ardour/ardour.menus.in | 2 +- gtk2_ardour/editing_context.cc | 65 ++++++++++++++++++++++++---------- gtk2_ardour/editing_context.h | 13 ++++++- gtk2_ardour/editor.cc | 25 ++----------- gtk2_ardour/editor.h | 12 ------- gtk2_ardour/editor_actions.cc | 2 -- gtk2_ardour/public_editor.h | 5 --- 8 files changed, 63 insertions(+), 65 deletions(-) diff --git a/gtk2_ardour/ardour.keys.in b/gtk2_ardour/ardour.keys.in index 5bad418aed..839936a471 100644 --- a/gtk2_ardour/ardour.keys.in +++ b/gtk2_ardour/ardour.keys.in @@ -210,8 +210,8 @@ 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|Editing/toggle-follow-playhead| <@PRIMARY@>f|toggle playhead tracking -@edit|Editor/toggle-stationary-playhead| <@TERTIARY@>f|toggle stationary playhead +@edit|EditorEditing/toggle-follow-playhead| <@PRIMARY@>f|toggle playhead tracking +@edit|EditorEditing/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 @wvis|Common/ToggleMaximalMixer| <@PRIMARY@><@TERTIARY@>f|maximise mixer space diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index d66a2fb919..8e18630777 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -187,7 +187,7 @@ - + diff --git a/gtk2_ardour/editing_context.cc b/gtk2_ardour/editing_context.cc index 3200666009..723f520142 100644 --- a/gtk2_ardour/editing_context.cc +++ b/gtk2_ardour/editing_context.cc @@ -153,6 +153,8 @@ EditingContext::EditingContext (std::string const & name) , grid_lines (nullptr) , time_line_group (nullptr) , temporary_zoom_focus_change (false) + , _dragging_playhead (false) + { using namespace Gtk::Menu_Helpers; @@ -338,6 +340,10 @@ EditingContext::set_action_defaults () follow_playhead_action->set_active (true); follow_playhead_action->set_active (false); #endif + + stationary_playhead_action->set_active (true); + stationary_playhead_action->set_active (false); + mouse_mode_actions[Editing::MouseObject]->set_active (false); mouse_mode_actions[Editing::MouseObject]->set_active (true); zoom_focus_actions[Editing::ZoomFocusLeft]->set_active (false); @@ -373,10 +379,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 action that represents state */ - follow_playhead_action = toggle_reg_sens (_common_actions, "follow-playhead", _("Follow Playhead"), sigc::mem_fun (*this, &EditingContext::follow_playhead_chosen)); - /* invokable action that toggles the stateful action */ - reg_sens (_common_actions, "toggle-follow-playhead", _("Follow Playhead"), sigc::mem_fun (*this, &EditingContext::toggle_follow_playhead)); + follow_playhead_action = toggle_reg_sens (_common_actions, "toggle-follow-playhead", _("Follow Playhead"), sigc::mem_fun (*this, &EditingContext::follow_playhead_chosen)); + stationary_playhead_action = toggle_reg_sens (_common_actions, "toggle-stationary-playhead", _("Stationary Playhead"), (mem_fun(*this, &EditingContext::stationary_playhead_chosen))); 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)); @@ -1174,6 +1178,34 @@ EditingContext::time_domain () const return Temporal::BeatTime; } +void +EditingContext::toggle_stationary_playhead () +{ + stationary_playhead_action->set_active (!stationary_playhead_action->get_active ()); +} + +void +EditingContext::stationary_playhead_chosen () +{ + instant_save (); +} + +void +EditingContext::set_stationary_playhead (bool yn) +{ + stationary_playhead_action->set_active (yn); +} + +bool +EditingContext::stationary_playhead () const +{ + if (!stationary_playhead_action) { + return false; + } + + return stationary_playhead_action->get_active (); +} + void EditingContext::toggle_follow_playhead () { @@ -1200,6 +1232,16 @@ EditingContext::set_follow_playhead (bool yn, bool catch_up) } } +bool +EditingContext::follow_playhead() const +{ + if (!follow_playhead_action) { + return false; + } + + return follow_playhead_action->get_active (); +} + double EditingContext::time_to_pixel (timepos_t const & pos) const { @@ -2552,11 +2594,6 @@ EditingContext::play_note_selection_clicked () UIConfiguration::instance().set_sound_midi_notes (!UIConfiguration::instance().get_sound_midi_notes()); } -void -EditingContext::follow_playhead_clicked () -{ -} - void EditingContext::cycle_zoom_focus () { @@ -3227,13 +3264,3 @@ EditingContext::center_screen_internal (samplepos_t sample, float page) reset_x_origin (sample); } - -bool -EditingContext::follow_playhead() const -{ - if (!follow_playhead_action) { - return false; - } - - return follow_playhead_action->get_active (); -} diff --git a/gtk2_ardour/editing_context.h b/gtk2_ardour/editing_context.h index 75fcb70d98..0b5fa4ae87 100644 --- a/gtk2_ardour/editing_context.h +++ b/gtk2_ardour/editing_context.h @@ -503,6 +503,14 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider, void enable_automation_bindings (); void disable_automation_bindings (); + /* playhead/screen stuff */ + + void set_stationary_playhead (bool yn); + void toggle_stationary_playhead (); + bool stationary_playhead() const; + + bool dragging_playhead () const { return _dragging_playhead; } + protected: std::string _name; bool within_track_canvas; @@ -573,7 +581,6 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider, virtual void play_note_selection_clicked(); virtual void note_mode_clicked() {} - virtual void follow_playhead_clicked (); virtual void full_zoom_clicked() {}; virtual void set_visible_channel (int) {} @@ -596,6 +603,9 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider, Glib::RefPtr follow_playhead_action; void follow_playhead_chosen (); + Glib::RefPtr stationary_playhead_action; + void stationary_playhead_chosen (); + /* selection process */ Selection* selection; @@ -821,4 +831,5 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider, virtual void automation_move_points_earlier () {}; bool temporary_zoom_focus_change; + bool _dragging_playhead; }; diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 7ebf1a198b..b5a11c3cd2 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -315,9 +315,7 @@ Editor::Editor () , ignore_gui_changes (false) , lock_dialog (nullptr) , _last_event_time (g_get_monotonic_time ()) - , _dragging_playhead (false) , ignore_map_change (false) - , _stationary_playhead (false) , _maximised (false) , global_rect_group (nullptr) , tempo_marker_menu (nullptr) @@ -2358,7 +2356,7 @@ Editor::get_state () const node->set_property ("maximised", _maximised); node->set_property ("follow-playhead", follow_playhead()); - node->set_property ("stationary-playhead", _stationary_playhead); + node->set_property ("stationary-playhead", stationary_playhead()); node->set_property ("mouse-mode", current_mouse_mode()); node->set_property ("join-object-range", smart_mode_action->get_active ()); @@ -3406,25 +3404,6 @@ Editor::cycle_marker_click_behavior () } } -void -Editor::toggle_stationary_playhead () -{ - RefPtr tact = ActionManager::get_toggle_action (X_("Editor"), X_("toggle-stationary-playhead")); - set_stationary_playhead (tact->get_active()); -} - -void -Editor::set_stationary_playhead (bool yn) -{ - if (_stationary_playhead != yn) { - if ((_stationary_playhead = yn) == true) { - /* catch up -- FIXME need a 3.0 equivalent of this 2.X call */ - // update_current_screen (); - } - instant_save (); - } -} - bool Editor::show_touched_automation() const { @@ -5310,7 +5289,7 @@ Editor::super_rapid_screen_update () return; } - if (!_stationary_playhead) { + if (!stationary_playhead()) { reset_x_origin_to_follow_playhead (); } else { samplepos_t const sample = _playhead_cursor->current_sample (); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index b2d0b57f03..3729088504 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -320,14 +320,6 @@ public: void sequence_regions (); - /* playhead/screen stuff */ - - void set_stationary_playhead (bool yn); - void toggle_stationary_playhead (); - bool stationary_playhead() const { return _stationary_playhead; } - - bool dragging_playhead () const { return _dragging_playhead; } - void toggle_zero_line_visibility (); void set_summary (); void set_group_tabs (); @@ -1488,8 +1480,6 @@ private: ARDOUR::PlaylistSet motion_frozen_playlists; - bool _dragging_playhead; - void marker_drag_motion_callback (GdkEvent*); void marker_drag_finished_callback (GdkEvent*); @@ -1645,8 +1635,6 @@ private: /* display control */ - /// true if we scroll the tracks rather than the playhead - bool _stationary_playhead; /// true if we are in fullscreen mode bool _maximised; diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index 24093e3636..2e5970bced 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -478,8 +478,6 @@ Editor::register_actions () 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))); - ActionManager::register_toggle_action (editor_actions, "toggle-stationary-playhead", _("Stationary Playhead"), (mem_fun(*this, &Editor::toggle_stationary_playhead))); - show_touched_automation_action = ActionManager::register_toggle_action (editor_actions, "show-touched-automation", _("Show Automation Lane on Touch"), (mem_fun(*this, &Editor::toggle_show_touched_automation))); act = reg_sens (editor_actions, "insert-time", _("Insert Time"), (sigc::mem_fun(*this, &Editor::do_insert_time))); diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 295a0081a6..eb0e46b9bf 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -278,14 +278,9 @@ public: virtual void hide_track_in_display (TimeAxisView* tv, bool apply_to_selection = false) = 0; virtual void show_track_in_display (TimeAxisView* tv, bool move_into_view = false) = 0; - virtual void set_stationary_playhead (bool yn) = 0; - virtual void toggle_stationary_playhead () = 0; - virtual bool stationary_playhead() const = 0; - virtual void toggle_cue_behavior () = 0; /** @return true if the playhead is currently being dragged, otherwise false */ - virtual bool dragging_playhead () const = 0; virtual samplepos_t leftmost_sample() const = 0; virtual samplecnt_t current_page_samples() const = 0; virtual double visible_canvas_height () const = 0;