diff --git a/src/messages/layouts/messagelayout.cpp b/src/messages/layouts/messagelayout.cpp index dabefc837..a297b4beb 100644 --- a/src/messages/layouts/messagelayout.cpp +++ b/src/messages/layouts/messagelayout.cpp @@ -172,6 +172,9 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection painter.fillRect(0, y, pixmap->width(), pixmap->height(), themeManager.messages.disabled); } + // draw gif emotes + this->container.paintAnimatedElements(painter, y); + this->bufferValid = true; } diff --git a/src/messages/layouts/messagelayoutcontainer.cpp b/src/messages/layouts/messagelayoutcontainer.cpp index 823471d24..4b3417c93 100644 --- a/src/messages/layouts/messagelayoutcontainer.cpp +++ b/src/messages/layouts/messagelayoutcontainer.cpp @@ -148,10 +148,17 @@ void MessageLayoutContainer::paintElements(QPainter &painter) } } +void MessageLayoutContainer::paintAnimatedElements(QPainter &painter, int yOffset) +{ + for (const std::unique_ptr &element : this->elements) { + element->paintAnimated(painter, yOffset); + } +} + void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex, Selection &selection) { } } // namespace layouts -} -} +} // namespace messages +} // namespace chatterino diff --git a/src/messages/layouts/messagelayoutcontainer.hpp b/src/messages/layouts/messagelayoutcontainer.hpp index b642ed093..8341884e6 100644 --- a/src/messages/layouts/messagelayoutcontainer.hpp +++ b/src/messages/layouts/messagelayoutcontainer.hpp @@ -64,6 +64,7 @@ public: // painting void paintElements(QPainter &painter); + void paintAnimatedElements(QPainter &painter, int yOffset); void paintSelection(QPainter &painter, int messageIndex, Selection &selection); private: @@ -80,5 +81,5 @@ private: std::vector> elements; }; } // namespace layouts -} -} +} // namespace messages +} // namespace chatterino diff --git a/src/messages/layouts/messagelayoutelement.cpp b/src/messages/layouts/messagelayoutelement.cpp index bd01a7428..e902dce03 100644 --- a/src/messages/layouts/messagelayoutelement.cpp +++ b/src/messages/layouts/messagelayoutelement.cpp @@ -71,12 +71,14 @@ void ImageLayoutElement::paint(QPainter &painter) } } -void ImageLayoutElement::paintAnimated(QPainter &painter) +void ImageLayoutElement::paintAnimated(QPainter &painter, int yOffset) { if (this->image.isAnimated()) { if (this->image.getPixmap() != nullptr) { // fourtf: make it use qreal values - painter.drawPixmap(QRectF(this->getRect()), *this->image.getPixmap(), QRectF()); + QRect rect = this->getRect(); + rect.moveTop(yOffset); + painter.drawPixmap(QRectF(rect), *this->image.getPixmap(), QRectF()); } } } @@ -119,7 +121,7 @@ void TextLayoutElement::paint(QPainter &painter) QTextOption(Qt::AlignLeft | Qt::AlignTop)); } -void TextLayoutElement::paintAnimated(QPainter &painter) +void TextLayoutElement::paintAnimated(QPainter &, int) { } diff --git a/src/messages/layouts/messagelayoutelement.hpp b/src/messages/layouts/messagelayoutelement.hpp index 3418f7d94..d15e54e56 100644 --- a/src/messages/layouts/messagelayoutelement.hpp +++ b/src/messages/layouts/messagelayoutelement.hpp @@ -34,7 +34,7 @@ public: virtual void addCopyTextToString(QString &str, int from = 0, int to = INT_MAX) const = 0; virtual int getSelectionIndexCount() = 0; virtual void paint(QPainter &painter) = 0; - virtual void paintAnimated(QPainter &painter) = 0; + virtual void paintAnimated(QPainter &painter, int yOffset) = 0; virtual int getMouseOverIndex(const QPoint &abs) = 0; protected: @@ -56,7 +56,7 @@ protected: virtual void addCopyTextToString(QString &str, int from = 0, int to = INT_MAX) const override; virtual int getSelectionIndexCount() override; virtual void paint(QPainter &painter) override; - virtual void paintAnimated(QPainter &painter) override; + virtual void paintAnimated(QPainter &painter, int yOffset) override; virtual int getMouseOverIndex(const QPoint &abs) override; private: @@ -74,7 +74,7 @@ protected: virtual void addCopyTextToString(QString &str, int from = 0, int to = INT_MAX) const override; virtual int getSelectionIndexCount() override; virtual void paint(QPainter &painter) override; - virtual void paintAnimated(QPainter &painter) override; + virtual void paintAnimated(QPainter &painter, int yOffset) override; virtual int getMouseOverIndex(const QPoint &abs) override; private: