media_view_overlay_widget.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  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 "base/timer.h"
  9. #include "ui/rp_widget.h"
  10. #include "ui/gl/gl_surface.h"
  11. #include "ui/effects/animations.h"
  12. #include "ui/effects/radial_animation.h"
  13. #include "data/data_shared_media.h"
  14. #include "data/data_user_photos.h"
  15. #include "data/data_web_page.h"
  16. #include "data/data_cloud_themes.h" // Data::CloudTheme.
  17. #include "media/stories/media_stories_delegate.h"
  18. #include "media/view/media_view_playback_controls.h"
  19. #include "media/view/media_view_open_common.h"
  20. #include "media/media_common.h"
  21. class History;
  22. namespace anim {
  23. enum class activation : uchar;
  24. } // namespace anim
  25. namespace Data {
  26. class PhotoMedia;
  27. class DocumentMedia;
  28. struct StoriesContext;
  29. } // namespace Data
  30. namespace Ui {
  31. class DropdownMenu;
  32. class PopupMenu;
  33. class LinkButton;
  34. class RoundButton;
  35. class RpWindow;
  36. class LayerManager;
  37. } // namespace Ui
  38. namespace Ui::GL {
  39. class Window;
  40. struct ChosenRenderer;
  41. enum class Backend;
  42. } // namespace Ui::GL
  43. namespace Ui::Menu {
  44. struct MenuCallback;
  45. } // namespace Ui::Menu
  46. namespace Platform {
  47. class OverlayWidgetHelper;
  48. } // namespace Platform
  49. namespace Window::Theme {
  50. struct Preview;
  51. } // namespace Window::Theme
  52. namespace Media::Player {
  53. struct TrackState;
  54. } // namespace Media::Player
  55. namespace Media::Streaming {
  56. struct Information;
  57. struct Update;
  58. struct FrameWithInfo;
  59. enum class Error;
  60. } // namespace Media::Streaming
  61. namespace Media::Stories {
  62. class View;
  63. struct ContentLayout;
  64. } // namespace Media::Stories
  65. namespace Media::View {
  66. class GroupThumbs;
  67. class Pip;
  68. class OverlayWidget final
  69. : public ClickHandlerHost
  70. , private PlaybackControls::Delegate
  71. , private Stories::Delegate {
  72. public:
  73. OverlayWidget();
  74. ~OverlayWidget();
  75. enum class TouchBarItemType {
  76. Photo,
  77. Video,
  78. None,
  79. };
  80. [[nodiscard]] bool isActive() const;
  81. [[nodiscard]] bool isHidden() const;
  82. [[nodiscard]] bool isMinimized() const;
  83. [[nodiscard]] bool isFullScreen() const;
  84. [[nodiscard]] not_null<QWidget*> widget() const;
  85. void hide();
  86. void setCursor(style::cursor cursor);
  87. void setFocus();
  88. [[nodiscard]] bool takeFocusFrom(not_null<QWidget*> window) const;
  89. void activate();
  90. void show(OpenRequest request);
  91. //void leaveToChildEvent(QEvent *e, QWidget *child) override {
  92. // // e -- from enterEvent() of child TWidget
  93. // updateOverState(Over::None);
  94. //}
  95. //void enterFromChildEvent(QEvent *e, QWidget *child) override {
  96. // // e -- from leaveEvent() of child TWidget
  97. // updateOver(mapFromGlobal(QCursor::pos()));
  98. //}
  99. void activateControls();
  100. void close();
  101. void minimize();
  102. void toggleFullScreen();
  103. void toggleFullScreen(bool fullscreen);
  104. void notifyFileDialogShown(bool shown);
  105. void clearSession();
  106. // ClickHandlerHost interface
  107. void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
  108. void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
  109. rpl::lifetime &lifetime();
  110. private:
  111. class Show;
  112. struct Streamed;
  113. struct PipWrap;
  114. struct ItemContext;
  115. struct StoriesContext;
  116. class Renderer;
  117. class RendererSW;
  118. class RendererGL;
  119. class SponsoredButton;
  120. // If changing, see paintControls()!
  121. enum class Over {
  122. None,
  123. Left,
  124. Right,
  125. LeftStories,
  126. RightStories,
  127. SponsoredButton,
  128. Header,
  129. Name,
  130. Date,
  131. Save,
  132. Share,
  133. Rotate,
  134. More,
  135. Icon,
  136. Video,
  137. Caption,
  138. };
  139. struct Entity {
  140. std::variant<
  141. v::null_t,
  142. not_null<PhotoData*>,
  143. not_null<DocumentData*>> data;
  144. HistoryItem *item = nullptr;
  145. MsgId topicRootId = 0;
  146. };
  147. enum class SavePhotoVideo {
  148. None,
  149. QuickSave,
  150. SaveAs,
  151. };
  152. struct ContentGeometry {
  153. QRectF rect;
  154. qreal rotation = 0.;
  155. qreal controlsOpacity = 0.;
  156. // Stories.
  157. qreal fade = 0.;
  158. qreal scale = 1.;
  159. int bottomShadowSkip = 0;
  160. int roundRadius = 0;
  161. bool topShadowShown = false;
  162. };
  163. struct StartStreaming {
  164. StartStreaming() : continueStreaming(false), startTime(0) {
  165. }
  166. StartStreaming(bool continueStreaming, crl::time startTime)
  167. : continueStreaming(continueStreaming)
  168. , startTime(startTime) {
  169. }
  170. const bool continueStreaming = false;
  171. const crl::time startTime = 0;
  172. };
  173. [[nodiscard]] not_null<QWindow*> window() const;
  174. [[nodiscard]] int width() const;
  175. [[nodiscard]] int height() const;
  176. void update();
  177. void update(const QRegion &region);
  178. [[nodiscard]] Ui::GL::ChosenRenderer chooseRenderer(
  179. Ui::GL::Backend backend);
  180. void paint(not_null<Renderer*> renderer);
  181. void setupWindow();
  182. void orderWidgets();
  183. void showAndActivate();
  184. void handleMousePress(QPoint position, Qt::MouseButton button);
  185. void handleMouseRelease(QPoint position, Qt::MouseButton button);
  186. void handleMouseMove(QPoint position);
  187. bool handleContextMenu(std::optional<QPoint> position);
  188. bool handleDoubleClick(QPoint position, Qt::MouseButton button);
  189. bool handleTouchEvent(not_null<QTouchEvent*> e);
  190. void handleWheelEvent(not_null<QWheelEvent*> e);
  191. void handleKeyPress(not_null<QKeyEvent*> e);
  192. void toggleApplicationEventFilter(bool install);
  193. bool filterApplicationEvent(
  194. not_null<QObject*> object,
  195. not_null<QEvent*> e);
  196. void setSession(not_null<Main::Session*> session);
  197. void playbackControlsPlay() override;
  198. void playbackControlsPause() override;
  199. void playbackControlsSeekProgress(crl::time position) override;
  200. void playbackControlsSeekFinished(crl::time position) override;
  201. void playbackControlsVolumeChanged(float64 volume) override;
  202. float64 playbackControlsCurrentVolume() override;
  203. void playbackControlsVolumeToggled() override;
  204. void playbackControlsVolumeChangeFinished() override;
  205. void playbackControlsSpeedChanged(float64 speed) override;
  206. float64 playbackControlsCurrentSpeed(bool lastNonDefault) override;
  207. std::vector<int> playbackControlsQualities() override;
  208. VideoQuality playbackControlsCurrentQuality() override;
  209. void playbackControlsQualityChanged(int quality) override;
  210. void playbackControlsToFullScreen() override;
  211. void playbackControlsFromFullScreen() override;
  212. void playbackControlsToPictureInPicture() override;
  213. void playbackControlsRotate() override;
  214. void playbackPauseResume();
  215. void playbackToggleFullScreen();
  216. void playbackPauseOnCall();
  217. void playbackResumeOnCall();
  218. void playbackPauseMusic();
  219. void switchToPip();
  220. [[nodiscard]] int topNotchSkip() const;
  221. [[nodiscard]] std::shared_ptr<ChatHelpers::Show> uiShow();
  222. not_null<Ui::RpWidget*> storiesWrap() override;
  223. std::shared_ptr<ChatHelpers::Show> storiesShow() override;
  224. auto storiesStickerOrEmojiChosen()
  225. -> rpl::producer<ChatHelpers::FileChosen> override;
  226. void storiesRedisplay(not_null<Data::Story*> story) override;
  227. void storiesJumpTo(
  228. not_null<Main::Session*> session,
  229. FullStoryId id,
  230. Data::StoriesContext context) override;
  231. void storiesClose() override;
  232. bool storiesPaused() override;
  233. rpl::producer<bool> storiesLayerShown() override;
  234. void storiesTogglePaused(bool paused) override;
  235. float64 storiesSiblingOver(Stories::SiblingType type) override;
  236. void storiesRepaint() override;
  237. void storiesVolumeToggle() override;
  238. void storiesVolumeChanged(float64 volume) override;
  239. void storiesVolumeChangeFinished() override;
  240. int storiesTopNotchSkip() override;
  241. void hideControls(bool force = false);
  242. void subscribeToScreenGeometry();
  243. void toMessage();
  244. void saveAs();
  245. void downloadMedia();
  246. void saveCancel();
  247. void showInFolder();
  248. void forwardMedia();
  249. void deleteMedia();
  250. void showMediaOverview();
  251. void copyMedia();
  252. void receiveMouse();
  253. void showAttachedStickers();
  254. void showDropdown();
  255. void handleTouchTimer();
  256. void handleDocumentClick();
  257. [[nodiscard]] bool canShareAtTime() const;
  258. [[nodiscard]] TimeId shareAtVideoTimestamp() const;
  259. void shareAtTime();
  260. void showSaveMsgToast(const QString &path, auto phrase);
  261. void showSaveMsgToastWith(
  262. const QString &path,
  263. const TextWithEntities &text);
  264. void updateSaveMsg();
  265. void clearBeforeHide();
  266. void clearAfterHide();
  267. void assignMediaPointer(DocumentData *document);
  268. void assignMediaPointer(not_null<PhotoData*> photo);
  269. void updateOver(QPoint mpos);
  270. void initFullScreen();
  271. void initNormalGeometry();
  272. void savePosition();
  273. void moveToScreen(bool inMove = false);
  274. void updateGeometry(bool inMove = false);
  275. void updateGeometryToScreen(bool inMove = false);
  276. bool moveToNext(int delta);
  277. void preloadData(int delta);
  278. void handleScreenChanged(not_null<QScreen*> screen);
  279. [[nodiscard]] bool computeSaveButtonVisible() const;
  280. void checkForSaveLoaded();
  281. void showPremiumDownloadPromo();
  282. [[nodiscard]] Entity entityForUserPhotos(int index) const;
  283. [[nodiscard]] Entity entityForSharedMedia(int index) const;
  284. [[nodiscard]] Entity entityForCollage(int index) const;
  285. [[nodiscard]] Entity entityByIndex(int index) const;
  286. [[nodiscard]] Entity entityForItemId(const FullMsgId &itemId) const;
  287. bool moveToEntity(const Entity &entity, int preloadDelta = 0);
  288. void setContext(std::variant<
  289. v::null_t,
  290. ItemContext,
  291. not_null<PeerData*>,
  292. StoriesContext> context);
  293. void setStoriesPeer(PeerData *peer);
  294. void refreshLang();
  295. void showSaveMsgFile();
  296. struct SharedMedia;
  297. using SharedMediaType = SharedMediaWithLastSlice::Type;
  298. using SharedMediaKey = SharedMediaWithLastSlice::Key;
  299. [[nodiscard]] std::optional<SharedMediaType> sharedMediaType() const;
  300. [[nodiscard]] std::optional<SharedMediaKey> sharedMediaKey() const;
  301. [[nodiscard]] std::optional<SharedMediaType> computeOverviewType() const;
  302. bool validSharedMedia() const;
  303. void validateSharedMedia();
  304. void handleSharedMediaUpdate(SharedMediaWithLastSlice &&update);
  305. struct UserPhotos;
  306. using UserPhotosKey = UserPhotosSlice::Key;
  307. [[nodiscard]] std::optional<UserPhotosKey> userPhotosKey() const;
  308. bool validUserPhotos() const;
  309. void validateUserPhotos();
  310. void handleUserPhotosUpdate(UserPhotosSlice &&update);
  311. struct Collage;
  312. using CollageKey = WebPageCollage::Item;
  313. [[nodiscard]] std::optional<CollageKey> collageKey() const;
  314. bool validCollage() const;
  315. void validateCollage();
  316. [[nodiscard]] Data::FileOrigin fileOrigin() const;
  317. [[nodiscard]] Data::FileOrigin fileOrigin(const Entity& entity) const;
  318. void refreshFromLabel();
  319. void refreshCaption();
  320. void refreshMediaViewer();
  321. void refreshNavVisibility();
  322. void refreshGroupThumbs();
  323. void dropdownHidden();
  324. void updateDocSize();
  325. void updateControls();
  326. void updateControlsGeometry();
  327. void updateNavigationControlsGeometry();
  328. void fillContextMenuActions(const Ui::Menu::MenuCallback &addAction);
  329. void resizeCenteredControls();
  330. void resizeContentByScreenSize();
  331. void recountSkipTop();
  332. void displayPhoto(
  333. not_null<PhotoData*> photo,
  334. anim::activation activation = anim::activation::normal);
  335. void displayDocument(
  336. DocumentData *document,
  337. anim::activation activation = anim::activation::normal,
  338. const Data::CloudTheme &cloud = Data::CloudTheme(),
  339. const StartStreaming &startStreaming = StartStreaming());
  340. void displayFinished(anim::activation activation);
  341. void redisplayContent();
  342. void findCurrent();
  343. void updateCursor();
  344. void setZoomLevel(int newZoom, bool force = false);
  345. void updatePlaybackState();
  346. void seekRelativeTime(crl::time time);
  347. void restartAtProgress(float64 progress);
  348. void restartAtSeekPosition(crl::time position);
  349. void refreshClipControllerGeometry();
  350. void refreshCaptionGeometry();
  351. bool initStreaming(
  352. const StartStreaming &startStreaming = StartStreaming());
  353. void startStreamingPlayer(const StartStreaming &startStreaming);
  354. void initStreamingThumbnail();
  355. void streamingReady(Streaming::Information &&info);
  356. [[nodiscard]] bool createStreamingObjects();
  357. void handleStreamingUpdate(Streaming::Update &&update);
  358. void handleStreamingError(Streaming::Error &&error);
  359. void updatePowerSaveBlocker(const Player::TrackState &state);
  360. void initThemePreview();
  361. void destroyThemePreview();
  362. void updateThemePreviewGeometry();
  363. void initSponsoredButton();
  364. void refreshSponsoredButtonGeometry();
  365. void refreshSponsoredButtonWidth();
  366. void documentUpdated(not_null<DocumentData*> document);
  367. void changingMsgId(FullMsgId newId, MsgId oldId);
  368. [[nodiscard]] int finalContentRotation() const;
  369. [[nodiscard]] QRect finalContentRect() const;
  370. [[nodiscard]] ContentGeometry contentGeometry() const;
  371. [[nodiscard]] ContentGeometry storiesContentGeometry(
  372. const Stories::ContentLayout &layout,
  373. float64 scale = 1.) const;
  374. void updateContentRect();
  375. void contentSizeChanged();
  376. // Radial animation interface.
  377. [[nodiscard]] float64 radialProgress() const;
  378. [[nodiscard]] bool radialLoading() const;
  379. [[nodiscard]] QRect radialRect() const;
  380. void radialStart();
  381. [[nodiscard]] crl::time radialTimeShift() const;
  382. void updateHeader();
  383. void snapXY();
  384. void clearControlsState();
  385. bool stateAnimationCallback(crl::time ms);
  386. bool radialAnimationCallback(crl::time now);
  387. void waitingAnimationCallback();
  388. bool updateControlsAnimation(crl::time now);
  389. void zoomIn();
  390. void zoomOut();
  391. void zoomReset();
  392. void zoomUpdate(int32 &newZoom);
  393. void paintRadialLoading(not_null<Renderer*> renderer);
  394. void paintRadialLoadingContent(
  395. Painter &p,
  396. QRect inner,
  397. bool radial,
  398. float64 radialOpacity) const;
  399. void paintThemePreviewContent(Painter &p, QRect outer, QRect clip);
  400. void paintDocumentBubbleContent(
  401. Painter &p,
  402. QRect outer,
  403. QRect icon,
  404. QRect clip) const;
  405. void paintSaveMsgContent(Painter &p, QRect outer, QRect clip);
  406. void paintControls(not_null<Renderer*> renderer, float64 opacity);
  407. void paintFooterContent(
  408. Painter &p,
  409. QRect outer,
  410. QRect clip,
  411. float64 opacity);
  412. [[nodiscard]] QRect footerGeometry() const;
  413. void paintCaptionContent(
  414. Painter &p,
  415. QRect outer,
  416. QRect clip,
  417. float64 opacity);
  418. [[nodiscard]] QRect captionGeometry() const;
  419. void paintGroupThumbsContent(
  420. Painter &p,
  421. QRect outer,
  422. QRect clip,
  423. float64 opacity);
  424. [[nodiscard]] float64 controlOpacity(
  425. float64 progress,
  426. bool nonbright = false) const;
  427. [[nodiscard]] bool isSaveMsgShown() const;
  428. void updateOverRect(Over state);
  429. bool updateOverState(Over newState);
  430. float64 overLevel(Over control) const;
  431. void checkGroupThumbsAnimation();
  432. void initGroupThumbs();
  433. void validatePhotoImage(Image *image, bool blurred);
  434. void validatePhotoCurrentImage();
  435. [[nodiscard]] bool hasCopyMediaRestriction(
  436. bool skipPremiumCheck = false) const;
  437. [[nodiscard]] bool showCopyMediaRestriction(
  438. bool skipPRemiumCheck = false);
  439. [[nodiscard]] QSize flipSizeByRotation(QSize size) const;
  440. void applyVideoSize();
  441. [[nodiscard]] bool videoShown() const;
  442. [[nodiscard]] QSize videoSize() const;
  443. [[nodiscard]] bool streamingRequiresControls() const;
  444. [[nodiscard]] QImage videoFrame() const; // ARGB (changes prepare format)
  445. [[nodiscard]] QImage currentVideoFrameImage() const; // RGB (may convert)
  446. [[nodiscard]] Streaming::FrameWithInfo videoFrameWithInfo() const; // YUV
  447. [[nodiscard]] int streamedIndex() const;
  448. [[nodiscard]] QImage transformedShownContent() const;
  449. [[nodiscard]] QImage transformShownContent(
  450. QImage content,
  451. int rotation) const;
  452. [[nodiscard]] bool documentContentShown() const;
  453. [[nodiscard]] bool documentBubbleShown() const;
  454. void setStaticContent(QImage image);
  455. [[nodiscard]] bool contentShown() const;
  456. [[nodiscard]] bool opaqueContentShown() const;
  457. void clearStreaming(bool savePosition = true);
  458. [[nodiscard]] bool canInitStreaming() const;
  459. [[nodiscard]] bool saveControlLocked() const;
  460. void applyVideoQuality(VideoQuality value);
  461. [[nodiscard]] bool topShadowOnTheRight() const;
  462. void applyHideWindowWorkaround();
  463. [[nodiscard]] ClickHandlerPtr ensureCaptionExpandLink();
  464. Window::SessionController *findWindow(bool switchTo = true) const;
  465. bool _opengl = false;
  466. const std::unique_ptr<Ui::GL::Window> _wrap;
  467. const not_null<Ui::RpWindow*> _window;
  468. const std::unique_ptr<Platform::OverlayWidgetHelper> _helper;
  469. const not_null<Ui::RpWidget*> _body;
  470. const std::unique_ptr<Ui::RpWidget> _titleBugWorkaround;
  471. const std::unique_ptr<Ui::RpWidgetWrap> _surface;
  472. const not_null<QWidget*> _widget;
  473. QRect _normalGeometry;
  474. bool _wasWindowedMode = false;
  475. bool _fullscreenInited = false;
  476. bool _normalGeometryInited = false;
  477. bool _fullscreen = true;
  478. bool _windowed = false;
  479. base::weak_ptr<Window::Controller> _openedFrom;
  480. Main::Session *_session = nullptr;
  481. rpl::lifetime _sessionLifetime;
  482. PhotoData *_photo = nullptr;
  483. DocumentData *_document = nullptr;
  484. DocumentData *_chosenQuality = nullptr;
  485. PhotoData *_videoCover = nullptr;
  486. Media::VideoQuality _quality;
  487. QString _documentLoadingTo;
  488. std::shared_ptr<Data::PhotoMedia> _photoMedia;
  489. std::shared_ptr<Data::DocumentMedia> _documentMedia;
  490. std::shared_ptr<Data::PhotoMedia> _videoCoverMedia;
  491. base::flat_set<std::shared_ptr<Data::PhotoMedia>> _preloadPhotos;
  492. base::flat_set<std::shared_ptr<Data::DocumentMedia>> _preloadDocuments;
  493. int _rotation = 0;
  494. std::unique_ptr<SharedMedia> _sharedMedia;
  495. std::optional<SharedMediaWithLastSlice> _sharedMediaData;
  496. std::optional<SharedMediaWithLastSlice::Key> _sharedMediaDataKey;
  497. std::unique_ptr<UserPhotos> _userPhotos;
  498. std::optional<UserPhotosSlice> _userPhotosData;
  499. std::unique_ptr<Collage> _collage;
  500. std::optional<WebPageCollage> _collageData;
  501. QRect _leftNav, _leftNavOver, _leftNavIcon;
  502. QRect _rightNav, _rightNavOver, _rightNavIcon;
  503. QRect _headerNav, _nameNav, _dateNav;
  504. QRect _rotateNav, _rotateNavOver, _rotateNavIcon;
  505. QRect _shareNav, _shareNavOver, _shareNavIcon;
  506. QRect _saveNav, _saveNavOver, _saveNavIcon;
  507. QRect _moreNav, _moreNavOver, _moreNavIcon;
  508. bool _leftNavVisible = false;
  509. bool _rightNavVisible = false;
  510. bool _saveVisible = false;
  511. bool _shareVisible = false;
  512. bool _rotateVisible = false;
  513. bool _headerHasLink = false;
  514. QString _dateText;
  515. QString _headerText;
  516. bool _streamingStartPaused = false;
  517. bool _fullScreenVideo = false;
  518. int _fullScreenZoomCache = 0;
  519. float64 _lastPositiveVolume = 1.;
  520. std::unique_ptr<GroupThumbs> _groupThumbs;
  521. QRect _groupThumbsRect;
  522. int _groupThumbsAvailableWidth = 0;
  523. int _groupThumbsLeft = 0;
  524. int _groupThumbsTop = 0;
  525. Ui::Text::String _caption;
  526. QRect _captionRect;
  527. ClickHandlerPtr _captionExpandLink;
  528. int _captionShowMoreWidth = 0;
  529. int _captionSkipBlockWidth = 0;
  530. int _topNotchSize = 0;
  531. int _width = 0;
  532. int _height = 0;
  533. int _skipTop = 0;
  534. int _availableHeight = 0;
  535. int _minUsedTop = 0; // Geometry without top notch on macOS.
  536. int _maxUsedHeight = 0;
  537. int _x = 0, _y = 0, _w = 0, _h = 0;
  538. int _xStart = 0, _yStart = 0;
  539. int _zoom = 0; // < 0 - out, 0 - none, > 0 - in
  540. float64 _zoomToScreen = 0.; // for documents
  541. float64 _zoomToDefault = 0.;
  542. QPoint _mStart;
  543. bool _pressed = false;
  544. bool _cursorOverriden = false;
  545. int32 _dragging = 0;
  546. QImage _staticContent;
  547. bool _staticContentTransparent = false;
  548. bool _blurred = true;
  549. bool _reShow = false;
  550. ContentGeometry _oldGeometry;
  551. Ui::Animations::Simple _geometryAnimation;
  552. rpl::lifetime _screenGeometryLifetime;
  553. std::unique_ptr<QObject> _applicationEventFilter;
  554. std::unique_ptr<Streamed> _streamed;
  555. std::unique_ptr<PipWrap> _pip;
  556. QImage _streamedQualityChangeFrame;
  557. crl::time _streamedPosition = 0;
  558. int _streamedCreated = 0;
  559. bool _streamedQualityChangeFinished = false;
  560. bool _showAsPip = false;
  561. Qt::Orientations _flip;
  562. std::unique_ptr<Stories::View> _stories;
  563. std::shared_ptr<Show> _cachedShow;
  564. rpl::event_stream<> _storiesChanged;
  565. Main::Session *_storiesSession = nullptr;
  566. rpl::event_stream<ChatHelpers::FileChosen> _storiesStickerOrEmojiChosen;
  567. std::unique_ptr<Ui::LayerManager> _layerBg;
  568. const style::icon *_docIcon = nullptr;
  569. style::color _docIconColor;
  570. QString _docName, _docSize, _docExt;
  571. int _docNameWidth = 0, _docSizeWidth = 0, _docExtWidth = 0;
  572. QRect _docRect, _docIconRect;
  573. QImage _docRectImage;
  574. int _docThumbx = 0, _docThumby = 0, _docThumbw = 0;
  575. object_ptr<Ui::LinkButton> _docDownload;
  576. object_ptr<Ui::LinkButton> _docSaveAs;
  577. object_ptr<Ui::LinkButton> _docCancel;
  578. QRect _bottomShadowRect;
  579. QRect _topShadowRect;
  580. rpl::variable<bool> _topShadowRight = false;
  581. QRect _photoRadialRect;
  582. Ui::RadialAnimation _radial;
  583. History *_migrated = nullptr;
  584. History *_history = nullptr; // if conversation photos or files overview
  585. MsgId _topicRootId = 0;
  586. PeerData *_peer = nullptr;
  587. UserData *_user = nullptr; // if user profile photos overview
  588. // We save the information about the reason of the current mediaview show:
  589. // did we open a peer profile photo or a photo from some message.
  590. // We use it when trying to delete a photo: if we've opened a peer photo,
  591. // then we'll delete group photo instead of the corresponding message.
  592. bool _firstOpenedPeerPhoto = false;
  593. PeerData *_from = nullptr;
  594. QString _fromName;
  595. Ui::Text::String _fromNameLabel;
  596. std::optional<int> _index; // Index in current _sharedMedia data.
  597. std::optional<int> _fullIndex; // Index in full shared media.
  598. std::optional<int> _fullCount;
  599. HistoryItem *_message = nullptr;
  600. mtpRequestId _loadRequest = 0;
  601. Over _over = Over::None;
  602. Over _down = Over::None;
  603. QPoint _lastAction, _lastMouseMovePos;
  604. bool _ignoringDropdown = false;
  605. Ui::Animations::Basic _stateAnimation;
  606. enum ControlsState {
  607. ControlsShowing,
  608. ControlsShown,
  609. ControlsHiding,
  610. ControlsHidden,
  611. };
  612. ControlsState _controlsState = ControlsShown;
  613. crl::time _controlsAnimStarted = 0;
  614. base::Timer _controlsHideTimer;
  615. anim::value _controlsOpacity = { 1. };
  616. bool _mousePressed = false;
  617. base::unique_qptr<Ui::PopupMenu> _menu;
  618. object_ptr<Ui::DropdownMenu> _dropdown;
  619. base::Timer _dropdownShowTimer;
  620. base::unique_qptr<SponsoredButton> _sponsoredButton;
  621. bool _receiveMouse = true;
  622. bool _processingKeyPress = false;
  623. bool _touchPress = false;
  624. bool _touchMove = false;
  625. bool _touchRightButton = false;
  626. base::Timer _touchTimer;
  627. QPoint _touchStart;
  628. QString _saveMsgFilename;
  629. QRect _saveMsg;
  630. Ui::Text::String _saveMsgText;
  631. SavePhotoVideo _savePhotoVideoWhenLoaded = SavePhotoVideo::None;
  632. // _saveMsgAnimation -> _saveMsgTimer -> _saveMsgAnimation.
  633. Ui::Animations::Simple _saveMsgAnimation;
  634. base::Timer _saveMsgTimer;
  635. base::flat_map<Over, crl::time> _animations;
  636. base::flat_map<Over, anim::value> _animationOpacities;
  637. rpl::event_stream<Media::Player::TrackState> _touchbarTrackState;
  638. rpl::event_stream<TouchBarItemType> _touchbarDisplay;
  639. rpl::event_stream<bool> _touchbarFullscreenToggled;
  640. int _verticalWheelDelta = 0;
  641. bool _themePreviewShown = false;
  642. uint64 _themePreviewId = 0;
  643. QRect _themePreviewRect;
  644. std::unique_ptr<Window::Theme::Preview> _themePreview;
  645. object_ptr<Ui::RoundButton> _themeApply = { nullptr };
  646. object_ptr<Ui::RoundButton> _themeCancel = { nullptr };
  647. object_ptr<Ui::RoundButton> _themeShare = { nullptr };
  648. Data::CloudTheme _themeCloudData;
  649. std::unique_ptr<Ui::RpWidget> _hideWorkaround;
  650. };
  651. } // namespace Media::View