fixed gif emotes not drawing

This commit is contained in:
fourtf 2018-01-13 02:13:59 +01:00
parent 40733ca312
commit 9703cf6ad4
5 changed files with 23 additions and 10 deletions

View file

@ -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;
}

View file

@ -148,10 +148,17 @@ void MessageLayoutContainer::paintElements(QPainter &painter)
}
}
void MessageLayoutContainer::paintAnimatedElements(QPainter &painter, int yOffset)
{
for (const std::unique_ptr<MessageLayoutElement> &element : this->elements) {
element->paintAnimated(painter, yOffset);
}
}
void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
Selection &selection)
{
}
} // namespace layouts
}
}
} // namespace messages
} // namespace chatterino

View file

@ -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<std::unique_ptr<MessageLayoutElement>> elements;
};
} // namespace layouts
}
}
} // namespace messages
} // namespace chatterino

View file

@ -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)
{
}

View file

@ -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: