2021-02-23 15:35:40 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2021-03-21 12:38:33 +00:00
|
|
|
#include "editor/scene/scene_item_base.h"
|
2021-02-23 15:35:40 +00:00
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
class DocumentMedia;
|
|
|
|
} // namespace Data
|
|
|
|
namespace Lottie {
|
|
|
|
class SinglePlayer;
|
|
|
|
} // namespace Lottie
|
|
|
|
class DocumentData;
|
|
|
|
|
|
|
|
namespace Editor {
|
|
|
|
|
|
|
|
class ItemSticker : public ItemBase {
|
|
|
|
public:
|
2021-03-14 09:46:17 +00:00
|
|
|
enum { Type = ItemBase::Type + 2 };
|
2021-02-23 15:35:40 +00:00
|
|
|
|
|
|
|
ItemSticker(
|
|
|
|
not_null<DocumentData*> document,
|
2021-07-04 12:57:07 +00:00
|
|
|
ItemBase::Data data);
|
2021-02-23 15:35:40 +00:00
|
|
|
void paint(
|
|
|
|
QPainter *p,
|
|
|
|
const QStyleOptionGraphicsItem *option,
|
|
|
|
QWidget *widget) override;
|
2021-03-14 09:46:17 +00:00
|
|
|
MTPInputDocument sticker() const;
|
|
|
|
int type() const override;
|
2021-03-10 17:50:35 +00:00
|
|
|
protected:
|
|
|
|
void performFlip() override;
|
2021-07-04 12:57:07 +00:00
|
|
|
std::shared_ptr<ItemBase> duplicate(ItemBase::Data data) const override;
|
2021-02-23 15:35:40 +00:00
|
|
|
private:
|
|
|
|
const not_null<DocumentData*> _document;
|
2021-07-04 12:57:07 +00:00
|
|
|
const std::shared_ptr<::Data::DocumentMedia> _mediaView;
|
2021-02-23 15:35:40 +00:00
|
|
|
|
2021-03-21 17:00:56 +00:00
|
|
|
void updatePixmap(QPixmap &&pixmap);
|
|
|
|
|
2021-02-23 15:35:40 +00:00
|
|
|
struct {
|
|
|
|
std::unique_ptr<Lottie::SinglePlayer> player;
|
|
|
|
rpl::lifetime lifetime;
|
|
|
|
} _lottie;
|
|
|
|
QPixmap _pixmap;
|
|
|
|
|
|
|
|
rpl::lifetime _loadingLifetime;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Editor
|