2025-07-18 14:03:52 +04:00
|
|
|
/*
|
|
|
|
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"
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
2025-07-21 09:27:57 +04:00
|
|
|
struct SubTabsOptions {
|
|
|
|
QString selected;
|
|
|
|
bool centered = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SubTabsTab {
|
|
|
|
QString id;
|
|
|
|
TextWithEntities text;
|
|
|
|
|
|
|
|
friend inline bool operator==(
|
|
|
|
const SubTabsTab &,
|
|
|
|
const SubTabsTab &) = default;
|
|
|
|
};
|
|
|
|
|
2025-07-18 14:03:52 +04:00
|
|
|
class SubTabs : public RpWidget {
|
|
|
|
public:
|
2025-07-21 09:27:57 +04:00
|
|
|
using Options = SubTabsOptions;
|
|
|
|
using Tab = SubTabsTab;
|
2025-07-18 14:03:52 +04:00
|
|
|
|
|
|
|
explicit SubTabs(
|
|
|
|
QWidget *parent,
|
|
|
|
Options options = {},
|
|
|
|
std::vector<Tab> tabs = {},
|
|
|
|
Text::MarkedContext context = {});
|
|
|
|
|
|
|
|
void setTabs(
|
|
|
|
std::vector<Tab> tabs,
|
|
|
|
Text::MarkedContext context = {});
|
|
|
|
|
|
|
|
void setActiveTab(const QString &id);
|
|
|
|
|
|
|
|
[[nodiscard]] rpl::producer<QString> activated() const;
|
2025-07-24 16:57:54 +04:00
|
|
|
[[nodiscard]] rpl::producer<QString> contextMenuRequests() const;
|
2025-07-18 14:03:52 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct Button {
|
|
|
|
Tab tab;
|
|
|
|
QRect geometry;
|
|
|
|
Text::String text;
|
|
|
|
bool active = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
int resizeGetHeight(int newWidth) override;
|
|
|
|
void wheelEvent(QWheelEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
2025-07-24 16:57:54 +04:00
|
|
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
2025-07-18 14:03:52 +04:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
bool eventHook(QEvent *e) override;
|
|
|
|
|
|
|
|
void setSelected(int index);
|
|
|
|
void setActive(int index);
|
|
|
|
[[nodiscard]] QPoint scroll() const;
|
|
|
|
|
|
|
|
std::vector<Button> _buttons;
|
|
|
|
rpl::event_stream<QString> _activated;
|
2025-07-24 16:57:54 +04:00
|
|
|
rpl::event_stream<QString> _contextMenuRequests;
|
2025-08-01 16:42:27 +04:00
|
|
|
std::optional<Qt::Orientation> _locked;
|
2025-07-18 14:03:52 +04:00
|
|
|
int _dragx = 0;
|
|
|
|
int _pressx = 0;
|
|
|
|
float64 _dragscroll = 0.;
|
|
|
|
float64 _scroll = 0.;
|
2025-07-25 20:31:56 +04:00
|
|
|
float64 _scrollTo = 0.;
|
|
|
|
Ui::Animations::Simple _scrollAnimation;
|
2025-07-18 14:03:52 +04:00
|
|
|
int _scrollMax = 0;
|
|
|
|
int _fullShift = 0;
|
|
|
|
int _fullWidth = 0;
|
|
|
|
int _selected = -1;
|
|
|
|
int _pressed = -1;
|
|
|
|
int _active = -1;
|
|
|
|
bool _centered = false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Ui
|