/* 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/rp_widget.h" #include "ui/effects/animations.h" // Right-edge A-Z fast-scroll index strip for the contacts box: thins letters // when they do not all fit and magnifies the one under the cursor Dock-like. class PeerListSectionIndex final : public Ui::RpWidget { public: struct Entry { QString letter; int contentTop = 0; }; explicit PeerListSectionIndex(QWidget *parent); void setLetters(std::vector letters); void setVisibleLetters(base::flat_set letters); void setJumpCallback(Fn callback); void setScrollCallback(Fn)> callback); [[nodiscard]] int idealWidth() const; protected: void paintEvent(QPaintEvent *e) override; void resizeEvent(QResizeEvent *e) override; void mousePressEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; void wheelEvent(QWheelEvent *e) override; void leaveEventHook(QEvent *e) override; private: struct Slot { QString letter; int sourceIndex = 0; int y = 0; }; void relayout(); void setCursor(QPoint position); void scrubTo(int slot, anim::type animated); bool updateCursorFromGlobal(); bool fisheyeFrame(); [[nodiscard]] float64 slotScale(int slotY) const; [[nodiscard]] int slotAtY(int y) const; [[nodiscard]] float64 columnCenterX() const; std::vector _letters; std::vector _slots; std::vector _scale; base::flat_set _visible; Fn _jump; Fn)> _scroll; int _pitch = 0; int _cursorX = -1; int _cursorY = -1; int _current = -1; bool _scrubbing = false; Ui::Animations::Basic _fisheye; };