/* 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 "data/data_stories.h" #include "ui/effects/animations.h" namespace base { class PowerSaveBlocker; } // namespace base namespace ChatHelpers { class Show; struct FileChosen; } // namespace ChatHelpers namespace Data { struct StoriesList; } // namespace Data namespace Ui { class RpWidget; } // namespace Ui namespace Media::Player { struct TrackState; } // namespace Media::Player namespace Media::Stories { class Header; class Slider; class ReplyArea; class Sibling; class Delegate; struct SiblingView; enum class SiblingType; struct ContentLayout; class CaptionFullView; enum class HeaderLayout { Normal, Outside, }; struct SiblingLayout { QRect geometry; QRect userpic; QRect nameBoundingRect; int nameFontSize = 0; }; struct Layout { QRect content; QRect header; QRect slider; int controlsWidth = 0; QPoint controlsBottomPosition; QRect autocompleteRect; HeaderLayout headerLayout = HeaderLayout::Normal; SiblingLayout siblingLeft; SiblingLayout siblingRight; friend inline bool operator==(Layout, Layout) = default; }; class Controller final { public: explicit Controller(not_null delegate); ~Controller(); [[nodiscard]] not_null wrap() const; [[nodiscard]] Layout layout() const; [[nodiscard]] rpl::producer layoutValue() const; [[nodiscard]] ContentLayout contentLayout() const; [[nodiscard]] TextWithEntities captionText() const; void showFullCaption(); [[nodiscard]] std::shared_ptr uiShow() const; [[nodiscard]] auto stickerOrEmojiChosen() const -> rpl::producer; void show( const std::vector &lists, int index, int subindex); void ready(); void updateVideoPlayback(const Player::TrackState &state); [[nodiscard]] bool subjumpAvailable(int delta) const; [[nodiscard]] bool subjumpFor(int delta); [[nodiscard]] bool jumpFor(int delta); [[nodiscard]] bool paused() const; void togglePaused(bool paused); [[nodiscard]] bool canDownload() const; void repaintSibling(not_null sibling); [[nodiscard]] SiblingView sibling(SiblingType type) const; void unfocusReply(); [[nodiscard]] rpl::lifetime &lifetime(); private: class PhotoPlayback; void initLayout(); void updatePhotoPlayback(const Player::TrackState &state); void updatePlayback(const Player::TrackState &state); void updatePowerSaveBlocker(const Player::TrackState &state); void showSiblings( const std::vector &lists, int index); void showSibling( std::unique_ptr &sibling, const Data::StoriesList *list); const not_null _delegate; rpl::variable> _layout; const not_null _wrap; const std::unique_ptr
_header; const std::unique_ptr _slider; const std::unique_ptr _replyArea; std::unique_ptr _photoPlayback; std::unique_ptr _captionFullView; Ui::Animations::Simple _contentFadeAnimation; bool _contentFaded = false; Data::FullStoryId _shown; TextWithEntities _captionText; std::optional _list; int _index = 0; bool _started = false; std::unique_ptr _siblingLeft; std::unique_ptr _siblingRight; std::unique_ptr _powerSaveBlocker; rpl::lifetime _lifetime; }; } // namespace Media::Stories