From a0286f2e6f267f03211d2c70cc52f03bcb2598d1 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 31 Mar 2023 23:13:20 +0200 Subject: [PATCH] Expose cut-copy-section in the editor This is still a bit of an experiment, there may need to be a dedicated ruler for sections, or a side-bar that allows arranging. --- gtk2_ardour/editor.cc | 15 +++++++++++++++ gtk2_ardour/editor.h | 1 + gtk2_ardour/editor_actions.cc | 3 +++ gtk2_ardour/editor_ops.cc | 10 ++++++++++ 4 files changed, 29 insertions(+) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index d962ddfb97..d301875bd2 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -1979,6 +1979,10 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items) edit_items.push_back (MenuElem (_("Crop Region to Range"), sigc::mem_fun(*this, &Editor::crop_region_to_selection))); edit_items.push_back (MenuElem (_("Duplicate Range"), sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_range), false))); + edit_items.push_back (SeparatorElem()); + edit_items.push_back (MenuElem (_("Copy/Paste Range Section to Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::cut_copy_section), true))); + edit_items.push_back (MenuElem (_("Cut/Paste Range Section to Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::cut_copy_section), false))); + edit_items.push_back (SeparatorElem()); edit_items.push_back (MenuElem (_("Consolidate"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), ReplaceRange, false))); edit_items.push_back (MenuElem (_("Consolidate (with processing)"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), ReplaceRange, true))); @@ -2061,6 +2065,17 @@ Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items) } edit_items.push_back (MenuElem (_("Insert Existing Media"), sigc::bind (sigc::mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack))); + /* Cut/Copy Section */ + + timepos_t unused; + bool have_time_selection = get_selection_extents (unused, unused); + edit_items.push_back (SeparatorElem()); + edit_items.push_back (MenuElem (_("Copy/Paste Range Section to Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::cut_copy_section), true))); + edit_items.back ().set_sensitive (have_time_selection); + edit_items.push_back (MenuElem (_("Cut/Paste Range Section to Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::cut_copy_section), false))); + edit_items.back ().set_sensitive (have_time_selection); + + /* Nudge track */ Menu *nudge_menu = manage (new Menu()); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 60069f737a..2941005f41 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1440,6 +1440,7 @@ private: std::shared_ptr current_playlist () const; void insert_source_list_selection (float times); + void cut_copy_section (bool copy); /* import & embed */ diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index 7ece9c52d9..3c87c95ee2 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -363,6 +363,9 @@ Editor::register_actions () reg_sens (editor_actions, "set-punch-from-edit-range", _("Set Punch from Selection"), sigc::mem_fun(*this, &Editor::set_punch_from_selection)); reg_sens (editor_actions, "set-session-from-edit-range", _("Set Session Start/End from Selection"), sigc::mem_fun(*this, &Editor::set_session_extents_from_selection)); + reg_sens (editor_actions, "copy-paste-section", _("Copy/Paste Range Section to Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::cut_copy_section), true)); + reg_sens (editor_actions, "cut-paste-section", _("Cut/Paste Range Section to Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::cut_copy_section), false)); + /* this is a duplicated action so that the main menu can use a different label */ reg_sens (editor_actions, "main-menu-play-selected-regions", _("Play Selected Regions"), sigc::mem_fun (*this, &Editor::play_selected_region)); reg_sens (editor_actions, "main-menu-tag-selected-regions", _("Tag Selected Regions"), sigc::mem_fun (*this, &Editor::tag_selected_region)); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 59a0d8e285..d03943fffa 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -2708,6 +2708,16 @@ Editor::insert_source_list_selection (float times) commit_reversible_command (); } +void +Editor::cut_copy_section (bool copy) +{ + timepos_t start, end; + if (!get_selection_extents (start, end) || !_session) { + return; + } + _session->cut_copy_section (start, end, get_preferred_edit_position(), copy); +} + /* BUILT-IN EFFECTS */ void