action-ify stationary playhead mgmt; fix up follow-playhead action handling

This commit is contained in:
Paul Davis 2025-08-08 11:35:14 -06:00
parent 2be15f035d
commit 4f5848d85c
8 changed files with 63 additions and 65 deletions

View file

@ -210,8 +210,8 @@ This mode provides many different operations on both regions and control points,
@edit|Editor/multi-duplicate| <@SECONDARY@>d|duplicate (multi) @edit|Editor/multi-duplicate| <@SECONDARY@>d|duplicate (multi)
@select|Editor/select-all-in-punch-range| <@TERTIARY@>d|select all in punch range @select|Editor/select-all-in-punch-range| <@TERTIARY@>d|select all in punch range
@vis|Editor/fit-selection| f|fit selection vertically @vis|Editor/fit-selection| f|fit selection vertically
@edit|Editing/toggle-follow-playhead| <@PRIMARY@>f|toggle playhead tracking @edit|EditorEditing/toggle-follow-playhead| <@PRIMARY@>f|toggle playhead tracking
@edit|Editor/toggle-stationary-playhead| <@TERTIARY@>f|toggle stationary playhead @edit|EditorEditing/toggle-stationary-playhead| <@TERTIARY@>f|toggle stationary playhead
@rop|Region/show-rhythm-ferret| <@SECONDARY@>f|show rhythm ferret window @rop|Region/show-rhythm-ferret| <@SECONDARY@>f|show rhythm ferret window
@wvis|Common/ToggleMaximalEditor| <@PRIMARY@><@SECONDARY@>f|maximise editor space @wvis|Common/ToggleMaximalEditor| <@PRIMARY@><@SECONDARY@>f|maximise editor space
@wvis|Common/ToggleMaximalMixer| <@PRIMARY@><@TERTIARY@>f|maximise mixer space @wvis|Common/ToggleMaximalMixer| <@PRIMARY@><@TERTIARY@>f|maximise mixer space

View file

@ -187,7 +187,7 @@
<menuitem action='ToggleAutoReturn'/> <menuitem action='ToggleAutoReturn'/>
<menuitem action='ToggleClick'/> <menuitem action='ToggleClick'/>
<menuitem action='EditorEditing/toggle-follow-playhead'/> <menuitem action='EditorEditing/toggle-follow-playhead'/>
<menuitem action='toggle-stationary-playhead'/> <menuitem action='EditorEditing/toggle-stationary-playhead'/>
<menuitem action='ToggleFollowEdits'/> <menuitem action='ToggleFollowEdits'/>
<menuitem action='ToggleExternalSync'/> <menuitem action='ToggleExternalSync'/>
<menuitem action='panic'/> <menuitem action='panic'/>

View file

@ -153,6 +153,8 @@ EditingContext::EditingContext (std::string const & name)
, grid_lines (nullptr) , grid_lines (nullptr)
, time_line_group (nullptr) , time_line_group (nullptr)
, temporary_zoom_focus_change (false) , temporary_zoom_focus_change (false)
, _dragging_playhead (false)
{ {
using namespace Gtk::Menu_Helpers; using namespace Gtk::Menu_Helpers;
@ -338,6 +340,10 @@ EditingContext::set_action_defaults ()
follow_playhead_action->set_active (true); follow_playhead_action->set_active (true);
follow_playhead_action->set_active (false); follow_playhead_action->set_active (false);
#endif #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 (false);
mouse_mode_actions[Editing::MouseObject]->set_active (true); mouse_mode_actions[Editing::MouseObject]->set_active (true);
zoom_focus_actions[Editing::ZoomFocusLeft]->set_active (false); 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-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)); 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, "toggle-follow-playhead", _("Follow Playhead"), sigc::mem_fun (*this, &EditingContext::follow_playhead_chosen));
follow_playhead_action = toggle_reg_sens (_common_actions, "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)));
/* invokable action that toggles the stateful action */
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)); 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)); 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; 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 void
EditingContext::toggle_follow_playhead () 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 double
EditingContext::time_to_pixel (timepos_t const & pos) const 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()); UIConfiguration::instance().set_sound_midi_notes (!UIConfiguration::instance().get_sound_midi_notes());
} }
void
EditingContext::follow_playhead_clicked ()
{
}
void void
EditingContext::cycle_zoom_focus () EditingContext::cycle_zoom_focus ()
{ {
@ -3227,13 +3264,3 @@ EditingContext::center_screen_internal (samplepos_t sample, float page)
reset_x_origin (sample); reset_x_origin (sample);
} }
bool
EditingContext::follow_playhead() const
{
if (!follow_playhead_action) {
return false;
}
return follow_playhead_action->get_active ();
}

View file

@ -503,6 +503,14 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider,
void enable_automation_bindings (); void enable_automation_bindings ();
void disable_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: protected:
std::string _name; std::string _name;
bool within_track_canvas; bool within_track_canvas;
@ -573,7 +581,6 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider,
virtual void play_note_selection_clicked(); virtual void play_note_selection_clicked();
virtual void note_mode_clicked() {} virtual void note_mode_clicked() {}
virtual void follow_playhead_clicked ();
virtual void full_zoom_clicked() {}; virtual void full_zoom_clicked() {};
virtual void set_visible_channel (int) {} virtual void set_visible_channel (int) {}
@ -596,6 +603,9 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider,
Glib::RefPtr<Gtk::ToggleAction> follow_playhead_action; Glib::RefPtr<Gtk::ToggleAction> follow_playhead_action;
void follow_playhead_chosen (); void follow_playhead_chosen ();
Glib::RefPtr<Gtk::ToggleAction> stationary_playhead_action;
void stationary_playhead_chosen ();
/* selection process */ /* selection process */
Selection* selection; Selection* selection;
@ -821,4 +831,5 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider,
virtual void automation_move_points_earlier () {}; virtual void automation_move_points_earlier () {};
bool temporary_zoom_focus_change; bool temporary_zoom_focus_change;
bool _dragging_playhead;
}; };

View file

@ -315,9 +315,7 @@ Editor::Editor ()
, ignore_gui_changes (false) , ignore_gui_changes (false)
, lock_dialog (nullptr) , lock_dialog (nullptr)
, _last_event_time (g_get_monotonic_time ()) , _last_event_time (g_get_monotonic_time ())
, _dragging_playhead (false)
, ignore_map_change (false) , ignore_map_change (false)
, _stationary_playhead (false)
, _maximised (false) , _maximised (false)
, global_rect_group (nullptr) , global_rect_group (nullptr)
, tempo_marker_menu (nullptr) , tempo_marker_menu (nullptr)
@ -2358,7 +2356,7 @@ Editor::get_state () const
node->set_property ("maximised", _maximised); node->set_property ("maximised", _maximised);
node->set_property ("follow-playhead", follow_playhead()); 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 ("mouse-mode", current_mouse_mode());
node->set_property ("join-object-range", smart_mode_action->get_active ()); 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<ToggleAction> 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 bool
Editor::show_touched_automation() const Editor::show_touched_automation() const
{ {
@ -5310,7 +5289,7 @@ Editor::super_rapid_screen_update ()
return; return;
} }
if (!_stationary_playhead) { if (!stationary_playhead()) {
reset_x_origin_to_follow_playhead (); reset_x_origin_to_follow_playhead ();
} else { } else {
samplepos_t const sample = _playhead_cursor->current_sample (); samplepos_t const sample = _playhead_cursor->current_sample ();

View file

@ -320,14 +320,6 @@ public:
void sequence_regions (); 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 toggle_zero_line_visibility ();
void set_summary (); void set_summary ();
void set_group_tabs (); void set_group_tabs ();
@ -1488,8 +1480,6 @@ private:
ARDOUR::PlaylistSet motion_frozen_playlists; ARDOUR::PlaylistSet motion_frozen_playlists;
bool _dragging_playhead;
void marker_drag_motion_callback (GdkEvent*); void marker_drag_motion_callback (GdkEvent*);
void marker_drag_finished_callback (GdkEvent*); void marker_drag_finished_callback (GdkEvent*);
@ -1645,8 +1635,6 @@ private:
/* display control */ /* display control */
/// true if we scroll the tracks rather than the playhead
bool _stationary_playhead;
/// true if we are in fullscreen mode /// true if we are in fullscreen mode
bool _maximised; bool _maximised;

View file

@ -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, "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))); 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))); 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))); act = reg_sens (editor_actions, "insert-time", _("Insert Time"), (sigc::mem_fun(*this, &Editor::do_insert_time)));

View file

@ -278,14 +278,9 @@ public:
virtual void hide_track_in_display (TimeAxisView* tv, bool apply_to_selection = false) = 0; 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 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; virtual void toggle_cue_behavior () = 0;
/** @return true if the playhead is currently being dragged, otherwise false */ /** @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 samplepos_t leftmost_sample() const = 0;
virtual samplecnt_t current_page_samples() const = 0; virtual samplecnt_t current_page_samples() const = 0;
virtual double visible_canvas_height () const = 0; virtual double visible_canvas_height () const = 0;