From 67d9fa885a548d8b75ffac74b276a1de38847a37 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 10 Jul 2023 12:22:16 -0600 Subject: [PATCH] use mid-drag key events to allow Alt to force a line break --- gtk2_ardour/editor_drag.cc | 28 ++++++++++++++++++++++++++-- gtk2_ardour/editor_drag.h | 2 ++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 3522dcba3d..a1808fdaf6 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -7264,6 +7264,7 @@ AutomationDrawDrag::AutomationDrawDrag (Editor* editor, ArdourCanvas::Rectangle& , direction (0) , edge_x (0) , did_snap (false) + , line_break_pending (false) { DEBUG_TRACE (DEBUG::Drags, "New AutomationDrawDrag\n"); } @@ -7344,8 +7345,12 @@ AutomationDrawDrag::maybe_add_point (GdkEvent* ev, timepos_t const & cpos) } if (pop_point) { - dragging_line->pop_back(); - drawn_points.pop_back (); + if (line_break_pending) { + line_break_pending = false; + } else { + dragging_line->pop_back(); + drawn_points.pop_back (); + } } if (add_point) { @@ -7382,3 +7387,22 @@ void AutomationDrawDrag::aborted (bool) { } + +bool +AutomationDrawDrag::mid_drag_key_event (GdkEventKey* ev) +{ + if (ev->type == GDK_KEY_PRESS) { + switch (ev->keyval) { + + case GDK_Alt_R: + case GDK_Alt_L: + line_break_pending = true; + return true; + + default: + break; + } + } + + return false; +} diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 640a71eb17..6ae70539a3 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -1592,6 +1592,7 @@ class AutomationDrawDrag : public Drag void motion (GdkEvent*, bool); void finished (GdkEvent*, bool); void aborted (bool); + bool mid_drag_key_event (GdkEventKey*); private: ArdourCanvas::Rectangle& base_rect; /* we do not own this */ @@ -1600,6 +1601,7 @@ private: int edge_x; Evoral::ControlList::OrderedPoints drawn_points; bool did_snap; + bool line_break_pending; void maybe_add_point (GdkEvent*, Temporal::timepos_t const &); };