Arrangement Ruler: overhaul context menu, do not select on RMB

This commit is contained in:
Robin Gareus 2023-09-12 05:37:41 +02:00
parent 4352f89ff0
commit 218fbda6e7
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
5 changed files with 34 additions and 29 deletions

View File

@ -1591,14 +1591,10 @@ Editor::popup_xfade_out_context_menu (int button, int32_t time, ArdourCanvas::It
}
void
Editor::popup_section_box_menu (int button, int32_t time)
Editor::add_section_context_items (Gtk::Menu_Helpers::MenuList& items)
{
using namespace Menu_Helpers;
section_box_menu.set_name ("ArdourContextMenu");
MenuList& items (section_box_menu.items());
items.clear ();
if (Profile->get_mixbus ()) {
items.push_back (MenuElem (_("Copy/Paste Range Section to Playhead"), sigc::bind (sigc::mem_fun (*this, &Editor::cut_copy_section), CopyPasteSection)));
items.push_back (MenuElem (_("Cut/Paste Range Section to Playhead"), sigc::bind (sigc::mem_fun (*this, &Editor::cut_copy_section), CutPasteSection)));
@ -1626,8 +1622,6 @@ Editor::popup_section_box_menu (int button, int32_t time)
items.push_back (SeparatorElem());
add_selection_context_items (items, true);
section_box_menu.popup (button, time);
}
void

View File

@ -861,12 +861,12 @@ private:
GdkEvent context_click_event;
void popup_section_box_menu (int, int);
void popup_track_context_menu (int, int, ItemType, bool);
Gtk::Menu* build_track_context_menu ();
Gtk::Menu* build_track_bus_context_menu ();
Gtk::Menu* build_track_region_context_menu ();
Gtk::Menu* build_track_selection_context_menu ();
void add_section_context_items (Gtk::Menu_Helpers::MenuList&);
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<ARDOUR::Track>);

View File

@ -40,6 +40,7 @@
#include "canvas/scroll_group.h"
#include "editor.h"
#include "editor_sections.h"
#include "keyboard.h"
#include "public_editor.h"
#include "audio_region_view.h"
@ -1164,31 +1165,26 @@ Editor::section_rect_event (GdkEvent* ev, Location* loc, ArdourCanvas::Rectangle
break;
case GDK_BUTTON_RELEASE:
if (Keyboard::is_context_menu_event (&ev->button)) {
using namespace Menu_Helpers;
/* find section */
timepos_t start (loc->start ());
timepos_t end;
Location* l = _session->locations()->section_at (start, start, end);
assert (l);
/* set selection range */
selection->clear ();
selection->set (start, end);
/* switch to range tool - same as EditorSections::selection_changed */
switch (current_mouse_mode ()) {
case Editing::MouseRange:
/* OK */
break;
case Editing::MouseObject:
if (ActionManager::get_toggle_action ("MouseMode", "set-mouse-mode-object-range")->get_active ()) {
/* smart mode; OK */
break;
}
/*fallthrough*/
default:
ActionManager::get_radio_action (X_("MouseMode"), X_("set-mouse-mode-range"))->set_active (true);
break;
}
/* and show section context menu */
popup_section_box_menu (ev->button.button, ev->button.time);
timepos_t where (canvas_event_time (ev));
section_box_menu.set_name ("ArdourContextMenu");
MenuList& items (section_box_menu.items());
items.clear ();
items.push_back (MenuElem (_("New Arrangement Marker"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_add_new_marker), where, Location::Flags(Location::IsMark | Location::IsSection), 0)));
items.push_back (MenuElem (_("Select Arrangement Section"), sigc::bind (sigc::mem_fun(*_sections, &EditorSections::select), l)));
items.push_back (SeparatorElem());
add_section_context_items (items);
section_box_menu.popup (ev->button.button, ev->button.time);
return true;
}
break;
@ -1220,7 +1216,11 @@ Editor::canvas_section_box_event (GdkEvent *event)
return !Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier);
case GDK_BUTTON_RELEASE:
if (Keyboard::is_context_menu_event (&event->button)) {
popup_section_box_menu (event->button.button, event->button.time);
section_box_menu.set_name ("ArdourContextMenu");
Gtk::Menu_Helpers::MenuList& items (section_box_menu.items());
items.clear ();
add_section_context_items (items);
section_box_menu.popup (event->button.button, event->button.time);
return true;
}
return false;

View File

@ -109,6 +109,15 @@ EditorSections::set_session (Session* s)
redisplay ();
}
void
EditorSections::select (ARDOUR::Location* l)
{
LocationRowMap::iterator map_it = _location_row_map.find (l);
if (map_it != _location_row_map.end ()) {
_view.get_selection ()->select (*map_it->second);
}
}
void
EditorSections::redisplay ()
{

View File

@ -41,6 +41,8 @@ public:
return _scroller;
}
void select (ARDOUR::Location*);
private:
void redisplay ();
bool delete_selected_section ();