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