Fix editing animated emoji messages.

This commit is contained in:
John Preston 2020-07-02 14:44:12 +04:00
parent 76596f42c7
commit 822c0434e8
6 changed files with 30 additions and 11 deletions

View file

@ -172,7 +172,9 @@ PointState Media::pointState(QPoint point) const {
: PointState::Outside; : PointState::Outside;
} }
std::unique_ptr<Lottie::SinglePlayer> Media::stickerTakeLottie() { std::unique_ptr<Lottie::SinglePlayer> Media::stickerTakeLottie(
not_null<DocumentData*> data,
const Lottie::ColorReplacements *replacements) {
return nullptr; return nullptr;
} }

View file

@ -26,6 +26,7 @@ using SharedMediaTypesMask = base::enum_mask<SharedMediaType>;
namespace Lottie { namespace Lottie {
class SinglePlayer; class SinglePlayer;
struct ColorReplacements;
} // namespace Lottie } // namespace Lottie
namespace HistoryView { namespace HistoryView {
@ -145,7 +146,9 @@ public:
} }
virtual void stickerClearLoopPlayed() { virtual void stickerClearLoopPlayed() {
} }
virtual std::unique_ptr<Lottie::SinglePlayer> stickerTakeLottie(); virtual std::unique_ptr<Lottie::SinglePlayer> stickerTakeLottie(
not_null<DocumentData*> data,
const Lottie::ColorReplacements *replacements);
virtual void checkAnimation() { virtual void checkAnimation() {
} }

View file

@ -26,7 +26,9 @@ constexpr auto kMaxForwardedBarLines = 4;
} // namespace } // namespace
auto UnwrappedMedia::Content::stickerTakeLottie() auto UnwrappedMedia::Content::stickerTakeLottie(
not_null<DocumentData*> data,
const Lottie::ColorReplacements *replacements)
-> std::unique_ptr<Lottie::SinglePlayer> { -> std::unique_ptr<Lottie::SinglePlayer> {
return nullptr; return nullptr;
} }
@ -383,8 +385,10 @@ TextState UnwrappedMedia::textState(QPoint point, StateRequest request) const {
return result; return result;
} }
std::unique_ptr<Lottie::SinglePlayer> UnwrappedMedia::stickerTakeLottie() { std::unique_ptr<Lottie::SinglePlayer> UnwrappedMedia::stickerTakeLottie(
return _content->stickerTakeLottie(); not_null<DocumentData*> data,
const Lottie::ColorReplacements *replacements) {
return _content->stickerTakeLottie(data, replacements);
} }
int UnwrappedMedia::calculateFullRight(const QRect &inner) const { int UnwrappedMedia::calculateFullRight(const QRect &inner) const {

View file

@ -34,7 +34,9 @@ public:
} }
virtual void stickerClearLoopPlayed() { virtual void stickerClearLoopPlayed() {
} }
virtual std::unique_ptr<Lottie::SinglePlayer> stickerTakeLottie(); virtual std::unique_ptr<Lottie::SinglePlayer> stickerTakeLottie(
not_null<DocumentData*> data,
const Lottie::ColorReplacements *replacements);
virtual bool hasHeavyPart() const { virtual bool hasHeavyPart() const {
return false; return false;
} }
@ -85,7 +87,9 @@ public:
void stickerClearLoopPlayed() override { void stickerClearLoopPlayed() override {
_content->stickerClearLoopPlayed(); _content->stickerClearLoopPlayed();
} }
std::unique_ptr<Lottie::SinglePlayer> stickerTakeLottie() override; std::unique_ptr<Lottie::SinglePlayer> stickerTakeLottie(
not_null<DocumentData*> data,
const Lottie::ColorReplacements *replacements) override;
bool hasHeavyPart() const override { bool hasHeavyPart() const override {
return _content->hasHeavyPart(); return _content->hasHeavyPart();

View file

@ -71,7 +71,7 @@ Sticker::Sticker(
_data->loadThumbnail(parent->data()->fullId()); _data->loadThumbnail(parent->data()->fullId());
} }
if (const auto media = replacing ? replacing->media() : nullptr) { if (const auto media = replacing ? replacing->media() : nullptr) {
_lottie = media->stickerTakeLottie(); _lottie = media->stickerTakeLottie(_data, _replacements);
if (_lottie) { if (_lottie) {
lottieCreated(); lottieCreated();
} }
@ -341,8 +341,12 @@ void Sticker::unloadLottie() {
_parent->checkHeavyPart(); _parent->checkHeavyPart();
} }
std::unique_ptr< Lottie::SinglePlayer> Sticker::stickerTakeLottie() { std::unique_ptr<Lottie::SinglePlayer> Sticker::stickerTakeLottie(
return std::move(_lottie); not_null<DocumentData*> data,
const Lottie::ColorReplacements *replacements) {
return (data == _data && replacements == _replacements)
? std::move(_lottie)
: nullptr;
} }
} // namespace HistoryView } // namespace HistoryView

View file

@ -50,7 +50,9 @@ public:
void stickerClearLoopPlayed() override { void stickerClearLoopPlayed() override {
_lottieOncePlayed = false; _lottieOncePlayed = false;
} }
std::unique_ptr<Lottie::SinglePlayer> stickerTakeLottie() override; std::unique_ptr<Lottie::SinglePlayer> stickerTakeLottie(
not_null<DocumentData*> data,
const Lottie::ColorReplacements *replacements) override;
bool hasHeavyPart() const override; bool hasHeavyPart() const override;
void unloadHeavyPart() override; void unloadHeavyPart() override;