From 370e6dc61b456e5da29a564947941d709c2ee8d2 Mon Sep 17 00:00:00 2001 From: fourtf Date: Tue, 21 Apr 2020 20:57:16 +0200 Subject: [PATCH] fixed scrollbar thumb not moving --- src/widgets/Scrollbar.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/widgets/Scrollbar.cpp b/src/widgets/Scrollbar.cpp index 6f4288fd5..1bc3c19cf 100644 --- a/src/widgets/Scrollbar.cpp +++ b/src/widgets/Scrollbar.cpp @@ -276,8 +276,7 @@ void Scrollbar::paintEvent(QPaintEvent *) int w = this->width(); float y = 0; - float dY = - float(this->height()) / std::max(1.0f, float(snapshotLength)); + float dY = float(this->height()) / float(snapshotLength); int highlightHeight = int(std::ceil(std::max(this->scale() * 2, dY))); @@ -357,10 +356,10 @@ void Scrollbar::mouseMoveEvent(QMouseEvent *event) { int delta = event->pos().y() - this->lastMousePosition_.y(); - setDesiredValue( - this->desiredValue_ + - qreal(delta) / - std::max(0.02, this->trackHeight_ * this->maximum_)); + setDesiredValue(this->desiredValue_ + + qreal(delta) / + std::max(0.00000002, this->trackHeight_ * + this->maximum_)); } this->lastMousePosition_ = event->pos(); @@ -445,11 +444,14 @@ void Scrollbar::updateScroll() this->trackHeight_ = this->height() - this->buttonHeight_ - this->buttonHeight_ - MIN_THUMB_HEIGHT - 1; - auto div = std::max(0.01, this->maximum_ * this->trackHeight_); + auto div = std::max(0.0000001, this->maximum_); - this->thumbRect_ = - QRect(0, int(this->currentValue_ / div) + 1 + this->buttonHeight_, - this->width(), int(this->largeChange_ / div) + MIN_THUMB_HEIGHT); + this->thumbRect_ = QRect( + 0, + int(this->currentValue_ / div * this->trackHeight_) + 1 + + this->buttonHeight_, + this->width(), + int(this->largeChange_ / div * this->trackHeight_) + MIN_THUMB_HEIGHT); this->update(); }