From b243b930725b03291b9d421eeb15fe79da351aad Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 8 Sep 2023 01:26:44 +0200 Subject: [PATCH] Allow to reuse range context menu w/o track/region selection --- gtk2_ardour/editor.cc | 93 ++++++++++++++++++++++++------------------- gtk2_ardour/editor.h | 2 +- 2 files changed, 52 insertions(+), 43 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 85dd635d29..d82695738d 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -1922,7 +1922,7 @@ Editor::add_region_context_items (Menu_Helpers::MenuList& edit_items, std::share * @param edit_items List to add the items to. */ void -Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items) +Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items, bool time_selection_only) { using namespace Menu_Helpers; @@ -1932,47 +1932,51 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items) edit_items.push_back (SeparatorElem()); edit_items.push_back (MenuElem (_("Zoom to Range"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_selection), Horizontal))); - edit_items.push_back (SeparatorElem()); - edit_items.push_back (MenuElem (_("Loudness Analysis"), sigc::mem_fun(*this, &Editor::loudness_analyze_range_selection))); - edit_items.push_back (MenuElem (_("Spectral Analysis"), sigc::mem_fun(*this, &Editor::spectral_analyze_range_selection))); - edit_items.push_back (SeparatorElem()); - edit_items.push_back (MenuElem (_("Loudness Assistant..."), sigc::bind (sigc::mem_fun (*this, &Editor::loudness_assistant), true))); - edit_items.push_back (SeparatorElem()); + if (!time_selection_only) { + edit_items.push_back (SeparatorElem()); + edit_items.push_back (MenuElem (_("Loudness Analysis"), sigc::mem_fun(*this, &Editor::loudness_analyze_range_selection))); + edit_items.push_back (MenuElem (_("Spectral Analysis"), sigc::mem_fun(*this, &Editor::spectral_analyze_range_selection))); + edit_items.push_back (SeparatorElem()); + edit_items.push_back (MenuElem (_("Loudness Assistant..."), sigc::bind (sigc::mem_fun (*this, &Editor::loudness_assistant), true))); + edit_items.push_back (SeparatorElem()); - edit_items.push_back ( - MenuElem ( - _("Move Range Start to Previous Region Boundary"), - sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), false, false) - ) - ); + edit_items.push_back ( + MenuElem ( + _("Move Range Start to Previous Region Boundary"), + sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), false, false) + ) + ); - edit_items.push_back ( - MenuElem ( - _("Move Range Start to Next Region Boundary"), - sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), false, true) - ) - ); + edit_items.push_back ( + MenuElem ( + _("Move Range Start to Next Region Boundary"), + sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), false, true) + ) + ); - edit_items.push_back ( - MenuElem ( - _("Move Range End to Previous Region Boundary"), - sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), true, false) - ) - ); + edit_items.push_back ( + MenuElem ( + _("Move Range End to Previous Region Boundary"), + sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), true, false) + ) + ); - edit_items.push_back ( - MenuElem ( - _("Move Range End to Next Region Boundary"), - sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), true, true) - ) - ); + edit_items.push_back ( + MenuElem ( + _("Move Range End to Next Region Boundary"), + sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), true, true) + ) + ); + } edit_items.push_back (SeparatorElem()); edit_items.push_back (MenuElem (_("Separate"), mem_fun(*this, &Editor::separate_region_from_selection))); // edit_items.push_back (MenuElem (_("Convert to Region in Region List"), sigc::mem_fun(*this, &Editor::new_region_from_selection))); - edit_items.push_back (SeparatorElem()); - edit_items.push_back (MenuElem (_("Select All in Range"), sigc::mem_fun(*this, &Editor::select_all_selectables_using_time_selection))); + if (!time_selection_only) { + edit_items.push_back (SeparatorElem()); + edit_items.push_back (MenuElem (_("Select All in Range"), sigc::mem_fun(*this, &Editor::select_all_selectables_using_time_selection))); + } edit_items.push_back (SeparatorElem()); edit_items.push_back (MenuElem (_("Set Loop from Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::set_loop_from_selection), false))); @@ -1980,17 +1984,22 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items) edit_items.push_back (MenuElem (_("Set Session Start/End from Selection"), sigc::mem_fun(*this, &Editor::set_session_extents_from_selection))); edit_items.push_back (SeparatorElem()); - edit_items.push_back (MenuElem (_("Add Range Markers"), sigc::mem_fun (*this, &Editor::add_location_from_selection))); - edit_items.push_back (SeparatorElem()); - 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))); + if (!time_selection_only) { + edit_items.push_back (MenuElem (_("Add Range Markers"), sigc::mem_fun (*this, &Editor::add_location_from_selection))); + + edit_items.push_back (SeparatorElem()); + + 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 (_("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))); + edit_items.push_back (MenuElem (_("Bounce"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), NewSource, false))); + edit_items.push_back (MenuElem (_("Bounce (with processing)"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), NewSource, true))); + } - 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))); - edit_items.push_back (MenuElem (_("Bounce"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), NewSource, false))); - edit_items.push_back (MenuElem (_("Bounce (with processing)"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), NewSource, true))); edit_items.push_back (MenuElem (_("Export Range..."), sigc::mem_fun(*this, &Editor::export_selection))); if (ARDOUR_UI::instance()->video_timeline->get_duration() > 0) { edit_items.push_back (MenuElem (_("Export Video Range..."), sigc::bind (sigc::mem_fun(*(ARDOUR_UI::instance()), &ARDOUR_UI::export_video), true))); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 543a338bba..4e0f131116 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -866,7 +866,7 @@ private: void add_dstream_context_items (Gtk::Menu_Helpers::MenuList&); void add_bus_context_items (Gtk::Menu_Helpers::MenuList&); void add_region_context_items (Gtk::Menu_Helpers::MenuList&, std::shared_ptr); - void add_selection_context_items (Gtk::Menu_Helpers::MenuList&); + void add_selection_context_items (Gtk::Menu_Helpers::MenuList&, bool time_selection_only = false); Gtk::MenuItem* _popup_region_menu_item; void popup_control_point_context_menu (ArdourCanvas::Item*, GdkEvent*);