mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Use CustomEmoji instances for categories in the panel.
This commit is contained in:
parent
655194c841
commit
01f28b4d52
3 changed files with 37 additions and 29 deletions
|
@ -1474,31 +1474,12 @@ std::vector<StickerIcon> EmojiListWidget::fillIcons() {
|
||||||
} else {
|
} else {
|
||||||
result.emplace_back(AllEmojiSectionSetId());
|
result.emplace_back(AllEmojiSectionSetId());
|
||||||
}
|
}
|
||||||
|
const auto esize = Data::FrameSizeFromTag(
|
||||||
|
Data::CustomEmojiManager::SizeTag::Large
|
||||||
|
) / style::DevicePixelRatio();
|
||||||
for (const auto &custom : _custom) {
|
for (const auto &custom : _custom) {
|
||||||
const auto set = custom.set;
|
const auto set = custom.set;
|
||||||
const auto s = custom.thumbnailDocument;
|
result.emplace_back(set, custom.thumbnailDocument, esize, esize);
|
||||||
const auto availw = st::stickerIconWidth - 2 * st::emojiIconPadding;
|
|
||||||
const auto availh = st::emojiFooterHeight - 2 * st::emojiIconPadding;
|
|
||||||
const auto size = set->hasThumbnail()
|
|
||||||
? QSize(
|
|
||||||
set->thumbnailLocation().width(),
|
|
||||||
set->thumbnailLocation().height())
|
|
||||||
: s->hasThumbnail()
|
|
||||||
? QSize(
|
|
||||||
s->thumbnailLocation().width(),
|
|
||||||
s->thumbnailLocation().height())
|
|
||||||
: QSize();
|
|
||||||
auto thumbw = size.width(), thumbh = size.height(), pixw = 1, pixh = 1;
|
|
||||||
if (availw * thumbh > availh * thumbw) {
|
|
||||||
pixh = availh;
|
|
||||||
pixw = (pixh * thumbw) / thumbh;
|
|
||||||
} else {
|
|
||||||
pixw = availw;
|
|
||||||
pixh = thumbw ? ((pixw * thumbh) / thumbw) : 1;
|
|
||||||
}
|
|
||||||
if (pixw < 1) pixw = 1;
|
|
||||||
if (pixh < 1) pixh = 1;
|
|
||||||
result.emplace_back(set, s, pixw, pixh);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "chat_helpers/stickers_lottie.h"
|
#include "chat_helpers/stickers_lottie.h"
|
||||||
#include "data/stickers/data_stickers_set.h"
|
#include "data/stickers/data_stickers_set.h"
|
||||||
#include "data/stickers/data_stickers.h"
|
#include "data/stickers/data_stickers.h"
|
||||||
|
#include "data/stickers/data_custom_emoji.h"
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
@ -88,11 +89,11 @@ StickerIcon::StickerIcon(
|
||||||
DocumentData *sticker,
|
DocumentData *sticker,
|
||||||
int pixw,
|
int pixw,
|
||||||
int pixh)
|
int pixh)
|
||||||
: setId(set->id)
|
: setId(set->id)
|
||||||
, set(set)
|
, set(set)
|
||||||
, sticker(sticker)
|
, sticker(sticker)
|
||||||
, pixw(pixw)
|
, pixw(pixw)
|
||||||
, pixh(pixh) {
|
, pixh(pixh) {
|
||||||
}
|
}
|
||||||
|
|
||||||
StickerIcon::StickerIcon(StickerIcon&&) = default;
|
StickerIcon::StickerIcon(StickerIcon&&) = default;
|
||||||
|
@ -530,6 +531,7 @@ void StickersListFooter::setLoading(bool loading) {
|
||||||
void StickersListFooter::paintEvent(QPaintEvent *e) {
|
void StickersListFooter::paintEvent(QPaintEvent *e) {
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
|
|
||||||
|
_repaintScheduled = false;
|
||||||
if (_searchButtonVisible) {
|
if (_searchButtonVisible) {
|
||||||
paintSearchIcon(p);
|
paintSearchIcon(p);
|
||||||
}
|
}
|
||||||
|
@ -951,6 +953,7 @@ void StickersListFooter::refreshIcons(
|
||||||
if (now.sticker == was.sticker) {
|
if (now.sticker == was.sticker) {
|
||||||
now.webm = std::move(was.webm);
|
now.webm = std::move(was.webm);
|
||||||
now.lottie = std::move(was.lottie);
|
now.lottie = std::move(was.lottie);
|
||||||
|
now.custom = std::move(was.custom);
|
||||||
now.lifetime = std::move(was.lifetime);
|
now.lifetime = std::move(was.lifetime);
|
||||||
now.savedFrame = std::move(was.savedFrame);
|
now.savedFrame = std::move(was.savedFrame);
|
||||||
}
|
}
|
||||||
|
@ -1052,6 +1055,13 @@ void StickersListFooter::paintSearchIcon(Painter &p) const {
|
||||||
width());
|
width());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StickersListFooter::customEmojiRepaint() {
|
||||||
|
if (!_repaintScheduled) {
|
||||||
|
_repaintScheduled = true;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void StickersListFooter::validateIconLottieAnimation(
|
void StickersListFooter::validateIconLottieAnimation(
|
||||||
const StickerIcon &icon) {
|
const StickerIcon &icon) {
|
||||||
icon.ensureMediaCreated();
|
icon.ensureMediaCreated();
|
||||||
|
@ -1104,6 +1114,18 @@ void StickersListFooter::validateIconWebmAnimation(
|
||||||
|
|
||||||
void StickersListFooter::validateIconAnimation(
|
void StickersListFooter::validateIconAnimation(
|
||||||
const StickerIcon &icon) {
|
const StickerIcon &icon) {
|
||||||
|
const auto emoji = icon.sticker;
|
||||||
|
if (emoji && emoji->sticker()->setType == Data::StickersType::Emoji) {
|
||||||
|
if (!icon.custom) {
|
||||||
|
const auto tag = Data::CustomEmojiManager::SizeTag::Large;
|
||||||
|
auto &manager = emoji->owner().customEmojiManager();
|
||||||
|
icon.custom = manager.create(
|
||||||
|
emoji->id,
|
||||||
|
[=] { customEmojiRepaint(); },
|
||||||
|
tag);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
validateIconWebmAnimation(icon);
|
validateIconWebmAnimation(icon);
|
||||||
validateIconLottieAnimation(icon);
|
validateIconLottieAnimation(icon);
|
||||||
}
|
}
|
||||||
|
@ -1138,7 +1160,9 @@ void StickersListFooter::paintSetIcon(
|
||||||
: nullptr;
|
: nullptr;
|
||||||
const auto x = info.adjustedLeft + (_singleWidth - icon.pixw) / 2;
|
const auto x = info.adjustedLeft + (_singleWidth - icon.pixw) / 2;
|
||||||
const auto y = _iconsTop + (st::emojiFooterHeight - icon.pixh) / 2;
|
const auto y = _iconsTop + (st::emojiFooterHeight - icon.pixh) / 2;
|
||||||
if (icon.lottie && icon.lottie->ready()) {
|
if (icon.custom) {
|
||||||
|
icon.custom->paint(p, x, y, now, st::emojiIconFg->c, paused);
|
||||||
|
} else if (icon.lottie && icon.lottie->ready()) {
|
||||||
const auto frame = icon.lottie->frame();
|
const auto frame = icon.lottie->frame();
|
||||||
const auto size = frame.size() / cIntRetinaFactor();
|
const auto size = frame.size() / cIntRetinaFactor();
|
||||||
if (icon.savedFrame.isNull()) {
|
if (icon.savedFrame.isNull()) {
|
||||||
|
|
|
@ -62,6 +62,7 @@ struct StickerIcon {
|
||||||
uint64 setId = 0;
|
uint64 setId = 0;
|
||||||
Data::StickersSet *set = nullptr;
|
Data::StickersSet *set = nullptr;
|
||||||
mutable std::unique_ptr<Lottie::SinglePlayer> lottie;
|
mutable std::unique_ptr<Lottie::SinglePlayer> lottie;
|
||||||
|
mutable std::unique_ptr<Ui::Text::CustomEmoji> custom;
|
||||||
mutable Media::Clip::ReaderPointer webm;
|
mutable Media::Clip::ReaderPointer webm;
|
||||||
mutable QImage savedFrame;
|
mutable QImage savedFrame;
|
||||||
DocumentData *sticker = nullptr;
|
DocumentData *sticker = nullptr;
|
||||||
|
@ -179,6 +180,7 @@ private:
|
||||||
void validateIconLottieAnimation(const StickerIcon &icon);
|
void validateIconLottieAnimation(const StickerIcon &icon);
|
||||||
void validateIconWebmAnimation(const StickerIcon &icon);
|
void validateIconWebmAnimation(const StickerIcon &icon);
|
||||||
void validateIconAnimation(const StickerIcon &icon);
|
void validateIconAnimation(const StickerIcon &icon);
|
||||||
|
void customEmojiRepaint();
|
||||||
|
|
||||||
void refreshIconsGeometry(
|
void refreshIconsGeometry(
|
||||||
uint64 activeSetId,
|
uint64 activeSetId,
|
||||||
|
@ -243,6 +245,7 @@ private:
|
||||||
int _subiconsWidth = 0;
|
int _subiconsWidth = 0;
|
||||||
bool _subiconsExpanded = false;
|
bool _subiconsExpanded = false;
|
||||||
bool _barSelection = false;
|
bool _barSelection = false;
|
||||||
|
bool _repaintScheduled = false;
|
||||||
|
|
||||||
bool _horizontal = false;
|
bool _horizontal = false;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue