/* 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/weak_ptr.h" #include "ui/widgets/menu/menu_add_action_callback.h" #include "ui/rp_widget.h" namespace Ui { class DynamicImage; } // namespace Ui namespace Dialogs { struct TopPeersEntry { uint64 id = 0; QString name; std::shared_ptr userpic; uint32 badge : 30 = 0; uint32 muted : 1 = 0; uint32 online : 1 = 0; }; struct TopPeersList { std::vector entries; }; struct ShowTopPeerMenuRequest { uint64 id = 0; Ui::Menu::MenuCallback callback; }; class TopPeersStrip final : public Ui::RpWidget { public: TopPeersStrip( not_null parent, rpl::producer content); ~TopPeersStrip(); [[nodiscard]] bool empty() const; [[nodiscard]] rpl::producer emptyValue() const; [[nodiscard]] rpl::producer clicks() const; [[nodiscard]] auto showMenuRequests() const -> rpl::producer; private: struct Entry; void resizeEvent(QResizeEvent *e) override; void paintEvent(QPaintEvent *e) override; void wheelEvent(QWheelEvent *e) override; void mousePressEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override; void updateScrollMax(); void updateSelected(); void checkDragging(); bool finishDragging(); void apply(const TopPeersList &list); void apply(Entry &entry, const TopPeersEntry &data); std::vector _entries; rpl::variable _empty = true; rpl::event_stream _clicks; rpl::event_stream _showMenuRequests; rpl::event_stream> _verticalScrollEvents; QPoint _lastMousePosition; std::optional _mouseDownPosition; int _startDraggingLeft = 0; int _scrollLeft = 0; int _scrollLeftMax = 0; bool _dragging = false; Qt::Orientation _scrollingLock = {}; int _selected = -1; int _pressed = -1; base::unique_qptr _menu; base::has_weak_ptr _menuGuard; }; } // namespace Dialogs