mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-10-03 13:26:03 +00:00
Replaced snap util function with std::clamp.
This commit is contained in:
@@ -78,7 +78,7 @@ float64 ContinuousSlider::computeValue(const QPoint &pos) const {
|
||||
const auto result = isHorizontal() ?
|
||||
(pos.x() - seekRect.x()) / float64(seekRect.width()) :
|
||||
(1. - (pos.y() - seekRect.y()) / float64(seekRect.height()));
|
||||
const auto snapped = snap(result, 0., 1.);
|
||||
const auto snapped = std::clamp(result, 0., 1.);
|
||||
return _adjustCallback ? _adjustCallback(snapped) : snapped;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ void ContinuousSlider::wheelEvent(QWheelEvent *e) {
|
||||
deltaX *= -1;
|
||||
}
|
||||
auto delta = (qAbs(deltaX) > qAbs(deltaY)) ? deltaX : deltaY;
|
||||
auto finalValue = snap(_value + delta * coef, 0., 1.);
|
||||
auto finalValue = std::clamp(_value + delta * coef, 0., 1.);
|
||||
setValue(finalValue);
|
||||
if (_changeProgressCallback) {
|
||||
_changeProgressCallback(finalValue);
|
||||
|
Reference in New Issue
Block a user