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.
This commit is contained in:
Robin Gareus 2023-03-31 23:13:20 +02:00
parent 91c0f143ec
commit a0286f2e6f
4 changed files with 29 additions and 0 deletions

View File

@ -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());

View File

@ -1440,6 +1440,7 @@ private:
std::shared_ptr<ARDOUR::Playlist> current_playlist () const;
void insert_source_list_selection (float times);
void cut_copy_section (bool copy);
/* import & embed */

View File

@ -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));

View File

@ -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