From b972301a3bc337f58992827d15cf2ed6d991fb84 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 2 Dec 2022 21:31:56 +0100 Subject: [PATCH] Add action to noninteractively add BBT marker at playhead --- gtk2_ardour/ardour_ui_ed.cc | 3 +++ gtk2_ardour/editor.h | 1 + gtk2_ardour/editor_tempodisplay.cc | 16 ++++++++++++++++ gtk2_ardour/public_editor.h | 1 + 4 files changed, 21 insertions(+) diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index a39c0b0541..1e21da18d3 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -639,6 +639,9 @@ ARDOUR_UI::install_dependent_actions () act = ActionManager::register_action (common_actions, "alternate-remove-location-from-playhead", _("Remove Mark at Playhead"), sigc::mem_fun(editor, &PublicEditor::remove_location_at_playhead_cursor)); ActionManager::session_sensitive_actions.push_back (act); + act = ActionManager::register_action (common_actions, "add-bbt-from-playhead", _("Add BBT Marker from Playhead"), sigc::mem_fun(editor, &PublicEditor::add_bbt_marker_at_playhead_cursor)); + ActionManager::session_sensitive_actions.push_back (act); + act = ActionManager::register_action (common_actions, "nudge-next-forward", _("Nudge Next Later"), sigc::bind (sigc::mem_fun(editor, &PublicEditor::nudge_forward), true, false)); ActionManager::session_sensitive_actions.push_back (act); act = ActionManager::register_action (common_actions, "nudge-next-backward", _("Nudge Next Earlier"), sigc::bind (sigc::mem_fun(editor, &PublicEditor::nudge_backward), true, false)); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 75950945bd..05c735f72d 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -603,6 +603,7 @@ public: void edit_tempo_section (Temporal::TempoPoint&); void edit_meter_section (Temporal::MeterPoint&); void mouse_add_bbt_marker_event (Temporal::timepos_t where); + void add_bbt_marker_at_playhead_cursor (); void edit_bbt (Temporal::MusicTimePoint&); diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index 1a05bd02fc..670ae79a62 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -528,6 +528,22 @@ Editor::mouse_add_new_meter_event (timepos_t pos) tmc.map().set_meter (Meter (bpb, note_type), pos); } +void +Editor::add_bbt_marker_at_playhead_cursor () +{ + if (_session == 0) { + return; + } + + timepos_t pos (_session->transport_sample ()); + + BBT_Time bbt = Temporal::TempoMap::use()->bbt_at (pos); + std::string name = _("Playhead"); + + TempoMapChange tmc (*this, _("add BBT marker")); + tmc.map().set_bartime (bbt, pos, name); +} + void Editor::mouse_add_bbt_marker_event (timepos_t pos) { diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index f38dc41f12..855bf5a8d0 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -247,6 +247,7 @@ public: virtual void goto_nth_marker (int nth) = 0; virtual void jump_to_loop_marker (bool start) = 0; virtual void trigger_script (int nth) = 0; + virtual void add_bbt_marker_at_playhead_cursor () = 0; virtual void add_location_from_playhead_cursor () = 0; virtual void remove_location_at_playhead_cursor () = 0; virtual void add_location_mark (Temporal::timepos_t const & where) = 0;