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
This commit is contained in:
Ben Loftis 2023-05-17 09:39:24 -05:00
parent a217c58ff5
commit ed7683d029
1 changed files with 25 additions and 3 deletions

View File

@ -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);
}
}