1 /* 2 This file is part of Telegram Desktop, 3 the official desktop application for the Telegram messaging service. 4 5 For license and copyright information please follow this link: 6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL 7 */ 8 #pragma once 9 10 #include "calls/group/calls_group_viewport.h" 11 #include "calls/group/calls_group_call.h" 12 #include "ui/effects/animations.h" 13 14 class Painter; 15 class QOpenGLFunctions; 16 17 namespace Ui { 18 class CrossLineAnimation; 19 class RoundRect; 20 } // namespace Ui 21 22 namespace Calls::Group { 23 24 class Viewport::VideoTile final { 25 public: 26 VideoTile( 27 const VideoEndpoint &endpoint, 28 VideoTileTrack track, 29 rpl::producer<QSize> trackSize, 30 rpl::producer<bool> pinned, 31 Fn<void()> update); 32 track()33 [[nodiscard]] not_null<Webrtc::VideoTrack*> track() const { 34 return _track.track; 35 } row()36 [[nodiscard]] not_null<MembersRow*> row() const { 37 return _track.row; 38 } geometry()39 [[nodiscard]] QRect geometry() const { 40 return _geometry; 41 } animation()42 [[nodiscard]] TileAnimation animation() const { 43 return _animation; 44 } pinned()45 [[nodiscard]] bool pinned() const { 46 return _pinned; 47 } hidden()48 [[nodiscard]] bool hidden() const { 49 return _hidden; 50 } visible()51 [[nodiscard]] bool visible() const { 52 return !_hidden && !_geometry.isEmpty(); 53 } 54 [[nodiscard]] QRect pinOuter() const; 55 [[nodiscard]] QRect pinInner() const; 56 [[nodiscard]] QRect backOuter() const; 57 [[nodiscard]] QRect backInner() const; endpoint()58 [[nodiscard]] const VideoEndpoint &endpoint() const { 59 return _endpoint; 60 } trackSize()61 [[nodiscard]] QSize trackSize() const { 62 return _trackSize.current(); 63 } trackSizeValue()64 [[nodiscard]] rpl::producer<QSize> trackSizeValue() const { 65 return _trackSize.value(); 66 } 67 [[nodiscard]] QSize trackOrUserpicSize() const; 68 [[nodiscard]] static QSize PausedVideoSize(); 69 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 lifetime()78 [[nodiscard]] rpl::lifetime &lifetime() { 79 return _lifetime; 80 } 81 82 [[nodiscard]] static QSize PinInnerSize(bool pinned); 83 static void PaintPinButton( 84 Painter &p, 85 bool pinned, 86 int x, 87 int y, 88 int outerWidth, 89 not_null<Ui::RoundRect*> background, 90 not_null<Ui::CrossLineAnimation*> icon); 91 92 [[nodiscard]] static QSize BackInnerSize(); 93 static void PaintBackButton( 94 Painter &p, 95 int x, 96 int y, 97 int outerWidth, 98 not_null<Ui::RoundRect*> background); 99 100 private: 101 void setup(rpl::producer<bool> pinned); 102 [[nodiscard]] int topControlsSlide() const; 103 void updateTopControlsSize(); 104 void updateTopControlsPosition(); 105 106 const VideoEndpoint _endpoint; 107 const Fn<void()> _update; 108 109 VideoTileTrack _track; 110 QRect _geometry; 111 TileAnimation _animation; 112 rpl::variable<QSize> _trackSize; 113 QRect _pinOuter; 114 QRect _pinInner; 115 QRect _backOuter; 116 QRect _backInner; 117 Ui::Animations::Simple _topControlsShownAnimation; 118 bool _wasPaused = false; 119 bool _topControlsShown = false; 120 bool _pinned = false; 121 bool _hidden = true; 122 std::optional<VideoQuality> _quality; 123 124 rpl::lifetime _lifetime; 125 126 }; 127 128 } // namespace Calls::Group 129