From 1f4490fff907c965917495febac02f2eeaeb284d Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 2 Jul 2023 20:35:30 +0200 Subject: [PATCH] Allow to select region-gain points via rubber-band drag --- gtk2_ardour/automation_line.cc | 5 ++--- gtk2_ardour/editor_mouse.cc | 9 ++++----- gtk2_ardour/streamview.cc | 32 ++++++++++++++++++++------------ 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index 18a01eb620..3d483a0606 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -948,14 +948,13 @@ void AutomationLine::get_selectables (timepos_t const & start, timepos_t const & end, double botfrac, double topfrac, list& results) { /* convert fractions to display coordinates with 0 at the top of the track */ - double const bot_track = (1 - topfrac) * trackview.current_height (); - double const top_track = (1 - botfrac) * trackview.current_height (); + double const bot_track = (1 - topfrac) * trackview.current_height (); // this should StreamView::child_height () for RegionGain + double const top_track = (1 - botfrac) * trackview.current_height (); // --"-- for (auto const & cp : control_points) { const timepos_t w = session_position ((*cp->model())->when); - if (w >= start && w <= end && cp->get_y() >= bot_track && cp->get_y() <= top_track) { results.push_back (cp); } diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index eca2be7b39..4fbc765b43 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -1045,11 +1045,9 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; case RegionItem: - if (dynamic_cast(clicked_regionview)) { - /* rubberband drag to select automation points */ - _drags->set (new EditorRubberbandSelectDrag (this, item), event); - return true; - } + /* rubberband drag to select region gain points */ + _drags->set (new EditorRubberbandSelectDrag (this, item), event); + return true; break; default: @@ -2324,6 +2322,7 @@ Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, bool from_aut update_join_object_range_location (event->motion.y); if (_drags->active ()) { + _region_peak_cursor->hide (); //drags change the snapped_cursor location, because we are snapping the thing being dragged, not the actual mouse cursor return _drags->motion_handler (event, from_autoscroll); } else { diff --git a/gtk2_ardour/streamview.cc b/gtk2_ardour/streamview.cc index 2b634df91c..cbd3e182a8 100644 --- a/gtk2_ardour/streamview.cc +++ b/gtk2_ardour/streamview.cc @@ -40,9 +40,11 @@ #include "canvas/rectangle.h" #include "canvas/debug.h" +#include "audio_region_view.h" #include "streamview.h" #include "region_view.h" #include "route_time_axis.h" +#include "region_gain_line.h" #include "region_selection.h" #include "selection.h" #include "public_editor.h" @@ -585,10 +587,6 @@ StreamView::set_selected_regionviews (RegionSelection& regions) void StreamView::get_selectables (timepos_t const & start, timepos_t const & end, double top, double bottom, list& results, bool within) { - if (_trackview.editor().internal_editing()) { - return; // Don't select regions with an internal tool - } - layer_t min_layer = 0; layer_t max_layer = 0; @@ -619,17 +617,27 @@ StreamView::get_selectables (timepos_t const & start, timepos_t const & end, dou layer_t const l = (*i)->region()->layer (); layer_ok = (min_layer <= l && l <= max_layer); } - - if (within) { - if ((*i)->region()->coverage (start, end) == Temporal::OverlapExternal && layer_ok) { - results.push_back (*i); - } - } else { - if ((*i)->region()->coverage (start, end) != Temporal::OverlapNone && layer_ok) { + if (!layer_ok) { + continue; + } + if ((within && (*i)->region()->coverage (start, end) == Temporal::OverlapExternal) + || (!within && (*i)->region()->coverage (start, end) != Temporal::OverlapNone)) { + if (_trackview.editor().internal_editing()) { + AudioRegionView* arv = dynamic_cast (*i); + if (arv && arv->get_gain_line ()) { + /* Note: AutomationLine::get_selectables() uses trackview.current_height (), + * disregarding Stacked layer display height + */ + double const c = height; // child_height (); // XXX + double const y = (*i)->get_canvas_group ()->position().y; + double t = 1.0 - std::min (1.0, std::max (0., (top - _trackview.y_position () - y) / c)); + double b = 1.0 - std::min (1.0, std::max (0., (bottom - _trackview.y_position () - y) / c)); + arv->get_gain_line()->get_selectables (start, end, b, t, results); + } + } else { results.push_back (*i); } } - } }