mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Hide emoji outline instead of disabling it
This commit is contained in:
@@ -323,13 +323,14 @@ EmojiImageLoader::EmojiImageLoader(
|
||||
QImage EmojiImageLoader::prepare(EmojiPtr emoji) {
|
||||
const auto loaded = _images->ensureLoaded();
|
||||
const auto factor = cIntRetinaFactor();
|
||||
const auto side = st::largeEmojiSize;
|
||||
auto result = QImage(
|
||||
QSize(side, side) * factor,
|
||||
const auto side = st::largeEmojiSize + 2 * st::largeEmojiOutline;
|
||||
auto tinted = QImage(
|
||||
QSize(st::largeEmojiSize, st::largeEmojiSize) * factor,
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
result.fill(Qt::transparent);
|
||||
tinted.fill(QColor(0, 0, 0, 0));
|
||||
if (loaded) {
|
||||
QPainter p(&result);
|
||||
QPainter p(&tinted);
|
||||
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||
_images->draw(
|
||||
p,
|
||||
emoji,
|
||||
@@ -337,6 +338,43 @@ QImage EmojiImageLoader::prepare(EmojiPtr emoji) {
|
||||
0,
|
||||
0);
|
||||
}
|
||||
auto result = QImage(
|
||||
QSize(side, side) * factor,
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
result.fill(Qt::transparent);
|
||||
if (loaded) {
|
||||
QPainter p(&result);
|
||||
const auto delta = st::largeEmojiOutline * factor;
|
||||
const auto planar = std::array<QPoint, 4>{ {
|
||||
{ 0, -1 },
|
||||
{ -1, 0 },
|
||||
{ 1, 0 },
|
||||
{ 0, 1 },
|
||||
} };
|
||||
for (const auto &shift : planar) {
|
||||
for (auto i = 0; i != delta; ++i) {
|
||||
p.drawImage(QPoint(delta, delta) + shift * (i + 1), tinted);
|
||||
}
|
||||
}
|
||||
const auto diagonal = std::array<QPoint, 4>{ {
|
||||
{ -1, -1 },
|
||||
{ 1, -1 },
|
||||
{ -1, 1 },
|
||||
{ 1, 1 },
|
||||
} };
|
||||
const auto corrected = int(std::round(delta / sqrt(2.)));
|
||||
for (const auto &shift : diagonal) {
|
||||
for (auto i = 0; i != corrected; ++i) {
|
||||
p.drawImage(QPoint(delta, delta) + shift * (i + 1), tinted);
|
||||
}
|
||||
}
|
||||
_images->draw(
|
||||
p,
|
||||
emoji,
|
||||
st::largeEmojiSize * factor,
|
||||
delta,
|
||||
delta);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -55,7 +55,7 @@ QSize LargeEmoji::size() {
|
||||
Assert(count > 0);
|
||||
|
||||
const auto single = _images[0]->size() / cIntRetinaFactor();
|
||||
const auto skip = st::largeEmojiSkip;
|
||||
const auto skip = st::largeEmojiSkip - 2 * st::largeEmojiOutline;
|
||||
const auto inner = count * single.width() + (count - 1) * skip;
|
||||
const auto &padding = st::largeEmojiPadding;
|
||||
_size = QSize(
|
||||
@@ -70,7 +70,7 @@ void LargeEmoji::draw(Painter &p, const QRect &r, bool selected) {
|
||||
auto x = r.x() + (r.width() - _size.width()) / 2 + padding.left();
|
||||
const auto y = r.y() + (r.height() - _size.height()) / 2 + padding.top();
|
||||
const auto o = Data::FileOrigin();
|
||||
const auto skip = st::largeEmojiSkip;
|
||||
const auto skip = st::largeEmojiSkip - 2 * st::largeEmojiOutline;
|
||||
for (const auto &image : images) {
|
||||
image->load(Data::FileOrigin());
|
||||
const auto w = image->width() / cIntRetinaFactor();
|
||||
|
@@ -34,7 +34,7 @@ QSize UnwrappedMedia::countOptimalSize() {
|
||||
_content->size(),
|
||||
{ st::maxStickerSize, st::historyStickerHeight }));
|
||||
auto maxWidth = _contentSize.width();
|
||||
const auto minimal = st::largeEmojiSize;
|
||||
const auto minimal = st::largeEmojiSize + 2 * st::largeEmojiOutline;
|
||||
auto minHeight = std::max(_contentSize.height(), minimal);
|
||||
if (_parent->media() == this) {
|
||||
const auto item = _parent->data();
|
||||
|
Reference in New Issue
Block a user