@@ -465,22 +465,23 @@ void GUISlider::OnMouseMove(int X, int Y, int Buttons, int Modifier)
465
465
466
466
void GUISlider::OnMouseWheelChange (int x, int y, int modifier, int mouseWheelChange) {
467
467
m_OldValue = m_Value;
468
- const int size = (m_Orientation == Horizontal) ? m_Width : m_Height;
469
-
470
- const float ratio = static_cast <float >(m_ValueResolution) / static_cast <float >(m_Maximum - m_Minimum);
471
- const int posRange = size - m_KnobSize - m_EndThickness;
472
- const int posDelta = std::max (static_cast <int >(ratio * static_cast <float >(posRange)),1 );
468
+
473
469
if (mouseWheelChange < 0 ) {
474
470
m_Value = std::max (m_Value - m_ValueResolution, m_Minimum);
475
- m_KnobPosition = std::max (m_KnobPosition - posDelta, m_EndThickness);
476
471
} else {
477
472
m_Value = std::min (m_Value + m_ValueResolution, m_Maximum);
478
- m_KnobPosition = std::min (m_KnobPosition + posDelta, posRange);
479
473
}
474
+
475
+ if (m_Value != m_OldValue) {
476
+ const int size = (m_Orientation == Horizontal) ? m_Width : m_Height;
477
+ const int posRange = size - m_KnobSize - m_EndThickness;
478
+ const float ratio = static_cast <float >(m_Value) / static_cast <float >(m_Maximum - m_Minimum);
479
+ m_KnobPosition = m_EndThickness + static_cast <int >(std::round (static_cast <float >(posRange) * ratio));
480
480
481
- if (m_Value != m_OldValue)
482
481
AddEvent (GUIEvent::Notification, Changed, 0 );
482
+ }
483
483
}
484
+
484
485
/*
485
486
486
487
//////////////////////////////////////////////////////////////////////////////////////////
0 commit comments