/* 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 "ui/effects/animations.h" #include "history/view/history_view_list_widget.h" #include "window/section_widget.h" #include "window/section_memento.h" #include "data/data_feed.h" #include "history/history_item.h" #include "history/admin_log/history_admin_log_item.h" namespace Ui { class ScrollArea; class PlainShadow; class FlatButton; class HistoryDownButton; } // namespace Ui namespace HistoryView { class ListWidget; class TopBarWidget; class Element; } // namespace HistoryView namespace Window { class DateClickHandler; } // namespace Window namespace HistoryFeed { class Memento; class Widget final : public Window::SectionWidget , public HistoryView::ListDelegate { public: using Element = HistoryView::Element; Widget( QWidget *parent, not_null controller, not_null feed); 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::unique_ptr createMemento() override; void setInternalState( const QRect &geometry, not_null memento); // Float player interface. bool wheelEventFromFloatPlayer(QEvent *e) override; QRect rectForFloatPlayer() const override; // HistoryView::ListDelegate interface. HistoryView::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 listIsLessInOrder( not_null first, not_null second) override; void listSelectionChanged( HistoryView::SelectedItems &&items) override; void listVisibleItemsChanged(HistoryItemsList &&items) override; std::optional listUnreadBarView( const std::vector> &elements) override; void listContentRefreshed() override; ClickHandlerPtr listDateLink(not_null view) 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 checkForSingleChannelFeed(); void onScroll(); void updateInnerVisibleArea(); void updateControlsGeometry(); void updateAdaptiveLayout(); void saveState(not_null memento); void restoreState(not_null memento); void showAtPosition(Data::MessagePosition position); bool showAtPositionNow(Data::MessagePosition position); void validateEmptyTextItem(); void setupScrollDownButton(); void scrollDownClicked(); void scrollDownAnimationFinish(); void updateScrollDownVisibility(); void updateScrollDownPosition(); void forwardSelected(); void confirmDeleteSelected(); void clearSelected(); void setupShortcuts(); not_null _feed; object_ptr _scroll; QPointer _inner; object_ptr _topBar; object_ptr _topBarShadow; object_ptr _showNext; bool _skipScrollEvent = false; bool _undefinedAroundPosition = false; std::unique_ptr _emptyTextItem; std::unique_ptr _emptyTextView; FullMsgId _currentMessageId; FullMsgId _highlightMessageId; std::optional _nextAnimatedScrollPosition; int _nextAnimatedScrollDelta = 0; Ui::Animations::Simple _scrollDownShown; bool _scrollDownIsShown = false; object_ptr _scrollDown; std::shared_ptr _dateLink; }; class Memento : public Window::SectionMemento { public: explicit Memento( not_null feed, Data::MessagePosition position = Data::UnreadMessagePosition); ~Memento(); object_ptr createWidget( QWidget *parent, not_null controller, Window::Column column, const QRect &geometry) override; not_null feed() const { return _feed; } Data::MessagePosition position() const { return _position; } not_null list() const { return _list.get(); } private: not_null _feed; Data::MessagePosition _position; std::unique_ptr _list; }; } // namespace HistoryFeed