From 764ed125a4fa9041f408faab18204e64ae79263c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 2 Oct 2023 12:00:50 -0600 Subject: [PATCH] region gain line freehand draw: ensure drawn line is above waveform --- gtk2_ardour/audio_region_view.cc | 1 + gtk2_ardour/editor_drag.cc | 12 +++++++----- gtk2_ardour/editor_drag.h | 5 +++-- gtk2_ardour/editor_mouse.cc | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index 4f8f4ef9a0..8faf5f35a2 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -278,6 +278,7 @@ AudioRegionView::init (bool wfd) setup_waveform_visibility (); get_canvas_frame()->set_data ("linemerger", (LineMerger*) this); + gain_line->canvas_group().raise_to_top (); /* XXX sync mark drag? */ } diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 3c0a0f76b7..96e9288291 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -7265,8 +7265,9 @@ LollipopDrag::setup_pointer_offset () /********/ template -FreehandLineDrag::FreehandLineDrag (Editor* editor, ArdourCanvas::Rectangle& r, Temporal::TimeDomain time_domain) +FreehandLineDrag::FreehandLineDrag (Editor* editor, ArdourCanvas::Item* p, ArdourCanvas::Rectangle& r, Temporal::TimeDomain time_domain) : Drag (editor, &r, time_domain) + , parent (p) , base_rect (r) , dragging_line (nullptr) , direction (0) @@ -7288,10 +7289,11 @@ void FreehandLineDrag::motion (GdkEvent* ev, bool first_move) { if (first_move) { - dragging_line = new ArdourCanvas::PolyLine (item()); + dragging_line = new ArdourCanvas::PolyLine (parent ? parent : item()); dragging_line->set_ignore_events (true); dragging_line->set_outline_width (2.0); dragging_line->set_outline_color (UIConfiguration::instance().color ("automation line")); + dragging_line->raise_to_top (); /* for freehand drawing, we only support left->right direction, for now. */ direction = 1; @@ -7447,8 +7449,8 @@ FreehandLineDrag::mid_drag_key_event (GdkEventKey /**********************/ -AutomationDrawDrag::AutomationDrawDrag (Editor* editor, ArdourCanvas::Rectangle& r, Temporal::TimeDomain time_domain) - : FreehandLineDrag (editor, r, time_domain) +AutomationDrawDrag::AutomationDrawDrag (Editor* editor, ArdourCanvas::Item* p, ArdourCanvas::Rectangle& r, Temporal::TimeDomain time_domain) + : FreehandLineDrag (editor, p, r, time_domain) { DEBUG_TRACE (DEBUG::Drags, "New AutomationDrawDrag\n"); } @@ -7487,7 +7489,7 @@ AutomationDrawDrag::finished (GdkEvent* event, bool motion_occured) /*****************/ VelocityLineDrag::VelocityLineDrag (Editor* editor, ArdourCanvas::Rectangle& r, Temporal::TimeDomain time_domain) - : FreehandLineDrag (editor, r, time_domain) + : FreehandLineDrag (editor, nullptr, r, time_domain) , grv (static_cast (r.get_data ("ghostregionview"))) , drag_did_change (false) { diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index b3b2c3cf7d..dcd8de6b06 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -1587,7 +1587,7 @@ template class FreehandLineDrag : public Drag { public: - FreehandLineDrag (Editor*, ArdourCanvas::Rectangle&, Temporal::TimeDomain); + FreehandLineDrag (Editor*, ArdourCanvas::Item*, ArdourCanvas::Rectangle&, Temporal::TimeDomain); ~FreehandLineDrag (); void motion (GdkEvent*, bool); @@ -1596,6 +1596,7 @@ class FreehandLineDrag : public Drag virtual void point_added (ArdourCanvas::Duple const & d, ArdourCanvas::Rectangle const & r, double last_x) {} protected: + ArdourCanvas::Item* parent; /* we do not own this. If null, use base_rect as the parent */ ArdourCanvas::Rectangle& base_rect; /* we do not own this */ ArdourCanvas::PolyLine* dragging_line; int direction; @@ -1610,7 +1611,7 @@ class FreehandLineDrag : public Drag class AutomationDrawDrag : public FreehandLineDrag { public: - AutomationDrawDrag (Editor*, ArdourCanvas::Rectangle&, Temporal::TimeDomain); + AutomationDrawDrag (Editor*, ArdourCanvas::Item*, ArdourCanvas::Rectangle&, Temporal::TimeDomain); ~AutomationDrawDrag (); void finished (GdkEvent*, bool); diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 2be02cc396..4144642ea9 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -1362,7 +1362,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT { AutomationTimeAxisView* atv = static_cast (item->get_data ("trackview")); if (atv) { - _drags->set (new AutomationDrawDrag (this, atv->base_item(), Temporal::AudioTime), event); + _drags->set (new AutomationDrawDrag (this, nullptr, atv->base_item(), Temporal::AudioTime), event); } } break; @@ -1389,7 +1389,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT RegionView* rv; if ((rv = dynamic_cast (clicked_regionview))) { ArdourCanvas::Rectangle* r = dynamic_cast (rv->get_canvas_frame()); - _drags->set (new AutomationDrawDrag (this, *r, Temporal::AudioTime), event); + _drags->set (new AutomationDrawDrag (this, rv->get_canvas_group(), *r, Temporal::AudioTime), event); } } break;