fixed scrollbar thumb not moving
This commit is contained in:
+12
-10
@@ -276,8 +276,7 @@ void Scrollbar::paintEvent(QPaintEvent *)
|
||||
|
||||
int w = this->width();
|
||||
float y = 0;
|
||||
float dY =
|
||||
float(this->height()) / std::max<float>(1.0f, float(snapshotLength));
|
||||
float dY = float(this->height()) / float(snapshotLength);
|
||||
int highlightHeight =
|
||||
int(std::ceil(std::max<float>(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<qreal>(0.02, this->trackHeight_ * this->maximum_));
|
||||
setDesiredValue(this->desiredValue_ +
|
||||
qreal(delta) /
|
||||
std::max<qreal>(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<qreal>(0.01, this->maximum_ * this->trackHeight_);
|
||||
auto div = std::max<qreal>(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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user