Fix scrollbar

This commit is contained in:
Rasmus Karlsson
2017-06-06 17:18:23 +02:00
parent 2d2d6dad17
commit 814fc4bbae
4 changed files with 62 additions and 17 deletions
+23 -2
View File
@@ -1,6 +1,7 @@
#include "widgets/scrollbar.h"
#include "colorscheme.h"
#include <QDebug>
#include <QMouseEvent>
#include <QPainter>
@@ -88,6 +89,16 @@ void ScrollBar::addHighlight(ScrollBarHighlight *highlight)
_mutex.unlock();
}
void ScrollBar::scrollToBottom()
{
this->setDesiredValue(this->_maximum - this->getLargeChange());
}
bool ScrollBar::isAtBottom() const
{
return this->getCurrentValue() == this->getMaximum() - this->getLargeChange();
}
void ScrollBar::setMaximum(qreal value)
{
_maximum = value;
@@ -188,6 +199,15 @@ void ScrollBar::setCurrentValue(qreal value)
}
}
void ScrollBar::printCurrentState(const QString &prefix) const
{
qDebug() << prefix //
<< "Current value: " << this->getCurrentValue() //
<< ". Maximum: " << this->getMaximum() //
<< ". Minimum: " << this->getMinimum() //
<< ". Large change: " << this->getLargeChange(); //
}
void ScrollBar::paintEvent(QPaintEvent *)
{
QPainter painter(this);
@@ -301,5 +321,6 @@ void ScrollBar::updateScroll()
update();
}
}
}
} // namespace widgets
} // namespace chatterino