diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 98ed8fd617..61eb7740e6 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -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 diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 78740d0542..05586f2f33 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -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); diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc index aace8b0473..494c64509c 100644 --- a/gtk2_ardour/editor_canvas_events.cc +++ b/gtk2_ardour/editor_canvas_events.cc @@ -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; diff --git a/gtk2_ardour/editor_sections.cc b/gtk2_ardour/editor_sections.cc index 97b7d386f7..7dd8f7d7f1 100644 --- a/gtk2_ardour/editor_sections.cc +++ b/gtk2_ardour/editor_sections.cc @@ -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 () { diff --git a/gtk2_ardour/editor_sections.h b/gtk2_ardour/editor_sections.h index 2a158d88e8..afc2b250f1 100644 --- a/gtk2_ardour/editor_sections.h +++ b/gtk2_ardour/editor_sections.h @@ -41,6 +41,8 @@ public: return _scroller; } + void select (ARDOUR::Location*); + private: void redisplay (); bool delete_selected_section ();