From 417f3647ccd70f0fc93d0de1314e1259dba54299 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 10 Oct 2023 04:18:53 +0200 Subject: [PATCH] Keep shuttle ctrl in sync with actual speed When using "VS" the numeric control shows the "default speed" when not rolling. Then when starting to roll default speed will be the actual speed. Previously the shuttle was not updated when `last_speed_displayed` was the current speed. This dated back to before "VS" showed default speed. --- gtk2_ardour/shuttle_control.cc | 15 ++++++++------- gtk2_ardour/shuttle_control.h | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/shuttle_control.cc b/gtk2_ardour/shuttle_control.cc index 1ac3bb13e3..7c28f9559e 100644 --- a/gtk2_ardour/shuttle_control.cc +++ b/gtk2_ardour/shuttle_control.cc @@ -155,6 +155,7 @@ ShuttleControl::ShuttleControl () shine_pattern = 0; last_shuttle_request = 0; last_speed_displayed = -99999999; + last_shuttle_fract = -99999999; shuttle_grabbed = false; shuttle_speed_on_grab = 0; shuttle_fract = 0.0; @@ -318,13 +319,6 @@ ShuttleControl::map_transport_state () speed = _session->actual_speed (); } - if ((fabsf (speed - last_speed_displayed) < 0.005f) // dead-zone - && !(speed == 1.f && last_speed_displayed != 1.f) - && !(speed == 0.f && last_speed_displayed != 0.f)) { - return; // nothing to see here, move along. - } - - // Q: is there a good reason why we re-calculate this every time? if (fabs (speed) <= (2 * DBL_EPSILON)) { shuttle_fract = 0; } else { @@ -335,6 +329,11 @@ ShuttleControl::map_transport_state () } } + if ((fabsf (shuttle_fract - last_shuttle_fract) < 0.005f)) { + /* dead-zone */ + return; + } + queue_draw (); } @@ -725,6 +724,7 @@ ShuttleControl::render (Cairo::RefPtr const& ctx, cairo_rectangl } last_speed_displayed = actual_speed; + last_shuttle_fract = shuttle_fract; _info_button.set_text (buf); @@ -765,6 +765,7 @@ ShuttleControl::parameter_changed (std::string p) } else if (p == "shuttle-max-speed") { shuttle_max_speed = Config->get_shuttle_max_speed (); last_speed_displayed = -99999999; + last_shuttle_fract = -99999999; map_transport_state (); use_shuttle_fract (true); delete shuttle_context_menu; diff --git a/gtk2_ardour/shuttle_control.h b/gtk2_ardour/shuttle_control.h index d0532f9618..fa25bed5c3 100644 --- a/gtk2_ardour/shuttle_control.h +++ b/gtk2_ardour/shuttle_control.h @@ -111,6 +111,7 @@ protected: bool _hovering; float shuttle_max_speed; float last_speed_displayed; + float last_shuttle_fract; bool shuttle_grabbed; double shuttle_speed_on_grab; double requested_speed;