mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Replaced snap util function with std::clamp.
This commit is contained in:
@@ -423,7 +423,7 @@ void RoundImageCheckbox::paint(Painter &p, int x, int y, int outerWidth) {
|
||||
|
||||
if (selectionLevel > 0) {
|
||||
PainterHighQualityEnabler hq(p);
|
||||
p.setOpacity(snap(selectionLevel, 0., 1.));
|
||||
p.setOpacity(std::clamp(selectionLevel, 0., 1.));
|
||||
p.setBrush(Qt::NoBrush);
|
||||
auto pen = _st.selectFg->p;
|
||||
pen.setWidth(_st.selectWidth);
|
||||
@@ -438,7 +438,7 @@ void RoundImageCheckbox::paint(Painter &p, int x, int y, int outerWidth) {
|
||||
}
|
||||
|
||||
float64 RoundImageCheckbox::checkedAnimationRatio() const {
|
||||
return snap(_selection.value(checked() ? 1. : 0.), 0., 1.);
|
||||
return std::clamp(_selection.value(checked() ? 1. : 0.), 0., 1.);
|
||||
}
|
||||
|
||||
void RoundImageCheckbox::setChecked(bool newChecked, anim::type animated) {
|
||||
|
@@ -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);
|
||||
|
@@ -280,7 +280,11 @@ void SettingsSlider::paintEvent(QPaintEvent *e) {
|
||||
auto activeLeft = getCurrentActiveLeft();
|
||||
|
||||
enumerateSections([&](Section §ion) {
|
||||
auto active = 1. - snap(qAbs(activeLeft - section.left) / float64(section.width), 0., 1.);
|
||||
auto active = 1.
|
||||
- std::clamp(
|
||||
qAbs(activeLeft - section.left) / float64(section.width),
|
||||
0.,
|
||||
1.);
|
||||
if (section.ripple) {
|
||||
auto color = anim::color(_st.rippleBg, _st.rippleBgActive, active);
|
||||
section.ripple->paint(p, section.left, 0, width(), &color);
|
||||
|
Reference in New Issue
Block a user