/* 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 #include "ui/rp_widget.h" namespace style { struct GroupCallLargeVideo; } // namespace style namespace Ui { class AbstractButton; class RpWidgetWrap; namespace GL { struct Capabilities; struct ChosenRenderer; } // namespace GL } // namespace Ui namespace Calls { struct VideoEndpoint; struct VideoPinToggle; struct VideoQualityRequest; } // namespace Calls namespace Webrtc { class VideoTrack; } // namespace Webrtc namespace Calls::Group { class MembersRow; enum class PanelMode; enum class VideoQuality; struct LargeVideoTrack; class Viewport final { public: Viewport(QWidget *parent, PanelMode mode); ~Viewport(); [[nodiscard]] not_null widget() const; [[nodiscard]] not_null rp() const; void setMode(PanelMode mode); void setControlsShown(float64 shown); void add( const VideoEndpoint &endpoint, LargeVideoTrack track, rpl::producer pinned); void remove(const VideoEndpoint &endpoint); void showLarge(const VideoEndpoint &endpoint); [[nodiscard]] rpl::producer pinToggled() const; [[nodiscard]] rpl::producer clicks() const; [[nodiscard]] rpl::producer qualityRequests() const; [[nodiscard]] rpl::producer mouseInsideValue() const; [[nodiscard]] rpl::lifetime &lifetime(); private: struct Textures; class VideoTile; class Renderer; class RendererGL; struct Selection { enum class Element { None, Tile, PinButton, }; VideoTile *tile = nullptr; Element element = Element::None; inline bool operator==(Selection other) const { return (tile == other.tile) && (element == other.element); } }; void setup(); [[nodiscard]] bool wide() const; void updateTilesGeometry(); void setTileGeometry(not_null tile, QRect geometry); void setSelected(Selection value); void setPressed(Selection value); void handleMousePress(QPoint position, Qt::MouseButton button); void handleMouseRelease(QPoint position, Qt::MouseButton button); void handleMouseMove(QPoint position); [[nodiscard]] Ui::GL::ChosenRenderer chooseRenderer( Ui::GL::Capabilities capabilities); Fn _freeTextures; rpl::variable _mode; const std::unique_ptr _content; std::vector> _tiles; QImage _shadow; rpl::event_stream _clicks; rpl::event_stream _pinToggles; rpl::event_stream _qualityRequests; float64 _controlsShownRatio = 1.; VideoTile *_large = nullptr; Selection _selected; Selection _pressed; rpl::variable _mouseInside = false; }; [[nodiscard]] QImage GenerateShadow( int height, int topAlpha, int bottomAlpha, QColor color = QColor(0, 0, 0)); } // namespace Calls::Group