calls_group_viewport_tile.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 "calls/group/calls_group_viewport.h"
  9. #include "calls/group/calls_group_call.h"
  10. #include "ui/effects/animations.h"
  11. class Painter;
  12. class QOpenGLFunctions;
  13. namespace Ui {
  14. class CrossLineAnimation;
  15. class RoundRect;
  16. } // namespace Ui
  17. namespace Calls::Group {
  18. class Viewport::VideoTile final {
  19. public:
  20. VideoTile(
  21. const VideoEndpoint &endpoint,
  22. VideoTileTrack track,
  23. rpl::producer<QSize> trackSize,
  24. rpl::producer<bool> pinned,
  25. Fn<void()> update,
  26. bool self);
  27. [[nodiscard]] not_null<Webrtc::VideoTrack*> track() const {
  28. return _track.track;
  29. }
  30. [[nodiscard]] not_null<MembersRow*> row() const {
  31. return _track.row;
  32. }
  33. [[nodiscard]] bool rtmp() const {
  34. return _rtmp;
  35. }
  36. [[nodiscard]] QRect geometry() const {
  37. return _geometry;
  38. }
  39. [[nodiscard]] TileAnimation animation() const {
  40. return _animation;
  41. }
  42. [[nodiscard]] bool pinned() const {
  43. return _pinned;
  44. }
  45. [[nodiscard]] bool hidden() const {
  46. return _hidden;
  47. }
  48. [[nodiscard]] bool visible() const {
  49. return !_hidden && !_geometry.isEmpty();
  50. }
  51. [[nodiscard]] bool self() const {
  52. return _self;
  53. }
  54. [[nodiscard]] bool mirror() const;
  55. [[nodiscard]] QRect pinOuter() const;
  56. [[nodiscard]] QRect pinInner() const;
  57. [[nodiscard]] QRect backOuter() const;
  58. [[nodiscard]] QRect backInner() const;
  59. [[nodiscard]] const VideoEndpoint &endpoint() const {
  60. return _endpoint;
  61. }
  62. [[nodiscard]] QSize trackSize() const {
  63. return _trackSize.current();
  64. }
  65. [[nodiscard]] rpl::producer<QSize> trackSizeValue() const {
  66. return _trackSize.value();
  67. }
  68. [[nodiscard]] QSize trackOrUserpicSize() const;
  69. [[nodiscard]] static QSize PausedVideoSize();
  70. [[nodiscard]] bool screencast() const;
  71. void setGeometry(
  72. QRect geometry,
  73. TileAnimation animation = TileAnimation());
  74. void hide();
  75. void toggleTopControlsShown(bool shown);
  76. bool updateRequestedQuality(VideoQuality quality);
  77. [[nodiscard]] rpl::lifetime &lifetime() {
  78. return _lifetime;
  79. }
  80. [[nodiscard]] static QSize PinInnerSize(bool pinned);
  81. static void PaintPinButton(
  82. Painter &p,
  83. bool pinned,
  84. int x,
  85. int y,
  86. int outerWidth,
  87. not_null<Ui::RoundRect*> background,
  88. not_null<Ui::CrossLineAnimation*> icon);
  89. [[nodiscard]] static QSize BackInnerSize();
  90. static void PaintBackButton(
  91. Painter &p,
  92. int x,
  93. int y,
  94. int outerWidth,
  95. not_null<Ui::RoundRect*> background);
  96. private:
  97. void setup(rpl::producer<bool> pinned);
  98. [[nodiscard]] int topControlsSlide() const;
  99. void updateTopControlsSize();
  100. void updateTopControlsPosition();
  101. const VideoEndpoint _endpoint;
  102. const Fn<void()> _update;
  103. VideoTileTrack _track;
  104. QRect _geometry;
  105. TileAnimation _animation;
  106. rpl::variable<QSize> _trackSize;
  107. QRect _pinOuter;
  108. QRect _pinInner;
  109. QRect _backOuter;
  110. QRect _backInner;
  111. Ui::Animations::Simple _topControlsShownAnimation;
  112. bool _wasPaused = false;
  113. bool _topControlsShown = false;
  114. bool _pinned = false;
  115. bool _hidden = true;
  116. bool _rtmp = false;
  117. bool _self = false;
  118. std::optional<VideoQuality> _quality;
  119. rpl::lifetime _lifetime;
  120. };
  121. } // namespace Calls::Group