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();
|
_repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
Internal::Internal(QString entityData, QImage image, bool colored)
|
Internal::Internal(
|
||||||
|
QString entityData,
|
||||||
|
QImage image,
|
||||||
|
QMargins padding,
|
||||||
|
bool colored)
|
||||||
: _entityData(std::move(entityData))
|
: _entityData(std::move(entityData))
|
||||||
, _image(std::move(image))
|
, _image(std::move(image))
|
||||||
|
, _padding(padding)
|
||||||
, _colored(colored) {
|
, _colored(colored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int Internal::width() {
|
int Internal::width() {
|
||||||
return _image.width() / _image.devicePixelRatio();
|
return _padding.left()
|
||||||
|
+ (_image.width() / _image.devicePixelRatio())
|
||||||
|
+ _padding.right();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Internal::entityData() {
|
QString Internal::entityData() {
|
||||||
|
|
@ -880,7 +887,9 @@ void Internal::paint(QPainter &p, const Context &context) {
|
||||||
context.internal.colorized = _colored;
|
context.internal.colorized = _colored;
|
||||||
|
|
||||||
const auto size = _image.size() / style::DevicePixelRatio();
|
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);
|
PaintScaledImage(p, rect, { &_image }, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,11 @@ private:
|
||||||
|
|
||||||
class Internal final : public Text::CustomEmoji {
|
class Internal final : public Text::CustomEmoji {
|
||||||
public:
|
public:
|
||||||
Internal(QString entityData, QImage image, bool colored);
|
Internal(
|
||||||
|
QString entityData,
|
||||||
|
QImage image,
|
||||||
|
QMargins padding,
|
||||||
|
bool colored);
|
||||||
|
|
||||||
int width() override;
|
int width() override;
|
||||||
QString entityData() override;
|
QString entityData() override;
|
||||||
|
|
@ -288,6 +292,7 @@ public:
|
||||||
private:
|
private:
|
||||||
const QString _entityData;
|
const QString _entityData;
|
||||||
const QImage _image;
|
const QImage _image;
|
||||||
|
const QMargins _padding;
|
||||||
const bool _colored = false;
|
const bool _colored = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue