mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 23:27:09 +02:00
Disable sync between sticker and effect.
This commit is contained in:
parent
b02a965778
commit
693d886d81
10 changed files with 125 additions and 125 deletions
|
@ -119,12 +119,12 @@ void PreloadSticker(const std::shared_ptr<Data::DocumentMedia> &media) {
|
|||
state->lottie->frame());
|
||||
p.drawImage(raw->rect(), state->effect->frame());
|
||||
|
||||
if (!frame.image.isNull()
|
||||
&& ((frame.index % effectsCount) <= effect.index)) {
|
||||
if (!frame.image.isNull()/*
|
||||
&& ((frame.index % effectsCount) <= effect.index)*/) {
|
||||
state->lottie->markFrameShown();
|
||||
}
|
||||
if (!effect.image.isNull()
|
||||
&& ((effect.index % framesCount) <= frame.index)) {
|
||||
if (!effect.image.isNull()/*
|
||||
&& ((effect.index % framesCount) <= frame.index)*/) {
|
||||
state->effect->markFrameShown();
|
||||
}
|
||||
}, lifetime);
|
||||
|
|
|
@ -412,18 +412,18 @@ void Element::setY(int y) {
|
|||
void Element::refreshDataIdHook() {
|
||||
}
|
||||
|
||||
void Element::externalLottieProgressing(bool external) const {
|
||||
if (const auto media = _media.get()) {
|
||||
media->externalLottieProgressing(external);
|
||||
}
|
||||
}
|
||||
|
||||
bool Element::externalLottieTill(ExternalLottieInfo info) const {
|
||||
if (const auto media = _media.get()) {
|
||||
return media->externalLottieTill(info);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//void Element::externalLottieProgressing(bool external) const {
|
||||
// if (const auto media = _media.get()) {
|
||||
// media->externalLottieProgressing(external);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//bool Element::externalLottieTill(ExternalLottieInfo info) const {
|
||||
// if (const auto media = _media.get()) {
|
||||
// return media->externalLottieTill(info);
|
||||
// }
|
||||
// return true;
|
||||
//}
|
||||
|
||||
void Element::repaint() const {
|
||||
history()->owner().requestViewRepaint(this);
|
||||
|
|
|
@ -44,7 +44,7 @@ enum class InfoDisplayType : char;
|
|||
struct StateRequest;
|
||||
struct TextState;
|
||||
class Media;
|
||||
struct ExternalLottieInfo;
|
||||
//struct ExternalLottieInfo;
|
||||
|
||||
using PaintContext = Ui::ChatPaintContext;
|
||||
|
||||
|
@ -272,8 +272,8 @@ public:
|
|||
Context context() const;
|
||||
void refreshDataId();
|
||||
|
||||
void externalLottieProgressing(bool external) const;
|
||||
bool externalLottieTill(ExternalLottieInfo info) const;
|
||||
//void externalLottieProgressing(bool external) const;
|
||||
//bool externalLottieTill(ExternalLottieInfo info) const;
|
||||
|
||||
QDateTime dateTime() const;
|
||||
|
||||
|
|
|
@ -65,11 +65,11 @@ EmojiInteractions::EmojiInteractions(
|
|||
}
|
||||
|
||||
EmojiInteractions::~EmojiInteractions() {
|
||||
for (const auto &play : _plays) {
|
||||
if (play.premium) {
|
||||
play.view->externalLottieProgressing(false);
|
||||
}
|
||||
}
|
||||
//for (const auto &play : _plays) {
|
||||
// if (play.premium) {
|
||||
// play.view->externalLottieProgressing(false);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
void EmojiInteractions::play(
|
||||
|
@ -103,13 +103,13 @@ void EmojiInteractions::playPremiumEffect(
|
|||
if (replacing) {
|
||||
const auto i = ranges::find(_plays, replacing, &Play::view);
|
||||
if (i != end(_plays)) {
|
||||
if (i->premium) {
|
||||
replacing->externalLottieProgressing(false);
|
||||
}
|
||||
//if (i->premium) {
|
||||
// replacing->externalLottieProgressing(false);
|
||||
//}
|
||||
i->view = view;
|
||||
if (i->premium) {
|
||||
view->externalLottieProgressing(true);
|
||||
}
|
||||
//if (i->premium) {
|
||||
// view->externalLottieProgressing(true);
|
||||
//}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -133,8 +133,8 @@ void EmojiInteractions::cancelPremiumEffect(not_null<const Element*> view) {
|
|||
_plays.erase(ranges::remove_if(_plays, [&](const Play &play) {
|
||||
if (play.view != view) {
|
||||
return false;
|
||||
} else if (play.premium) {
|
||||
play.view->externalLottieProgressing(false);
|
||||
//} else if (play.premium) {
|
||||
// play.view->externalLottieProgressing(false);
|
||||
}
|
||||
return true;
|
||||
}), end(_plays));
|
||||
|
@ -192,9 +192,9 @@ void EmojiInteractions::play(
|
|||
}
|
||||
});
|
||||
}, lottie->lifetime());
|
||||
if (premium) {
|
||||
view->externalLottieProgressing(true);
|
||||
}
|
||||
//if (premium) {
|
||||
// view->externalLottieProgressing(true);
|
||||
//}
|
||||
_plays.push_back({
|
||||
.view = view,
|
||||
.lottie = std::move(lottie),
|
||||
|
@ -328,19 +328,19 @@ void EmojiInteractions::paint(QPainter &p) {
|
|||
p.drawImage(
|
||||
QRect(rect.topLeft(), frame.image.size() / factor),
|
||||
frame.image);
|
||||
const auto info = HistoryView::ExternalLottieInfo{
|
||||
.frame = frame.index,
|
||||
.count = play.framesCount,
|
||||
};
|
||||
if (!play.premium || play.view->externalLottieTill(info)) {
|
||||
//const auto info = HistoryView::ExternalLottieInfo{
|
||||
// .frame = frame.index,
|
||||
// .count = play.framesCount,
|
||||
//};
|
||||
//if (!play.premium || play.view->externalLottieTill(info)) {
|
||||
play.lottie->markFrameShown();
|
||||
}
|
||||
//}
|
||||
}
|
||||
_plays.erase(ranges::remove_if(_plays, [](const Play &play) {
|
||||
if (!play.finished) {
|
||||
return false;
|
||||
} else if (play.premium) {
|
||||
play.view->externalLottieProgressing(false);
|
||||
//} else if (play.premium) {
|
||||
// play.view->externalLottieProgressing(false);
|
||||
}
|
||||
return true;
|
||||
}), end(_plays));
|
||||
|
|
|
@ -69,10 +69,10 @@ enum class MediaInBubbleState {
|
|||
TimeId duration,
|
||||
const QString &base);
|
||||
|
||||
struct ExternalLottieInfo {
|
||||
int frame = -1;
|
||||
int count = -1;
|
||||
};
|
||||
//struct ExternalLottieInfo {
|
||||
// int frame = -1;
|
||||
// int count = -1;
|
||||
//};
|
||||
|
||||
class Media : public Object {
|
||||
public:
|
||||
|
@ -178,14 +178,14 @@ public:
|
|||
virtual void checkAnimation() {
|
||||
}
|
||||
|
||||
virtual void externalLottieProgressing(bool external) {
|
||||
}
|
||||
virtual bool externalLottieTill(ExternalLottieInfo info) {
|
||||
return true;
|
||||
}
|
||||
virtual ExternalLottieInfo externalLottieInfo() const {
|
||||
return {};
|
||||
}
|
||||
//virtual void externalLottieProgressing(bool external) {
|
||||
//}
|
||||
//virtual bool externalLottieTill(ExternalLottieInfo info) {
|
||||
// return true;
|
||||
//}
|
||||
//virtual ExternalLottieInfo externalLottieInfo() const {
|
||||
// return {};
|
||||
//}
|
||||
|
||||
[[nodiscard]] virtual QSize sizeForGroupingOptimal(int maxWidth) const {
|
||||
Unexpected("Grouping method call.");
|
||||
|
|
|
@ -460,17 +460,17 @@ std::unique_ptr<Lottie::SinglePlayer> UnwrappedMedia::stickerTakeLottie(
|
|||
return _content->stickerTakeLottie(data, replacements);
|
||||
}
|
||||
|
||||
void UnwrappedMedia::externalLottieProgressing(bool external) {
|
||||
_content->externalLottieProgressing(external);
|
||||
}
|
||||
|
||||
bool UnwrappedMedia::externalLottieTill(ExternalLottieInfo info) {
|
||||
return _content->externalLottieTill(info);
|
||||
}
|
||||
|
||||
ExternalLottieInfo UnwrappedMedia::externalLottieInfo() const {
|
||||
return _content->externalLottieInfo();
|
||||
}
|
||||
//void UnwrappedMedia::externalLottieProgressing(bool external) {
|
||||
// _content->externalLottieProgressing(external);
|
||||
//}
|
||||
//
|
||||
//bool UnwrappedMedia::externalLottieTill(ExternalLottieInfo info) {
|
||||
// return _content->externalLottieTill(info);
|
||||
//}
|
||||
//
|
||||
//ExternalLottieInfo UnwrappedMedia::externalLottieInfo() const {
|
||||
// return _content->externalLottieInfo();
|
||||
//}
|
||||
|
||||
int UnwrappedMedia::calculateFullRight(const QRect &inner) const {
|
||||
const auto rightAligned = _parent->hasOutLayout()
|
||||
|
|
|
@ -41,14 +41,14 @@ public:
|
|||
not_null<DocumentData*> data,
|
||||
const Lottie::ColorReplacements *replacements);
|
||||
|
||||
virtual void externalLottieProgressing(bool external) {
|
||||
}
|
||||
virtual bool externalLottieTill(ExternalLottieInfo info) {
|
||||
return true;
|
||||
}
|
||||
virtual ExternalLottieInfo externalLottieInfo() const {
|
||||
return {};
|
||||
}
|
||||
//virtual void externalLottieProgressing(bool external) {
|
||||
//}
|
||||
//virtual bool externalLottieTill(ExternalLottieInfo info) {
|
||||
// return true;
|
||||
//}
|
||||
//virtual ExternalLottieInfo externalLottieInfo() const {
|
||||
// return {};
|
||||
//}
|
||||
|
||||
virtual bool hasHeavyPart() const {
|
||||
return false;
|
||||
|
@ -102,9 +102,9 @@ public:
|
|||
not_null<DocumentData*> data,
|
||||
const Lottie::ColorReplacements *replacements) override;
|
||||
|
||||
void externalLottieProgressing(bool external) override;
|
||||
bool externalLottieTill(ExternalLottieInfo info) override;
|
||||
ExternalLottieInfo externalLottieInfo() const override;
|
||||
//void externalLottieProgressing(bool external) override;
|
||||
//bool externalLottieTill(ExternalLottieInfo info) override;
|
||||
//ExternalLottieInfo externalLottieInfo() const override;
|
||||
|
||||
bool hasHeavyPart() const override {
|
||||
return _content->hasHeavyPart();
|
||||
|
|
|
@ -75,7 +75,7 @@ Sticker::Sticker(
|
|||
if (const auto media = replacing ? replacing->media() : nullptr) {
|
||||
_lottie = media->stickerTakeLottie(_data, _replacements);
|
||||
if (_lottie) {
|
||||
_externalInfo = media->externalLottieInfo();
|
||||
//_externalInfo = media->externalLottieInfo();
|
||||
if (_data->isPremiumSticker()
|
||||
&& !_premiumEffectPlayed) {
|
||||
_premiumEffectPlayed = true;
|
||||
|
@ -217,9 +217,9 @@ void Sticker::paintLottie(
|
|||
const auto count = _lottie->information().framesCount;
|
||||
_frameIndex = frame.index;
|
||||
_framesCount = count;
|
||||
const auto paused = (_externalInfo.frame >= 0)
|
||||
const auto paused = /*(_externalInfo.frame >= 0)
|
||||
? (_frameIndex % _externalInfo.count >= _externalInfo.frame)
|
||||
: _parent->delegate()->elementIsGifPaused();
|
||||
: */_parent->delegate()->elementIsGifPaused();
|
||||
_nextLastDiceFrame = !paused
|
||||
&& (_diceIndex > 0)
|
||||
&& (_frameIndex + 2 == count);
|
||||
|
@ -230,8 +230,8 @@ void Sticker::paintLottie(
|
|||
: (isEmojiSticker()
|
||||
|| !Core::App().settings().loopAnimatedStickers());
|
||||
const auto lastDiceFrame = (_diceIndex > 0) && atTheEnd();
|
||||
const auto switchToNext = (_externalInfo.frame >= 0)
|
||||
|| !playOnce
|
||||
const auto switchToNext = /*(_externalInfo.frame >= 0)
|
||||
|| */!playOnce
|
||||
|| (!lastDiceFrame && (_frameIndex != 0 || !_lottieOncePlayed));
|
||||
if (!paused
|
||||
&& switchToNext
|
||||
|
@ -426,7 +426,7 @@ void Sticker::lottieCreated() {
|
|||
) | rpl::start_with_next([=](Lottie::Update update) {
|
||||
v::match(update.data, [&](const Lottie::Information &information) {
|
||||
_parent->history()->owner().requestViewResize(_parent);
|
||||
markFramesTillExternal();
|
||||
//markFramesTillExternal();
|
||||
}, [&](const Lottie::DisplayFrameRequest &request) {
|
||||
_parent->history()->owner().requestViewRepaint(_parent);
|
||||
});
|
||||
|
@ -465,38 +465,38 @@ std::unique_ptr<Lottie::SinglePlayer> Sticker::stickerTakeLottie(
|
|||
: nullptr;
|
||||
}
|
||||
|
||||
void Sticker::externalLottieProgressing(bool external) {
|
||||
_externalInfo = !external
|
||||
? ExternalLottieInfo{}
|
||||
: (_externalInfo.frame > 0)
|
||||
? _externalInfo
|
||||
: ExternalLottieInfo{ 0, 2 };
|
||||
}
|
||||
|
||||
bool Sticker::externalLottieTill(ExternalLottieInfo info) {
|
||||
if (_externalInfo.frame >= 0) {
|
||||
_externalInfo = info;
|
||||
}
|
||||
return markFramesTillExternal();
|
||||
}
|
||||
|
||||
ExternalLottieInfo Sticker::externalLottieInfo() const {
|
||||
return _externalInfo;
|
||||
}
|
||||
|
||||
bool Sticker::markFramesTillExternal() {
|
||||
if (_externalInfo.frame < 0 || !_lottie) {
|
||||
return true;
|
||||
} else if (!_lottie->ready()) {
|
||||
return false;
|
||||
}
|
||||
const auto till = _externalInfo.frame % _lottie->framesCount();
|
||||
while (_lottie->frameIndex() < till) {
|
||||
if (!_lottie->markFrameShown()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//void Sticker::externalLottieProgressing(bool external) {
|
||||
// _externalInfo = !external
|
||||
// ? ExternalLottieInfo{}
|
||||
// : (_externalInfo.frame > 0)
|
||||
// ? _externalInfo
|
||||
// : ExternalLottieInfo{ 0, 2 };
|
||||
//}
|
||||
//
|
||||
//bool Sticker::externalLottieTill(ExternalLottieInfo info) {
|
||||
// if (_externalInfo.frame >= 0) {
|
||||
// _externalInfo = info;
|
||||
// }
|
||||
// return markFramesTillExternal();
|
||||
//}
|
||||
//
|
||||
//ExternalLottieInfo Sticker::externalLottieInfo() const {
|
||||
// return _externalInfo;
|
||||
//}
|
||||
//
|
||||
//bool Sticker::markFramesTillExternal() {
|
||||
// if (_externalInfo.frame < 0 || !_lottie) {
|
||||
// return true;
|
||||
// } else if (!_lottie->ready()) {
|
||||
// return false;
|
||||
// }
|
||||
// const auto till = _externalInfo.frame % _lottie->framesCount();
|
||||
// while (_lottie->frameIndex() < till) {
|
||||
// if (!_lottie->markFrameShown()) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
//}
|
||||
|
||||
} // namespace HistoryView
|
||||
|
|
|
@ -51,9 +51,9 @@ public:
|
|||
not_null<DocumentData*> data,
|
||||
const Lottie::ColorReplacements *replacements) override;
|
||||
|
||||
void externalLottieProgressing(bool external) override;
|
||||
bool externalLottieTill(ExternalLottieInfo info) override;
|
||||
ExternalLottieInfo externalLottieInfo() const override;
|
||||
//void externalLottieProgressing(bool external) override;
|
||||
//bool externalLottieTill(ExternalLottieInfo info) override;
|
||||
//ExternalLottieInfo externalLottieInfo() const override;
|
||||
|
||||
bool hasHeavyPart() const override;
|
||||
void unloadHeavyPart() override;
|
||||
|
@ -96,7 +96,7 @@ private:
|
|||
void lottieCreated();
|
||||
void unloadLottie();
|
||||
void emojiStickerClicked();
|
||||
bool markFramesTillExternal();
|
||||
//bool markFramesTillExternal();
|
||||
|
||||
const not_null<Element*> _parent;
|
||||
const not_null<DocumentData*> _data;
|
||||
|
@ -107,7 +107,7 @@ private:
|
|||
QSize _size;
|
||||
QImage _lastDiceFrame;
|
||||
QString _diceEmoji;
|
||||
ExternalLottieInfo _externalInfo;
|
||||
//ExternalLottieInfo _externalInfo;
|
||||
int _diceIndex = -1;
|
||||
mutable int _frameIndex = -1;
|
||||
mutable int _framesCount = -1;
|
||||
|
|
|
@ -116,12 +116,12 @@ void MediaPreviewWidget::paintEvent(QPaintEvent *e) {
|
|||
emojiLeft += _emojiSize + st::stickerEmojiSkip;
|
||||
}
|
||||
}
|
||||
if (!frame.image.isNull()
|
||||
&& (!_effect || ((frame.index % effectsCount) <= effect.index))) {
|
||||
if (!frame.image.isNull()/*
|
||||
&& (!_effect || ((frame.index % effectsCount) <= effect.index))*/) {
|
||||
_lottie->markFrameShown();
|
||||
}
|
||||
if (!effect.image.isNull()
|
||||
&& ((effect.index % framesCount) <= frame.index)) {
|
||||
if (!effect.image.isNull()/*
|
||||
&& ((effect.index % framesCount) <= frame.index)*/) {
|
||||
_effect->markFrameShown();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue