Fix STEPPED_SLIDER glitchlyness on windows

wxWidgets drives some of this problem, it blindly calls SetValue and invokes the win32 update position messages on all the scroll subevents and we end up fighting it as well by inserting the rounded position on each subevent rather than the final one
This commit is contained in:
Marek Roszko 2021-07-06 00:58:19 -04:00
parent 70ce74ed4a
commit 5116fa6d12
1 changed files with 15 additions and 4 deletions

View File

@ -70,9 +70,20 @@ int STEPPED_SLIDER::GetStep() const
void STEPPED_SLIDER::OnScroll( wxScrollEvent& aEvent )
{
const int value = GetValue();
const int rounded = value - value % m_step;
SetValue( rounded );
// On Windows, moving the thumb can generate multiple subevents and wx is blindly
// calling SetValue for each one before calling this event handler
// We need to explicitly wait until the "final" sub event or else we end up fighting
// wx on the value it is setting and extreme glitchlyness will occur
// Not sure if other platforms have this issue
#ifdef __WXMSW__
if( aEvent.GetEventType() == wxEVT_SCROLL_CHANGED )
{
#endif // __WXMSW__
const int value = GetValue();
const int rounded = value - value % m_step;
SetValue( rounded );
#ifdef __WXMSW__
}
#endif // __WXMSW__
aEvent.Skip();
}