dialogs_video_userpic.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 "media/clip/media_clip_reader.h"
  9. class Painter;
  10. namespace Data {
  11. class PhotoMedia;
  12. } // namespace Data
  13. namespace Ui {
  14. struct PeerUserpicView;
  15. } // namespace Ui
  16. namespace Dialogs {
  17. class Entry;
  18. } // namespace Dialogs
  19. namespace Dialogs::Ui {
  20. using namespace ::Ui;
  21. struct PaintContext;
  22. class VideoUserpic final {
  23. public:
  24. VideoUserpic(not_null<PeerData*> peer, Fn<void()> repaint);
  25. ~VideoUserpic();
  26. [[nodiscard]] int frameIndex() const;
  27. void paintLeft(
  28. Painter &p,
  29. PeerUserpicView &view,
  30. int x,
  31. int y,
  32. int w,
  33. int size,
  34. bool paused);
  35. private:
  36. void clipCallback(Media::Clip::Notification notification);
  37. [[nodiscard]] Media::Clip::FrameRequest request(int size) const;
  38. bool startReady(int size = 0);
  39. const not_null<PeerData*> _peer;
  40. const Fn<void()> _repaint;
  41. Media::Clip::ReaderPointer _video;
  42. int _lastSize = 0;
  43. std::shared_ptr<Data::PhotoMedia> _videoPhotoMedia;
  44. PhotoId _videoPhotoId = 0;
  45. };
  46. void PaintUserpic(
  47. Painter &p,
  48. not_null<Entry*> entry,
  49. PeerData *peer,
  50. VideoUserpic *videoUserpic,
  51. PeerUserpicView &view,
  52. const Ui::PaintContext &context);
  53. void PaintUserpic(
  54. Painter &p,
  55. not_null<PeerData*> peer,
  56. VideoUserpic *videoUserpic,
  57. PeerUserpicView &view,
  58. int x,
  59. int y,
  60. int outerWidth,
  61. int size,
  62. bool paused);
  63. } // namespace Dialogs::Ui