mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 21:27:07 +02:00
Fix intro hello sticker playback in editing.
This commit is contained in:
parent
191c35914f
commit
98ce91df39
8 changed files with 52 additions and 48 deletions
|
@ -180,13 +180,10 @@ ChatIntroBox::ChatIntroBox(not_null<Element*> parent, Data::ChatIntro data)
|
|||
, _data(data) {
|
||||
if (const auto document = data.sticker) {
|
||||
if (const auto sticker = document->sticker()) {
|
||||
const auto skipPremiumEffect = false;
|
||||
const auto skipPremiumEffect = true;
|
||||
_sticker.emplace(_parent, document, skipPremiumEffect, _parent);
|
||||
_sticker->setDiceIndex(sticker->alt, 0);
|
||||
_sticker->setGiftBoxSticker(true);
|
||||
_sticker->initSize();
|
||||
_sticker->setCustomEmojiPart(
|
||||
st::chatIntroStickerSize,
|
||||
_sticker->initSize(st::chatIntroStickerSize);
|
||||
_sticker->setCustomCachingTag(
|
||||
ChatHelpers::StickerLottieSize::ChatIntroHelloSticker);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -753,14 +753,16 @@ void Element::refreshMedia(Element *replacing) {
|
|||
const auto emojiStickers = &history()->session().emojiStickersPack();
|
||||
const auto skipPremiumEffect = false;
|
||||
if (const auto sticker = emojiStickers->stickerForEmoji(emoji)) {
|
||||
auto content = std::make_unique<Sticker>(
|
||||
this,
|
||||
sticker.document,
|
||||
skipPremiumEffect,
|
||||
replacing,
|
||||
sticker.replacements);
|
||||
content->setEmojiSticker();
|
||||
_media = std::make_unique<UnwrappedMedia>(
|
||||
this,
|
||||
std::make_unique<Sticker>(
|
||||
this,
|
||||
sticker.document,
|
||||
skipPremiumEffect,
|
||||
replacing,
|
||||
sticker.replacements));
|
||||
std::move(content));
|
||||
} else {
|
||||
_media = std::make_unique<UnwrappedMedia>(
|
||||
this,
|
||||
|
|
|
@ -128,7 +128,9 @@ std::unique_ptr<Sticker> CustomEmoji::createStickerPart(
|
|||
_parent,
|
||||
document,
|
||||
skipPremiumEffect);
|
||||
result->setCustomEmojiPart(_singleSize, _cachingTag);
|
||||
result->initSize(_singleSize);
|
||||
result->setCustomCachingTag(_cachingTag);
|
||||
result->setCustomEmojiPart();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -310,10 +310,10 @@ void StickerWithBadgePart::draw(
|
|||
int outerWidth) const {
|
||||
const auto stickerSize = st::msgServiceGiftBoxStickerSize;
|
||||
const auto sticker = QRect(
|
||||
(outerWidth - stickerSize.width()) / 2,
|
||||
(outerWidth - stickerSize) / 2,
|
||||
st::chatGiveawayStickerTop + _skipTop,
|
||||
stickerSize.width(),
|
||||
stickerSize.height());
|
||||
stickerSize,
|
||||
stickerSize);
|
||||
|
||||
if (_sticker) {
|
||||
_sticker->draw(p, context, sticker);
|
||||
|
@ -335,7 +335,7 @@ void StickerWithBadgePart::unloadHeavyPart() {
|
|||
|
||||
QSize StickerWithBadgePart::countOptimalSize() {
|
||||
const auto size = st::msgServiceGiftBoxStickerSize;
|
||||
return { size.width(), st::chatGiveawayStickerTop + size.height() };
|
||||
return { size, st::chatGiveawayStickerTop + size };
|
||||
}
|
||||
|
||||
QSize StickerWithBadgePart::countCurrentSize(int newWidth) {
|
||||
|
@ -352,8 +352,9 @@ void StickerWithBadgePart::ensureCreated() const {
|
|||
_skipTop = data.skipTop;
|
||||
_sticker.emplace(_parent, document, skipPremiumEffect, _parent);
|
||||
_sticker->setDiceIndex(sticker->alt, 1);
|
||||
_sticker->setGiftBoxSticker(data.isGiftBoxSticker);
|
||||
_sticker->initSize();
|
||||
_sticker->initSize(data.isGiftBoxSticker
|
||||
? st::msgServiceGiftBoxStickerSize
|
||||
: 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,9 @@ int PremiumGift::top() {
|
|||
}
|
||||
|
||||
QSize PremiumGift::size() {
|
||||
return st::msgServiceGiftBoxStickerSize;
|
||||
return QSize(
|
||||
st::msgServiceGiftBoxStickerSize,
|
||||
st::msgServiceGiftBoxStickerSize);
|
||||
}
|
||||
|
||||
QString PremiumGift::title() {
|
||||
|
@ -172,8 +174,7 @@ void PremiumGift::ensureStickerCreated() const {
|
|||
const auto skipPremiumEffect = false;
|
||||
_sticker.emplace(_parent, document, skipPremiumEffect, _parent);
|
||||
_sticker->setDiceIndex(sticker->alt, 1);
|
||||
_sticker->setGiftBoxSticker(true);
|
||||
_sticker->initSize();
|
||||
_sticker->initSize(st::msgServiceGiftBoxStickerSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,20 +130,18 @@ bool Sticker::hasPremiumEffect() const {
|
|||
}
|
||||
|
||||
bool Sticker::customEmojiPart() const {
|
||||
return (_cachingTag != ChatHelpers::StickerLottieSize::MessageHistory);
|
||||
return _customEmojiPart;
|
||||
}
|
||||
|
||||
bool Sticker::isEmojiSticker() const {
|
||||
return (_parent->data()->media() == nullptr);
|
||||
bool Sticker::emojiSticker() const {
|
||||
return _emojiSticker;
|
||||
}
|
||||
|
||||
void Sticker::initSize() {
|
||||
if (isEmojiSticker() || _diceIndex >= 0) {
|
||||
if (_giftBoxSticker) {
|
||||
_size = st::msgServiceGiftBoxStickerSize;
|
||||
} else {
|
||||
_size = EmojiSize();
|
||||
}
|
||||
void Sticker::initSize(int customSize) {
|
||||
if (customSize > 0) {
|
||||
_size = { customSize, customSize };
|
||||
} else if (emojiSticker() || _diceIndex >= 0) {
|
||||
_size = EmojiSize();
|
||||
if (_diceIndex > 0) {
|
||||
[[maybe_unused]] bool result = readyToDrawAnimationFrame();
|
||||
}
|
||||
|
@ -252,7 +250,7 @@ void Sticker::paintAnimationFrame(
|
|||
: (context.selected() && !_nextLastDiceFrame)
|
||||
? context.st->msgStickerOverlay()->c
|
||||
: QColor(0, 0, 0, 0);
|
||||
const auto powerSavingFlag = (isEmojiSticker() || _diceIndex >= 0)
|
||||
const auto powerSavingFlag = (emojiSticker() || _diceIndex >= 0)
|
||||
? PowerSaving::kEmojiChat
|
||||
: PowerSaving::kStickersChat;
|
||||
const auto paused = context.paused || On(powerSavingFlag);
|
||||
|
@ -298,7 +296,7 @@ void Sticker::paintAnimationFrame(
|
|||
? true
|
||||
: (_diceIndex == 0)
|
||||
? false
|
||||
: ((!customEmojiPart() && isEmojiSticker())
|
||||
: ((!customEmojiPart() && emojiSticker())
|
||||
|| !Core::App().settings().loopAnimatedStickers());
|
||||
const auto lastDiceFrame = (_diceIndex > 0) && atTheEnd();
|
||||
const auto switchToNext = !playOnce
|
||||
|
@ -421,7 +419,7 @@ void Sticker::refreshLink() {
|
|||
return;
|
||||
}
|
||||
const auto sticker = _data->sticker();
|
||||
if (isEmojiSticker()) {
|
||||
if (emojiSticker()) {
|
||||
const auto weak = base::make_weak(this);
|
||||
_link = std::make_shared<LambdaClickHandler>([weak] {
|
||||
if (const auto that = weak.get()) {
|
||||
|
@ -499,15 +497,16 @@ void Sticker::setDiceIndex(const QString &emoji, int index) {
|
|||
_diceIndex = index;
|
||||
}
|
||||
|
||||
void Sticker::setCustomEmojiPart(
|
||||
int size,
|
||||
ChatHelpers::StickerLottieSize tag) {
|
||||
_size = { size, size };
|
||||
void Sticker::setCustomCachingTag(ChatHelpers::StickerLottieSize tag) {
|
||||
_cachingTag = tag;
|
||||
}
|
||||
|
||||
void Sticker::setGiftBoxSticker(bool giftBoxSticker) {
|
||||
_giftBoxSticker = giftBoxSticker;
|
||||
void Sticker::setCustomEmojiPart() {
|
||||
_customEmojiPart = true;
|
||||
}
|
||||
|
||||
void Sticker::setEmojiSticker() {
|
||||
_emojiSticker = true;
|
||||
}
|
||||
|
||||
void Sticker::setupPlayer() {
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
const Lottie::ColorReplacements *replacements = nullptr);
|
||||
~Sticker();
|
||||
|
||||
void initSize();
|
||||
void initSize(int customSize = 0);
|
||||
QSize countOptimalSize() override;
|
||||
void draw(
|
||||
Painter &p,
|
||||
|
@ -62,12 +62,13 @@ public:
|
|||
|
||||
void refreshLink() override;
|
||||
bool hasTextForCopy() const override {
|
||||
return isEmojiSticker();
|
||||
return emojiSticker();
|
||||
}
|
||||
|
||||
void setDiceIndex(const QString &emoji, int index);
|
||||
void setCustomEmojiPart(int size, ChatHelpers::StickerLottieSize tag);
|
||||
void setGiftBoxSticker(bool giftBoxSticker);
|
||||
void setCustomCachingTag(ChatHelpers::StickerLottieSize tag);
|
||||
void setCustomEmojiPart();
|
||||
void setEmojiSticker();
|
||||
[[nodiscard]] bool atTheEnd() const {
|
||||
return (_frameIndex >= 0) && (_frameIndex + 1 == _framesCount);
|
||||
}
|
||||
|
@ -96,7 +97,7 @@ public:
|
|||
private:
|
||||
[[nodiscard]] bool hasPremiumEffect() const;
|
||||
[[nodiscard]] bool customEmojiPart() const;
|
||||
[[nodiscard]] bool isEmojiSticker() const;
|
||||
[[nodiscard]] bool emojiSticker() const;
|
||||
void paintAnimationFrame(
|
||||
Painter &p,
|
||||
const PaintContext &context,
|
||||
|
@ -134,7 +135,8 @@ private:
|
|||
mutable bool _premiumEffectSkipped : 1 = false;
|
||||
mutable bool _nextLastDiceFrame : 1 = false;
|
||||
bool _skipPremiumEffect : 1 = false;
|
||||
bool _giftBoxSticker : 1 = false;
|
||||
bool _customEmojiPart : 1 = false;
|
||||
bool _emojiSticker : 1 = false;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -923,7 +923,7 @@ msgServiceGiftBoxButtonPadding: margins(2px, 0px, 2px, 0px);
|
|||
msgServiceGiftBoxButtonMargins: margins(0px, 13px, 0px, 17px);
|
||||
msgServiceGiftBoxTitlePadding: margins(0px, 5px, 0px, 2px);
|
||||
msgServiceGiftBoxStickerTop: -19px;
|
||||
msgServiceGiftBoxStickerSize: size(140px, 140px);
|
||||
msgServiceGiftBoxStickerSize: 140px;
|
||||
|
||||
historySponsorInfoItem: FlatLabel(defaultFlatLabel) {
|
||||
style: TextStyle(defaultTextStyle) {
|
||||
|
|
Loading…
Add table
Reference in a new issue