2021-10-01 12:42:44 +00: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
|
|
|
|
|
2021-10-01 14:58:41 +00:00
|
|
|
#include <any>
|
|
|
|
|
|
|
|
class Image;
|
2021-10-01 12:42:44 +00:00
|
|
|
class HistoryItem;
|
2021-10-01 14:58:41 +00:00
|
|
|
enum class ImageRoundRadius;
|
2021-10-01 12:42:44 +00:00
|
|
|
|
2022-11-13 19:38:18 +00:00
|
|
|
namespace style {
|
|
|
|
struct DialogRow;
|
|
|
|
} // namespace style
|
|
|
|
|
2021-10-01 12:42:44 +00:00
|
|
|
namespace Ui {
|
2022-12-28 10:07:38 +00:00
|
|
|
class SpoilerAnimation;
|
2021-10-01 12:42:44 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2022-11-11 09:24:37 +00:00
|
|
|
namespace Data {
|
|
|
|
class Forum;
|
|
|
|
} // namespace Data
|
|
|
|
|
2021-10-01 12:42:44 +00:00
|
|
|
namespace HistoryView {
|
|
|
|
struct ToPreviewOptions;
|
2021-10-04 19:37:55 +00:00
|
|
|
struct ItemPreviewImage;
|
2021-10-01 12:42:44 +00:00
|
|
|
struct ItemPreview;
|
|
|
|
} // namespace HistoryView
|
|
|
|
|
|
|
|
namespace Dialogs::Ui {
|
|
|
|
|
|
|
|
using namespace ::Ui;
|
|
|
|
|
2022-09-29 07:52:18 +00:00
|
|
|
struct PaintContext;
|
2022-11-14 07:24:31 +00:00
|
|
|
struct TopicJumpCache;
|
2022-11-11 09:24:37 +00:00
|
|
|
class TopicsView;
|
2022-09-29 07:52:18 +00:00
|
|
|
|
2022-07-05 07:50:40 +00:00
|
|
|
[[nodiscard]] TextWithEntities DialogsPreviewText(TextWithEntities text);
|
|
|
|
|
2021-10-01 12:42:44 +00:00
|
|
|
class MessageView final {
|
|
|
|
public:
|
|
|
|
MessageView();
|
|
|
|
~MessageView();
|
|
|
|
|
|
|
|
using ToPreviewOptions = HistoryView::ToPreviewOptions;
|
2021-10-04 19:37:55 +00:00
|
|
|
using ItemPreviewImage = HistoryView::ItemPreviewImage;
|
2021-10-01 12:42:44 +00:00
|
|
|
using ItemPreview = HistoryView::ItemPreview;
|
|
|
|
|
|
|
|
void itemInvalidated(not_null<const HistoryItem*> item);
|
|
|
|
[[nodiscard]] bool dependsOn(not_null<const HistoryItem*> item) const;
|
|
|
|
|
2022-11-13 19:38:18 +00:00
|
|
|
[[nodiscard]] bool prepared(
|
|
|
|
not_null<const HistoryItem*> item,
|
|
|
|
Data::Forum *forum) const;
|
2022-08-09 15:53:40 +00:00
|
|
|
void prepare(
|
|
|
|
not_null<const HistoryItem*> item,
|
2022-11-13 19:38:18 +00:00
|
|
|
Data::Forum *forum,
|
2022-08-09 15:53:40 +00:00
|
|
|
Fn<void()> customEmojiRepaint,
|
|
|
|
ToPreviewOptions options);
|
2022-11-11 09:24:37 +00:00
|
|
|
|
2021-10-01 12:42:44 +00:00
|
|
|
void paint(
|
|
|
|
Painter &p,
|
|
|
|
const QRect &geometry,
|
2022-09-29 07:52:18 +00:00
|
|
|
const PaintContext &context) const;
|
2021-10-01 12:42:44 +00:00
|
|
|
|
2022-11-14 07:24:31 +00:00
|
|
|
[[nodiscard]] bool isInTopicJump(int x, int y) const;
|
|
|
|
void addTopicJumpRipple(
|
|
|
|
QPoint origin,
|
|
|
|
not_null<TopicJumpCache*> topicJumpCache,
|
|
|
|
Fn<void()> updateCallback);
|
|
|
|
void stopLastRipple();
|
|
|
|
|
2021-10-01 12:42:44 +00:00
|
|
|
private:
|
2021-10-01 14:58:41 +00:00
|
|
|
struct LoadingContext;
|
|
|
|
|
2022-11-13 19:38:18 +00:00
|
|
|
[[nodiscard]] int countWidth() const;
|
|
|
|
void paintJumpToLast(
|
|
|
|
Painter &p,
|
|
|
|
const QRect &rect,
|
|
|
|
const PaintContext &context,
|
|
|
|
int width1) const;
|
|
|
|
|
2021-10-01 12:42:44 +00:00
|
|
|
mutable const HistoryItem *_textCachedFor = nullptr;
|
2022-09-16 20:23:27 +00:00
|
|
|
mutable Text::String _senderCache;
|
2022-11-11 09:24:37 +00:00
|
|
|
mutable std::unique_ptr<TopicsView> _topics;
|
2022-09-16 20:23:27 +00:00
|
|
|
mutable Text::String _textCache;
|
2021-10-04 19:37:55 +00:00
|
|
|
mutable std::vector<ItemPreviewImage> _imagesCache;
|
2022-12-28 10:07:38 +00:00
|
|
|
mutable std::unique_ptr<SpoilerAnimation> _spoiler;
|
2021-10-01 14:58:41 +00:00
|
|
|
mutable std::unique_ptr<LoadingContext> _loadingContext;
|
2021-10-01 12:42:44 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-10-04 07:58:31 +00:00
|
|
|
[[nodiscard]] HistoryView::ItemPreview PreviewWithSender(
|
|
|
|
HistoryView::ItemPreview &&preview,
|
2022-11-02 12:39:13 +00:00
|
|
|
const QString &sender,
|
|
|
|
TextWithEntities topic);
|
2021-10-04 07:58:31 +00:00
|
|
|
|
2021-10-01 12:42:44 +00:00
|
|
|
} // namespace Dialogs::Ui
|