Use internal custom emoji with paddings.
This commit is contained in:
parent
fa787b6b0d
commit
08235c5e06
2 changed files with 18 additions and 4 deletions
|
|
@ -862,14 +862,21 @@ void Object::repaint() {
|
|||
_repaint();
|
||||
}
|
||||
|
||||
Internal::Internal(QString entityData, QImage image, bool colored)
|
||||
Internal::Internal(
|
||||
QString entityData,
|
||||
QImage image,
|
||||
QMargins padding,
|
||||
bool colored)
|
||||
: _entityData(std::move(entityData))
|
||||
, _image(std::move(image))
|
||||
, _padding(padding)
|
||||
, _colored(colored) {
|
||||
}
|
||||
|
||||
int Internal::width() {
|
||||
return _image.width() / _image.devicePixelRatio();
|
||||
return _padding.left()
|
||||
+ (_image.width() / _image.devicePixelRatio())
|
||||
+ _padding.right();
|
||||
}
|
||||
|
||||
QString Internal::entityData() {
|
||||
|
|
@ -880,7 +887,9 @@ void Internal::paint(QPainter &p, const Context &context) {
|
|||
context.internal.colorized = _colored;
|
||||
|
||||
const auto size = _image.size() / style::DevicePixelRatio();
|
||||
const auto rect = QRect(context.position, size);
|
||||
const auto rect = QRect(
|
||||
context.position + QPoint(_padding.left(), _padding.top()),
|
||||
size);
|
||||
PaintScaledImage(p, rect, { &_image }, context);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -276,7 +276,11 @@ private:
|
|||
|
||||
class Internal final : public Text::CustomEmoji {
|
||||
public:
|
||||
Internal(QString entityData, QImage image, bool colored);
|
||||
Internal(
|
||||
QString entityData,
|
||||
QImage image,
|
||||
QMargins padding,
|
||||
bool colored);
|
||||
|
||||
int width() override;
|
||||
QString entityData() override;
|
||||
|
|
@ -288,6 +292,7 @@ public:
|
|||
private:
|
||||
const QString _entityData;
|
||||
const QImage _image;
|
||||
const QMargins _padding;
|
||||
const bool _colored = false;
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue