Fixed a bug where scrolling layouts wrong

It used the wrong with to layout the messages.
This commit is contained in:
fourtf 2018-01-05 10:41:21 +01:00
parent 69488eb2ea
commit 8418e36e49
2 changed files with 11 additions and 7 deletions

View file

@ -2,6 +2,7 @@
#include <QMap> #include <QMap>
#include <QString> #include <QString>
#include <memory>
#include <mutex> #include <mutex>
namespace chatterino { namespace chatterino {

View file

@ -24,6 +24,9 @@
#include <functional> #include <functional>
#include <memory> #include <memory>
#define LAYOUT_WIDTH \
(this->width() - (this->scrollBar.isVisible() ? 16 : 4) * this->getDpiMultiplier())
using namespace chatterino::messages; using namespace chatterino::messages;
namespace chatterino { namespace chatterino {
@ -141,8 +144,7 @@ void ChannelView::actuallyLayoutMessages()
size_t start = this->scrollBar.getCurrentValue(); size_t start = this->scrollBar.getCurrentValue();
// int layoutWidth = // int layoutWidth =
// (this->scrollBar.isVisible() ? width() - this->scrollBar.width() : width()) - 4; // (this->scrollBar.isVisible() ? width() - this->scrollBar.width() : width()) - 4;
int layoutWidth = int layoutWidth = LAYOUT_WIDTH;
this->width() - (this->scrollBar.isVisible() ? 16 : 4) * this->getDpiMultiplier();
// layout the visible messages in the view // layout the visible messages in the view
if (messagesSnapshot.getLength() > start) { if (messagesSnapshot.getLength() > start) {
@ -447,13 +449,13 @@ void ChannelView::detachChannel()
void ChannelView::resizeEvent(QResizeEvent *) void ChannelView::resizeEvent(QResizeEvent *)
{ {
this->scrollBar.resize(this->scrollBar.width(), height()); this->scrollBar.resize(this->scrollBar.width(), height());
this->scrollBar.move(width() - this->scrollBar.width(), 0); this->scrollBar.move(this->width() - this->scrollBar.width(), 0);
this->goToBottom->setGeometry(0, this->height() - 32, this->width(), 32); this->goToBottom->setGeometry(0, this->height() - 32, this->width(), 32);
this->scrollBar.raise(); this->scrollBar.raise();
layoutMessages(); this->layoutMessages();
this->update(); this->update();
} }
@ -542,7 +544,8 @@ void ChannelView::drawMessages(QPainter &painter, bool overlays)
bool updateBuffer = false; bool updateBuffer = false;
if (!buffer) { if (!buffer) {
buffer = std::shared_ptr<QPixmap>(new QPixmap(width(), messageRef->getHeight())); buffer =
std::shared_ptr<QPixmap>(new QPixmap(this->width(), messageRef->getHeight()));
updateBuffer = true; updateBuffer = true;
} }
@ -845,7 +848,7 @@ void ChannelView::wheelEvent(QWheelEvent *event)
if (i == 0) { if (i == 0) {
desired = 0; desired = 0;
} else { } else {
snapshot[i - 1]->layout(this->width(), this->getDpiMultiplier()); snapshot[i - 1]->layout(LAYOUT_WIDTH, this->getDpiMultiplier());
scrollFactor = 1; scrollFactor = 1;
currentScrollLeft = snapshot[i - 1]->getHeight(); currentScrollLeft = snapshot[i - 1]->getHeight();
} }
@ -867,7 +870,7 @@ void ChannelView::wheelEvent(QWheelEvent *event)
if (i == snapshot.getLength() - 1) { if (i == snapshot.getLength() - 1) {
desired = snapshot.getLength(); desired = snapshot.getLength();
} else { } else {
snapshot[i + 1]->layout(this->width(), this->getDpiMultiplier()); snapshot[i + 1]->layout(LAYOUT_WIDTH, this->getDpiMultiplier());
scrollFactor = 1; scrollFactor = 1;
currentScrollLeft = snapshot[i + 1]->getHeight(); currentScrollLeft = snapshot[i + 1]->getHeight();