From ed7683d02973a41e926b1d951a3bb14d58a9c688 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Wed, 17 May 2023 09:39:24 -0500 Subject: [PATCH] tempo mapping: initiating a drag on a BEAT line applies a ramped twist as opposed to grabbing a BAR line, which explicitly creates or moves a tempo marker, and creates constant tempo lines when dragged --- gtk2_ardour/editor_mouse.cc | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 159037dc77..02ddd7addf 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -2348,6 +2348,7 @@ Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, bool from_aut if (ctx) { timepos_t snapped = _snap_to_bbt (t, RoundNearest, SnapToGrid_Unscaled, GridTypeBeat); + timepos_t snapped_to_bar = _snap_to_bbt (t, RoundNearest, SnapToGrid_Unscaled, GridTypeBar); const double unsnapped_pos = time_to_pixel_unrounded (t); const double snapped_pos = time_to_pixel_unrounded (snapped); @@ -2358,7 +2359,12 @@ Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, bool from_aut * the beat. */ - ctx->cursor_ctx->change (cursors()->time_fx); + if (snapped == snapped_to_bar) { + ctx->cursor_ctx->change (cursors()->time_fx); + } else { + /* snapped to a beat, not a bar .... we'll implement a TWIST here */ + ctx->cursor_ctx->change (cursors()->expand_left_right); + } } else { ctx->cursor_ctx->change (cursors()->grabber); } @@ -2938,7 +2944,18 @@ Editor::choose_mapping_drag (ArdourCanvas::Item* item, GdkEvent* event) return; } - if (_cursor_stack.empty() || _cursor_stack.back() != cursors()->time_fx) { + if (_cursor_stack.empty()) { + return; + } + + bool ramped = false; + if (_cursor_stack.back() == cursors()->time_fx) { + /* We are on a BAR line ... the user can drag the line exactly where it's needed */ + ramped = false; + } else if (_cursor_stack.back() == cursors()->expand_left_right) { + /* We are on a BEAT line ... we will nudge the beat line via ramping, without moving any tempo markers */ + ramped = true; + } else { /* Not close enough to a beat line to start any mapping drag */ return; } @@ -3007,6 +3024,11 @@ Editor::choose_mapping_drag (ArdourCanvas::Item* item, GdkEvent* event) at_end = true; } + } else if (ramped) { + + /* User is dragging on a BEAT line (not a bar line) ... try to implement a tempo twist on the prior marker */ + focus = &tempo; + } else { std::cerr << "ADD TEMPO MARKER " << bbt << " != " << tempo.bbt() << "\n"; @@ -3037,6 +3059,6 @@ Editor::choose_mapping_drag (ArdourCanvas::Item* item, GdkEvent* event) if (before && focus && after) { std::cerr << "TWIST\n"; begin_reversible_command (_("tempo mapping: mid-twist")); - _drags->set (new MappingTwistDrag (this, item, map, *before, *focus, *after, *before_state), event); + _drags->set (new MappingTwistDrag (this, item, map, *before, *focus, *after, *before_state, ramped), event); } }