From 4f35d8854a110fc9c166196a7f51fce3ad4822e6 Mon Sep 17 00:00:00 2001 From: fourtf Date: Thu, 31 May 2018 12:59:43 +0200 Subject: [PATCH] made message backgrounds overflow into the scrollbar --- src/messages/layouts/messagelayout.cpp | 12 +++++------- src/messages/layouts/messagelayout.hpp | 2 +- src/singletons/thememanager.cpp | 3 ++- src/widgets/helper/channelview.cpp | 5 +++-- src/widgets/scrollbar.cpp | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/messages/layouts/messagelayout.cpp b/src/messages/layouts/messagelayout.cpp index 7be83b95e..391983129 100644 --- a/src/messages/layouts/messagelayout.cpp +++ b/src/messages/layouts/messagelayout.cpp @@ -149,8 +149,8 @@ void MessageLayout::actuallyLayout(int width, MessageElement::Flags _flags) } // Painting -void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection &selection, - bool isLastReadMessage, bool isWindowFocused) +void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex, + Selection &selection, bool isLastReadMessage, bool isWindowFocused) { auto app = getApp(); QPixmap *pixmap = this->m_buffer.get(); @@ -158,13 +158,11 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection // create new buffer if required if (!pixmap) { #ifdef Q_OS_MACOS - pixmap = - new QPixmap(int(this->m_container.getWidth() * painter.device()->devicePixelRatioF()), - int(this->m_container.getHeight() * painter.device()->devicePixelRatioF())); + pixmap = new QPixmap(int(width * painter.device()->devicePixelRatioF()), + int(width * painter.device()->devicePixelRatioF())); pixmap->setDevicePixelRatio(painter.device()->devicePixelRatioF()); #else - pixmap = - new QPixmap(this->m_container.getWidth(), std::max(16, this->m_container.getHeight())); + pixmap = new QPixmap(width, std::max(16, this->m_container.getHeight())); #endif this->m_buffer = std::shared_ptr(pixmap); diff --git a/src/messages/layouts/messagelayout.hpp b/src/messages/layouts/messagelayout.hpp index 3289e9126..27d806485 100644 --- a/src/messages/layouts/messagelayout.hpp +++ b/src/messages/layouts/messagelayout.hpp @@ -42,7 +42,7 @@ public: bool layout(int width, float m_scale, MessageElement::Flags flags); // Painting - void paint(QPainter &painter, int y, int messageIndex, Selection &selection, + void paint(QPainter &painter, int width, int y, int messageIndex, Selection &selection, bool isLastReadMessage, bool isWindowFocused); void invalidateBuffer(); void deleteBuffer(); diff --git a/src/singletons/thememanager.cpp b/src/singletons/thememanager.cpp index 6d4c60435..f4126bfd4 100644 --- a/src/singletons/thememanager.cpp +++ b/src/singletons/thememanager.cpp @@ -174,7 +174,8 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier) // this->messages.seperatorInner = // Scrollbar - this->scrollbars.background = getColor(0, sat, 0.94); + this->scrollbars.background = splits.background; + this->scrollbars.background.setAlphaF(qreal(0.4)); this->scrollbars.thumb = getColor(0, sat, 0.80); this->scrollbars.thumbSelected = getColor(0, sat, 0.7); diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index 3172fc1ce..cf1d68c9e 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -27,7 +27,8 @@ #include #include -#define LAYOUT_WIDTH (this->width() - (this->scrollBar.isVisible() ? 16 : 4) * this->getScale()) +#define LAYOUT_WIDTH (this->width() - (this->scrollBar.isVisible() ? 16 : 2) * this->getScale()) +#define DRAW_WIDTH (this->width()) #define SELECTION_RESUME_SCROLLING_MSG_THRESHOLD 3 #define CHAT_HOVER_PAUSE_DURATION 400 @@ -617,7 +618,7 @@ void ChannelView::drawMessages(QPainter &painter) isLastMessage = this->lastReadMessage.get() == layout; } - layout->paint(painter, y, i, this->selection, isLastMessage, windowFocused); + layout->paint(painter, DRAW_WIDTH, y, i, this->selection, isLastMessage, windowFocused); y += layout->getHeight(); diff --git a/src/widgets/scrollbar.cpp b/src/widgets/scrollbar.cpp index 422fdeedb..e75506902 100644 --- a/src/widgets/scrollbar.cpp +++ b/src/widgets/scrollbar.cpp @@ -202,7 +202,7 @@ void Scrollbar::paintEvent(QPaintEvent *) int xOffset = mouseOver ? 0 : width() - int(4 * this->getScale()); QPainter painter(this); - // painter.fillRect(rect(), this->themeManager->ScrollbarBG); + painter.fillRect(rect(), this->themeManager->scrollbars.background); // painter.fillRect(QRect(xOffset, 0, width(), this->buttonHeight), // this->themeManager->ScrollbarArrow);