2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-23 18:57:12 +00:00
tdesktop/Telegram/SourceFiles/dialogs/ui/dialogs_topics_view.h

131 lines
2.8 KiB
C
Raw Permalink Normal View History

2022-11-11 13:24:37 +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
class Painter;
namespace style {
struct DialogRow;
} // namespace style
namespace Data {
class Forum;
class ForumTopic;
class SavedMessages;
class SavedSublist;
2022-11-11 13:24:37 +04:00
} // namespace Data
namespace Ui {
2022-11-14 11:24:31 +04:00
class RippleAnimation;
2022-11-11 13:24:37 +04:00
} // namespace Ui
namespace Dialogs::Ui {
using namespace ::Ui;
struct PaintContext;
2022-11-14 11:24:31 +04:00
struct TopicJumpCache;
struct TopicJumpCorners;
struct JumpToLastBg {
not_null<const style::DialogRow*> st;
not_null<TopicJumpCorners*> corners;
QRect geometry;
const style::color &bg;
int width1 = 0;
int width2 = 0;
};
struct JumpToLastGeometry {
int rightCut = 0;
2022-11-14 11:24:31 +04:00
QRect area1;
QRect area2;
2022-11-15 18:47:13 +01:00
friend inline bool operator==(
2022-11-14 11:24:31 +04:00
const JumpToLastGeometry&,
const JumpToLastGeometry&) = default;
};
JumpToLastGeometry FillJumpToLastBg(QPainter &p, JumpToLastBg context);
struct JumpToLastPrepared {
not_null<const style::DialogRow*> st;
not_null<TopicJumpCorners*> corners;
const style::color &bg;
const JumpToLastGeometry &prepared;
};
void FillJumpToLastPrepared(QPainter &p, JumpToLastPrepared context);
2022-11-11 13:24:37 +04:00
class TopicsView final {
public:
TopicsView(Data::Forum *forum, Data::SavedMessages *monoforum);
2022-11-11 13:24:37 +04:00
~TopicsView();
[[nodiscard]] Data::Forum *forum() const {
2022-11-11 13:24:37 +04:00
return _forum;
}
[[nodiscard]] Data::SavedMessages *monoforum() const {
return _monoforum;
}
2022-11-11 13:24:37 +04:00
[[nodiscard]] bool prepared() const;
void prepare(MsgId frontRootId, Fn<void()> customEmojiRepaint);
void prepare(PeerId frontPeerId, Fn<void()> customEmojiRepaint);
[[nodiscard]] int jumpToTopicWidth() const;
2022-11-11 13:24:37 +04:00
void paint(
Painter &p,
const QRect &geometry,
const PaintContext &context) const;
2022-11-14 11:24:31 +04:00
bool changeTopicJumpGeometry(JumpToLastGeometry geometry);
void clearTopicJumpGeometry();
[[nodiscard]] bool isInTopicJumpArea(int x, int y) const;
void addTopicJumpRipple(
QPoint origin,
not_null<TopicJumpCache*> topicJumpCache,
Fn<void()> updateCallback);
void paintRipple(
QPainter &p,
int x,
int y,
int outerWidth,
const QColor *colorOverride) const;
void stopLastRipple();
void clearRipple();
2022-11-14 11:24:31 +04:00
2022-11-11 13:24:37 +04:00
[[nodiscard]] rpl::lifetime &lifetime() {
return _lifetime;
}
private:
struct Title {
Text::String title;
uint64 key = 0;
int version = -1;
2022-11-11 13:24:37 +04:00
bool unread = false;
};
2022-11-14 11:24:31 +04:00
[[nodiscard]] QImage topicJumpRippleMask(
not_null<TopicJumpCache*> topicJumpCache) const;
Data::Forum * const _forum = nullptr;
Data::SavedMessages * const _monoforum = nullptr;
2022-11-11 13:24:37 +04:00
mutable std::vector<Title> _titles;
2022-11-14 11:24:31 +04:00
mutable std::unique_ptr<RippleAnimation> _ripple;
JumpToLastGeometry _lastTopicJumpGeometry;
int _version = -1;
bool _jumpToTopic = false;
2025-05-29 18:25:41 +04:00
bool _allLoaded = false;
2022-11-11 13:24:37 +04:00
rpl::lifetime _lifetime;
};
} // namespace Dialogs::Ui