revert: use max(minimum, min(bottom, value)) over clamp(..) (#5393)

This commit is contained in:
nerix 2024-05-13 20:00:50 +02:00 committed by GitHub
parent 2ad45bc288
commit fdecb4a39f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View file

@ -10,7 +10,7 @@
- Dev: Use Qt's high DPI scaling. (#4868) - Dev: Use Qt's high DPI scaling. (#4868)
- Dev: Add doxygen build target. (#5377) - Dev: Add doxygen build target. (#5377)
- Dev: Make printing of strings in tests easier. (#5379) - Dev: Make printing of strings in tests easier. (#5379)
- Dev: Refactor and document `Scrollbar`. (#5334) - Dev: Refactor and document `Scrollbar`. (#5334, #5393)
## 2.5.1 ## 2.5.1

View file

@ -153,7 +153,9 @@ void Scrollbar::setPageSize(qreal value)
void Scrollbar::setDesiredValue(qreal value, bool animated) void Scrollbar::setDesiredValue(qreal value, bool animated)
{ {
value = std::clamp(value, this->minimum_, this->getBottom()); // this can't use std::clamp, because minimum_ < getBottom() isn't always
// true, which is a precondition for std::clamp
value = std::max(this->minimum_, std::min(this->getBottom(), value));
if (areClose(this->currentValue_, value)) if (areClose(this->currentValue_, value))
{ {
// value has not changed // value has not changed