calls_video_bubble.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "ui/rect_part.h"
  9. #include "ui/rp_widget.h"
  10. namespace Webrtc {
  11. class VideoTrack;
  12. enum class VideoState;
  13. } // namespace Webrtc
  14. namespace Calls {
  15. class VideoBubble final {
  16. public:
  17. VideoBubble(
  18. not_null<QWidget*> parent,
  19. not_null<Webrtc::VideoTrack*> track);
  20. enum class DragMode {
  21. None,
  22. SnapToCorners,
  23. };
  24. void updateGeometry(
  25. DragMode mode,
  26. QRect boundingRect,
  27. QSize sizeMin = QSize(),
  28. QSize sizeMax = QSize());
  29. [[nodiscard]] QRect geometry() const;
  30. [[nodiscard]] rpl::lifetime &lifetime() {
  31. return _content.lifetime();
  32. }
  33. void setMirrored(bool mirrored) {
  34. _mirrored = mirrored;
  35. }
  36. private:
  37. void setup();
  38. void paint();
  39. void setState(Webrtc::VideoState state);
  40. void applyDragMode(DragMode mode);
  41. void applyBoundingRect(QRect rect);
  42. void applySizeConstraints(QSize min, QSize max);
  43. void updateSizeToFrame(QSize frame);
  44. void updateVisibility();
  45. void setInnerSize(QSize size);
  46. void prepareFrame();
  47. Ui::RpWidget _content;
  48. const not_null<Webrtc::VideoTrack*> _track;
  49. Webrtc::VideoState _state = Webrtc::VideoState();
  50. QImage _frame, _pausedFrame;
  51. QSize _min, _max, _size, _lastDraggableSize, _lastFrameSize;
  52. QRect _boundingRect;
  53. DragMode _dragMode = DragMode::None;
  54. RectPart _corner = RectPart::None;
  55. bool _dragging = false;
  56. bool _geometryDirty = false;
  57. bool _mirrored = true;
  58. };
  59. } // namespace Calls