/* 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 "dialogs/dialogs_common.h" #include "ui/round_rect.h" #include "ui/rp_widget.h" #include "ui/widgets/buttons.h" namespace style { struct ChatTabsVertical; struct ChatTabsOutline; } // namespace style namespace Ui { class DynamicImage; class RippleAnimation; class SubsectionButton; struct ScrollToRequest; struct SubsectionTab { TextWithEntities text; std::shared_ptr userpic; Dialogs::BadgesState badges; }; struct SubsectionTabs { std::vector tabs; Text::MarkedContext context; int fixed = 0; int pinned = 0; bool reorder = false; }; class SubsectionButtonDelegate { public: virtual bool buttonPaused() = 0; virtual float64 buttonActive(not_null button) = 0; virtual Text::MarkedContext buttonContext() = 0; virtual void buttonContextMenu( not_null button, not_null e) = 0; }; class SubsectionButton : public RippleButton { public: SubsectionButton( not_null parent, not_null delegate, SubsectionTab &&data); ~SubsectionButton(); void setData(SubsectionTab &&data); [[nodiscard]] DynamicImage *userpic() const; void setActiveShown(float64 activeShown); protected: virtual void dataUpdatedHook() = 0; void contextMenuEvent(QContextMenuEvent *e) override; const not_null _delegate; SubsectionTab _data; float64 _activeShown = 0.; }; class SubsectionSlider : public RpWidget , public SubsectionButtonDelegate { public: ~SubsectionSlider(); void setSections( SubsectionTabs sections, Fn paused); void setActiveSectionFast(int active); [[nodiscard]] int sectionsCount() const; [[nodiscard]] rpl::producer sectionActivated() const; [[nodiscard]] rpl::producer sectionContextMenu() const; [[nodiscard]] int lookupSectionPosition(int index) const; bool buttonPaused() override; float64 buttonActive(not_null button) override; void buttonContextMenu( not_null button, not_null e) override; Text::MarkedContext buttonContext() override; [[nodiscard]] not_null buttonAt(int index); [[nodiscard]] rpl::producer requestShown() const; protected: struct Range { int from = 0; int size = 0; }; SubsectionSlider(not_null parent, bool vertical); void setupBar(); void paintEvent(QPaintEvent *e) override; [[nodiscard]] int lookupSectionIndex(QPoint position) const; [[nodiscard]] Range getFinalActiveRange() const; [[nodiscard]] Range getCurrentActiveRange() const; void activate(int index); [[nodiscard]] virtual std::unique_ptr makeButton( SubsectionTab &&data) = 0; const bool _vertical = false; const style::ChatTabsOutline &_barSt; RpWidget *_bar = nullptr; RoundRect _barRect; std::vector> _tabs; int _active = -1; int _pressed = -1; Animations::Simple _activeFrom; Animations::Simple _activeSize; //int _buttonIndexHint = 0; Text::MarkedContext _context; int _fixedCount = 0; int _pinnedCount = 0; bool _reorderAllowed = false; rpl::event_stream _sectionActivated; rpl::event_stream _sectionContextMenu; Fn _paused; rpl::event_stream _requestShown; }; class VerticalSlider final : public SubsectionSlider { public: explicit VerticalSlider(not_null parent); ~VerticalSlider(); private: std::unique_ptr makeButton( SubsectionTab &&data) override; }; class HorizontalSlider final : public SubsectionSlider { public: explicit HorizontalSlider(not_null parent); ~HorizontalSlider(); private: std::unique_ptr makeButton( SubsectionTab &&data) override; const style::SettingsSlider &_st; }; [[nodiscard]] std::shared_ptr MakeAllSubsectionsThumbnail( Fn textColor); } // namespace Ui