mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
added margin to emote input items
This commit is contained in:
parent
95f975996d
commit
758fdc28ee
1 changed files with 21 additions and 6 deletions
|
@ -19,23 +19,38 @@ void EmoteInputItem::action()
|
|||
void EmoteInputItem::paint(QPainter *painter, const QRect &rect) const
|
||||
{
|
||||
painter->setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
auto margin = 4;
|
||||
auto imageHeight = ICON_SIZE.height() - margin * 2;
|
||||
|
||||
QRect iconRect{
|
||||
rect.topLeft() + QPoint{margin, margin},
|
||||
QSize{imageHeight, imageHeight},
|
||||
};
|
||||
|
||||
if (this->emote_)
|
||||
{
|
||||
if (auto image = this->emote_->images.getImage(4))
|
||||
if (auto image = this->emote_->images.getImage(2))
|
||||
{
|
||||
if (auto pixmap = image->pixmapOrLoad())
|
||||
{
|
||||
painter->drawPixmap(QRect(rect.x(), rect.y(), ICON_SIZE.width(),
|
||||
ICON_SIZE.height()),
|
||||
*pixmap);
|
||||
if (image->height() != 0)
|
||||
{
|
||||
auto aspectRatio =
|
||||
double(image->width()) / double(image->height());
|
||||
|
||||
iconRect = {
|
||||
rect.topLeft() + QPoint{margin, margin},
|
||||
QSize(int(imageHeight * aspectRatio), imageHeight)};
|
||||
painter->drawPixmap(iconRect, *pixmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QRect iconRect(rect.topLeft(), ICON_SIZE);
|
||||
QRect textRect =
|
||||
QRect(iconRect.topRight(),
|
||||
QRect(iconRect.topRight() + QPoint{margin, 0},
|
||||
QSize(rect.width() - iconRect.width(), iconRect.height()));
|
||||
painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, this->text_);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue