/* 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 "base/object_ptr.h" #include "info/info_controller.h" // Key #include "info/profile/info_profile_badge.h" #include "ui/rp_widget.h" #include "ui/userpic_view.h" namespace Data { class ForumTopic; class DocumentMedia; struct SavedStarGift; struct ColorProfileSet; class SavedStarGiftId; } // namespace Data namespace Info::Profile { class BadgeTooltip; class TopicIconView; } // namespace Info::Profile namespace Lottie { class Animation; class MultiPlayer; } // namespace Lottie namespace Ui { class VideoUserpicPlayer; struct OutlineSegment; namespace Text { class CustomEmoji; } // namespace Text } // namespace Ui class PeerData; namespace base { class Timer; } // namespace base namespace style { struct InfoTopBar; struct InfoPeerBadge; struct FlatLabel; } //namespace style class QGraphicsOpacityEffect; namespace Ui { class FlatLabel; class IconButton; class PopupMenu; class RoundButton; class StarsRating; template class FadeWrap; class HorizontalFitContainer; namespace Animations { class Simple; } // namespace Animations } //namespace Ui namespace Info { class Controller; class Key; enum class Wrap; } //namespace Info namespace Ui::Menu { struct MenuCallback; } //namespace Ui::Menu namespace Info::Profile { class Badge; class StatusLabel; struct TopBarActionButtonStyle; class TopBar final : public Ui::RpWidget { public: enum class Source { Profile, Stories, Preview, }; struct Descriptor { not_null controller; Key key; rpl::producer wrap; Source source = Source::Profile; PeerData *peer = nullptr; rpl::producer backToggles; rpl::producer<> showFinished; }; struct AnimatedPatternPoint { QPointF basePosition; float64 size; float64 startTime; float64 endTime; }; TopBar(not_null parent, Descriptor descriptor); ~TopBar(); [[nodiscard]] rpl::producer<> backRequest() const; void setOnlineCount(rpl::producer &&count); void setRoundEdges(bool value); void setLottieSingleLoop(bool value); void setColorProfileIndex(std::optional index); void setPatternEmojiId(std::optional patternEmojiId); void setLocalEmojiStatusId(EmojiStatusId emojiStatusId); void addTopBarEditButton( not_null controller, Wrap wrap, bool shouldUseColored); rpl::producer> edgeColor() const; protected: void resizeEvent(QResizeEvent *e) override; void paintEvent(QPaintEvent *e) override; private: void paintEdges(QPainter &p, const QBrush &brush) const; void paintEdges(QPainter &p) const; void updateLabelsPosition(); [[nodiscard]] int titleMostLeft() const; [[nodiscard]] int statusMostLeft() const; [[nodiscard]] QRect userpicGeometry() const; void updateGiftButtonsGeometry( float64 progressCurrent, const QRect &userpicRect); void paintUserpic(QPainter &p, const QRect &geometry); void updateVideoUserpic(); void showTopBarMenu( not_null controller, bool check); void fillTopBarMenu( not_null controller, const Ui::Menu::MenuCallback &addAction); void setupUserpicButton(not_null controller); void setupActions(not_null controller); void setupButtons( not_null controller, Source source); void setupShowLastSeen(not_null controller); void setupUniqueBadgeTooltip(); void hideBadgeTooltip(); void setupAnimatedPattern(const QRect &userpicGeometry = QRect()); void paintAnimatedPattern( QPainter &p, const QRect &rect, const QRect &userpicGeometry); void setupPinnedToTopGifts( not_null controller); void setupNewGifts( not_null controller, const std::vector &gifts); void paintPinnedToTopGifts( QPainter &p, const QRect &rect, const QRect &userpicGeometry); [[nodiscard]] QPointF calculateGiftPosition( int position, float64 progress, const QRect &userpicRect) const; void adjustColors(const std::optional &edgeColor); void updateCollectibleStatus(); void setupStoryOutline(const QRect &geometry = QRect()); void updateStoryOutline(std::optional edgeColor); void paintStoryOutline(QPainter &p, const QRect &geometry); void updateStatusPosition(float64 progressCurrent); [[nodiscard]] int calculateRightButtonsWidth() const; [[nodiscard]] const style::FlatLabel &statusStyle() const; void setupStatusWithRating(); [[nodiscard]] TopBarActionButtonStyle mapActionStyle( std::optional c) const; [[nodiscard]] rpl::producer nameValue() const; [[nodiscard]] auto effectiveColorProfile() const -> std::optional; [[nodiscard]] auto effectiveCollectible() const -> std::shared_ptr; const not_null _peer; Data::ForumTopic *_topic = nullptr; const Key _key; rpl::variable _wrap; const style::InfoTopBar &_st; const Source _source; std::unique_ptr _badgeTooltipHide; const std::unique_ptr _botVerify; rpl::variable _badgeContent; const Fn _gifPausedChecker; const std::unique_ptr _badge; const std::unique_ptr _verified; const bool _hasActions; const int _minForProgress; std::unique_ptr _badgeTooltip; std::vector> _badgeOldTooltips; uint64 _badgeCollectibleId = 0; object_ptr _title; std::unique_ptr _starsRating; object_ptr _status; std::unique_ptr _statusLabel; rpl::variable _statusShift = 0; object_ptr _showLastSeen = { nullptr }; object_ptr _forumButton = { nullptr }; QGraphicsOpacityEffect *_showLastSeenOpacity = nullptr; std::shared_ptr _statusSt; std::shared_ptr _botVerifySt; std::shared_ptr _badgeSt; std::shared_ptr _verifiedSt; rpl::variable _progress = 0.; bool _roundEdges = true; rpl::variable> _edgeColor; bool _hasGradientBg = false; std::optional _solidBg; QImage _cachedGradient; QPainterPath _cachedClipPath; std::unique_ptr _patternEmoji; QImage _basePatternImage; std::vector _animatedPoints; QRect _lastUserpicRect; base::unique_qptr _userpicButton; Ui::PeerUserpicView _userpicView; InMemoryKey _userpicUniqueKey; QImage _cachedUserpic; QImage _monoforumMask; std::unique_ptr _videoUserpicPlayer; std::unique_ptr _topicIconView; rpl::lifetime _userpicLoadingLifetime; base::unique_qptr _close; base::unique_qptr> _back; rpl::variable _backToggles; rpl::event_stream<> _backClicks; base::unique_qptr _topBarButton; base::unique_qptr _peerMenu; Ui::RpWidget *_actionMore = nullptr; base::unique_qptr _actions; std::unique_ptr _lottiePlayer; bool _lottieSingleLoop = false; struct PinnedToTopGiftEntry { Data::SavedStarGiftId manageId; // QString slug; Lottie::Animation *animation = nullptr; std::shared_ptr media; QImage bg; QImage lastFrame; int position = 0; base::unique_qptr button; }; bool _pinnedToTopGiftsFirstTimeShowed = false; std::vector _pinnedToTopGifts; std::unique_ptr _giftsAppearing; std::unique_ptr _giftsHiding; rpl::lifetime _giftsLoadingLifetime; QBrush _storyOutlineBrush; std::vector _storySegments; bool _hasStories = false; bool _hasLiveStories = false; std::optional _localColorProfileIndex; std::optional _localPatternEmojiId; std::shared_ptr _localCollectible; }; } // namespace Info::Profile