13
0

Allow to select Arrangement sections

This also adds interaction with sections in the
Arrangement Ruler.

Note that selecting a range switches to the Range tool.
This is enforced because time-range selection is only meaningful
with tools that perform edit operations on the whole timeline.
This commit is contained in:
Robin Gareus 2023-09-07 21:25:08 +02:00
parent b6e9f37007
commit 019a3a1976
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
5 changed files with 92 additions and 1 deletions

View File

@ -716,6 +716,7 @@ private:
void location_flags_changed (ARDOUR::Location*);
void refresh_location_display ();
void update_section_rects ();
bool section_rect_event (GdkEvent*, ARDOUR::Location*, ArdourCanvas::Rectangle*, std::string);
void refresh_location_display_internal (const ARDOUR::Locations::LocationList&);
void add_new_location (ARDOUR::Location*);
ArdourCanvas::Container* add_new_location_internal (ARDOUR::Location*);

View File

@ -1126,6 +1126,78 @@ Editor::canvas_ruler_bar_event (GdkEvent *event, ArdourCanvas::Item* item, ItemT
return typed_event (item, event, type);
}
bool
Editor::section_rect_event (GdkEvent* ev, Location* loc, ArdourCanvas::Rectangle* rect, std::string color)
{
switch (ev->type) {
case GDK_ENTER_NOTIFY:
if (UIConfiguration::instance ().get_widget_prelight ()) {
rect->set_fill_color (UIConfiguration::instance().color_mod (color, "marker bar"));
return true;
}
break;
case GDK_LEAVE_NOTIFY:
if (UIConfiguration::instance ().get_widget_prelight ()) {
rect->set_fill_color (UIConfiguration::instance().color (color));
return true;
}
break;
case GDK_BUTTON_PRESS:
if (Keyboard::modifier_state_equals (ev->button.state, Keyboard::PrimaryModifier)) {
/* used to add markers */
return false;
}
if (ev->button.button == 1) {
_session->request_locate (loc->start().samples());
}
return true;
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
if (Keyboard::modifier_state_equals (ev->button.state, Keyboard::PrimaryModifier)) {
return false;
}
if (ev->button.button == 1) {
assert (find_location_markers (loc));
rename_marker (find_location_markers (loc)->start);
return true;
}
break;
case GDK_BUTTON_RELEASE:
if (Keyboard::is_context_menu_event (&ev->button)) {
/* 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);
return true;
}
break;
default:
break;
}
return false;
}
bool
Editor::canvas_playhead_cursor_event (GdkEvent *event, ArdourCanvas::Item* item)
{

View File

@ -677,6 +677,7 @@ Editor::update_section_rects ()
std::string const color = bright ? "arrangement rect" : "arrangement rect alt";
rect->set_fill_color (UIConfiguration::instance().color (color));
rect->Event.connect (sigc::bind (sigc::mem_fun (this, &Editor::section_rect_event), l, rect, color));
Editor::LocationMarkers* markers = find_location_markers (l);
if (markers) {

View File

@ -1850,7 +1850,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
return true;
case SectionMarkerBarItem:
if (!_dragging_playhead) {
if (!_dragging_playhead && Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
snap_to_with_modifier (where, event, Temporal::RoundNearest, SnapToGrid_Scaled);
mouse_add_new_marker (where, Location::IsSection);
}

View File

@ -231,6 +231,23 @@ EditorSections::selection_changed ()
timepos_t end = row[_columns.end];
_selection_change.block ();
switch (PublicEditor::instance ().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:
Glib::RefPtr<RadioAction> ract = ActionManager::get_radio_action (X_("MouseMode"), X_("set-mouse-mode-range"));
ract->set_active (true);
break;
}
Selection& s (PublicEditor::instance ().get_selection ());
s.clear ();
s.set (start, end);