scene_item_sticker.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "editor/scene/scene_item_base.h"
  9. #include "media/clip/media_clip_reader.h"
  10. namespace Data {
  11. class DocumentMedia;
  12. } // namespace Data
  13. namespace Lottie {
  14. class SinglePlayer;
  15. } // namespace Lottie
  16. class DocumentData;
  17. namespace Editor {
  18. class ItemSticker : public ItemBase {
  19. public:
  20. enum { Type = ItemBase::Type + 1 };
  21. ItemSticker(
  22. not_null<DocumentData*> document,
  23. ItemBase::Data data);
  24. void paint(
  25. QPainter *p,
  26. const QStyleOptionGraphicsItem *option,
  27. QWidget *widget) override;
  28. [[nodiscard]] not_null<DocumentData*> sticker() const;
  29. int type() const override;
  30. protected:
  31. void performFlip() override;
  32. std::shared_ptr<ItemBase> duplicate(ItemBase::Data data) const override;
  33. private:
  34. const not_null<DocumentData*> _document;
  35. const std::shared_ptr<::Data::DocumentMedia> _mediaView;
  36. void updatePixmap(QImage &&image);
  37. struct {
  38. std::unique_ptr<Lottie::SinglePlayer> player;
  39. rpl::lifetime lifetime;
  40. } _lottie;
  41. ::Media::Clip::ReaderPointer _webm;
  42. QImage _image;
  43. rpl::lifetime _loadingLifetime;
  44. };
  45. } // namespace Editor