2
0
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:
23rd
2021-01-23 06:29:50 +03:00
parent 4895e5e110
commit dd01ece14a
44 changed files with 193 additions and 92 deletions

View File

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