/* 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 "window/section_widget.h" #include "window/section_memento.h" #include "history/view/history_view_list_widget.h" #include "data/data_messages.h" #include "base/weak_ptr.h" #include "base/timer.h" class History; namespace Ui { class ScrollArea; class PlainShadow; class FlatButton; class HistoryDownButton; } // namespace Ui namespace Profile { class BackButton; } // namespace Profile namespace HistoryView { class Element; class TopBarWidget; class PinnedMemento; class PinnedWidget final : public Window::SectionWidget , private ListDelegate { public: PinnedWidget( QWidget *parent, not_null controller, not_null history); ~PinnedWidget(); [[nodiscard]] not_null history() const; Dialogs::RowDescriptor activeChat() const override; bool hasTopBarShadow() const override { return true; } QPixmap grabForShowAnimation( const Window::SectionSlideParams ¶ms) override; bool showInternal( not_null memento, const Window::SectionShow ¶ms) override; std::shared_ptr createMemento() override; bool showMessage( PeerId peerId, const Window::SectionShow ¶ms, MsgId messageId) override; void setInternalState( const QRect &geometry, not_null memento); Window::SectionActionResult sendBotCommand( Bot::SendCommandRequest request) override { return Window::SectionActionResult::Fallback; } // Float player interface. bool floatPlayerHandleWheelEvent(QEvent *e) override; QRect floatPlayerAvailableRect() override; // ListDelegate interface. Context listContext() override; void listScrollTo(int top) override; void listCancelRequest() override; void listDeleteRequest() override; rpl::producer listSource( Data::MessagePosition aroundId, int limitBefore, int limitAfter) override; bool listAllowsMultiSelect() override; bool listIsItemGoodForSelection(not_null item) override; bool listIsLessInOrder( not_null first, not_null second) override; void listSelectionChanged(SelectedItems &&items) override; void listVisibleItemsChanged(HistoryItemsList &&items) override; MessagesBarData listMessagesBar( const std::vector> &elements) override; void listContentRefreshed() override; ClickHandlerPtr listDateLink(not_null view) override; bool listElementHideReply(not_null view) override; bool listElementShownUnread(not_null view) override; bool listIsGoodForAroundPosition(not_null view) override; void listSendBotCommand( const QString &command, const FullMsgId &context) override; void listHandleViaClick(not_null bot) override; not_null listChatTheme() override; CopyRestrictionType listCopyRestrictionType(HistoryItem *item) override; CopyRestrictionType listSelectRestrictionType() override; protected: void resizeEvent(QResizeEvent *e) override; void paintEvent(QPaintEvent *e) override; void showAnimatedHook( const Window::SectionSlideParams ¶ms) override; void showFinishedHook() override; void doSetInnerFocus() override; private: void onScroll(); void updateInnerVisibleArea(); void updateControlsGeometry(); void updateAdaptiveLayout(); void saveState(not_null memento); void restoreState(not_null memento); void showAtStart(); void showAtEnd(); void showAtPosition( Data::MessagePosition position, HistoryItem *originItem = nullptr); bool showAtPositionNow( Data::MessagePosition position, HistoryItem *originItem, anim::type animated = anim::type::normal); void setupClearButton(); void setupScrollDownButton(); void scrollDownClicked(); void scrollDownAnimationFinish(); void updateScrollDownVisibility(); void updateScrollDownPosition(); void confirmDeleteSelected(); void confirmForwardSelected(); void clearSelected(); void recountChatWidth(); void setMessagesCount(int count); void refreshClearButtonText(); const not_null _history; std::shared_ptr _theme; PeerData *_migratedPeer = nullptr; QPointer _inner; object_ptr _topBar; object_ptr _topBarShadow; bool _skipScrollEvent = false; std::unique_ptr _scroll; std::unique_ptr _clearButton; Ui::Animations::Simple _scrollDownShown; bool _scrollDownIsShown = false; object_ptr _scrollDown; int _messagesCount = -1; }; class PinnedMemento : public Window::SectionMemento { public: using UniversalMsgId = MsgId; explicit PinnedMemento( not_null history, UniversalMsgId highlightId = 0); object_ptr createWidget( QWidget *parent, not_null controller, Window::Column column, const QRect &geometry) override; [[nodiscard]] not_null getHistory() const { return _history; } [[nodiscard]] not_null list() { return &_list; } [[nodiscard]] UniversalMsgId getHighlightId() const { return _highlightId; } private: const not_null _history; const UniversalMsgId _highlightId = 0; ListMemento _list; }; } // namespace HistoryView