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.
This commit is contained in:
Robin Gareus 2023-10-10 04:18:53 +02:00
parent 0f21d26f2c
commit 417f3647cc
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 9 additions and 7 deletions

View File

@ -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<Cairo::Context> 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;

View File

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