mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Colorize status in premium promo and pack preview.
This commit is contained in:
parent
c13221a984
commit
e32031963b
4 changed files with 34 additions and 2 deletions
|
@ -305,6 +305,7 @@ private:
|
|||
std::vector<Element> _elements;
|
||||
std::unique_ptr<Lottie::MultiPlayer> _lottiePlayer;
|
||||
|
||||
mutable Ui::Text::CustomEmojiColored _colored;
|
||||
base::flat_map<
|
||||
not_null<DocumentData*>,
|
||||
std::unique_ptr<Ui::Text::CustomEmoji>> _customEmoji;
|
||||
|
@ -1268,8 +1269,10 @@ void StickerSetBox::Inner::paintSticker(
|
|||
(_singleSize.height() - size.height()) / 2);
|
||||
auto lottieFrame = QImage();
|
||||
if (element.emoji) {
|
||||
_colored.color = st::profileVerifiedCheckBg->c;
|
||||
element.emoji->paint(p, {
|
||||
.preview = st::windowBgOver->c,
|
||||
.colored = &_colored,
|
||||
.now = now,
|
||||
.position = ppos,
|
||||
.paused = paused,
|
||||
|
|
|
@ -782,6 +782,10 @@ Session &CustomEmojiManager::owner() const {
|
|||
return *_owner;
|
||||
}
|
||||
|
||||
uint64 CustomEmojiManager::coloredSetId() const {
|
||||
return _coloredSetId;
|
||||
}
|
||||
|
||||
int FrameSizeFromTag(SizeTag tag) {
|
||||
const auto emoji = EmojiSizeFromTag(tag);
|
||||
const auto factor = style::DevicePixelRatio();
|
||||
|
|
|
@ -77,6 +77,8 @@ public:
|
|||
[[nodiscard]] Main::Session &session() const;
|
||||
[[nodiscard]] Session &owner() const;
|
||||
|
||||
[[nodiscard]] uint64 coloredSetId() const;
|
||||
|
||||
private:
|
||||
static constexpr auto kSizeCount = int(SizeTag::kCount);
|
||||
|
||||
|
|
|
@ -437,12 +437,16 @@ public:
|
|||
void paint(QPainter &p);
|
||||
|
||||
private:
|
||||
QPixmap paintedPixmap(const QSize &size) const;
|
||||
[[nodiscard]] QPixmap paintedPixmap(const QSize &size) const;
|
||||
|
||||
void resolveIsColored();
|
||||
|
||||
QRectF _rect;
|
||||
std::shared_ptr<Data::DocumentMedia> _media;
|
||||
std::unique_ptr<HistoryView::StickerPlayer> _player;
|
||||
bool _paused = false;
|
||||
bool _isColored = false;
|
||||
bool _isColoredResolved = false;
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
@ -508,12 +512,31 @@ QPixmap EmojiStatusTopBar::paintedPixmap(const QSize &size) const {
|
|||
return QPixmap();
|
||||
}
|
||||
|
||||
void EmojiStatusTopBar::resolveIsColored() {
|
||||
if (_isColoredResolved) {
|
||||
return;
|
||||
}
|
||||
const auto document = _media->owner();
|
||||
const auto manager = &document->owner().customEmojiManager();
|
||||
const auto coloredSetId = manager->coloredSetId();
|
||||
if (!coloredSetId) {
|
||||
return;
|
||||
}
|
||||
_isColoredResolved = true;
|
||||
const auto sticker = document->sticker();
|
||||
const auto setId = sticker ? sticker->set.id : 0;
|
||||
_isColored = sticker && (sticker->set.id == coloredSetId);
|
||||
}
|
||||
|
||||
void EmojiStatusTopBar::paint(QPainter &p) {
|
||||
if (_player) {
|
||||
if (_player->ready()) {
|
||||
resolveIsColored();
|
||||
const auto frame = _player->frame(
|
||||
_rect.size().toSize(),
|
||||
Qt::transparent,
|
||||
(_isColored
|
||||
? st::profileVerifiedCheckBg->c
|
||||
: QColor(0, 0, 0, 0)),
|
||||
false,
|
||||
crl::now(),
|
||||
_paused);
|
||||
|
|
Loading…
Add table
Reference in a new issue