tdesktop/Telegram/SourceFiles/calls/calls_video_bubble.h

71 lines
1.5 KiB
C
Raw Normal View History

/*
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"
2020-08-11 09:59:48 +00:00
namespace Webrtc {
class VideoTrack;
enum class VideoState;
2020-08-11 09:59:48 +00:00
} // namespace Webrtc
namespace Calls {
class VideoBubble final {
public:
VideoBubble(
not_null<QWidget*> parent,
2020-08-11 09:59:48 +00:00
not_null<Webrtc::VideoTrack*> track);
enum class DragMode {
None,
SnapToCorners,
};
void updateGeometry(
DragMode mode,
QRect boundingRect,
QSize sizeMin = QSize(),
QSize sizeMax = QSize());
2020-08-12 13:35:31 +00:00
[[nodiscard]] QRect geometry() const;
[[nodiscard]] rpl::lifetime &lifetime() {
return _content.lifetime();
}
void setMirrored(bool mirrored) {
_mirrored = mirrored;
}
private:
void setup();
void paint();
2020-08-11 09:59:48 +00:00
void setState(Webrtc::VideoState state);
void applyDragMode(DragMode mode);
void applyBoundingRect(QRect rect);
void applySizeConstraints(QSize min, QSize max);
void updateSizeToFrame(QSize frame);
void updateVisibility();
void setInnerSize(QSize size);
2020-08-07 14:33:34 +00:00
void prepareFrame();
Ui::RpWidget _content;
2020-08-11 09:59:48 +00:00
const not_null<Webrtc::VideoTrack*> _track;
Webrtc::VideoState _state = Webrtc::VideoState();
2020-08-07 14:33:34 +00:00
QImage _frame, _pausedFrame;
QSize _min, _max, _size, _lastDraggableSize, _lastFrameSize;
QRect _boundingRect;
DragMode _dragMode = DragMode::None;
RectPart _corner = RectPart::None;
bool _dragging = false;
bool _geometryDirty = false;
bool _mirrored = true;
};
} // namespace Calls