tdesktop/Telegram/SourceFiles/dialogs/ui/dialogs_message_view.h

107 lines
2.5 KiB
C
Raw Normal View History

/*
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 <any>
class Image;
class HistoryItem;
enum class ImageRoundRadius;
namespace style {
struct DialogRow;
struct DialogsMiniIcon;
} // namespace style
namespace Ui {
class SpoilerAnimation;
} // namespace Ui
2022-11-11 09:24:37 +00:00
namespace Data {
class Forum;
} // namespace Data
namespace HistoryView {
struct ToPreviewOptions;
2021-10-04 19:37:55 +00:00
struct ItemPreviewImage;
struct ItemPreview;
} // namespace HistoryView
namespace Dialogs::Ui {
using namespace ::Ui;
struct PaintContext;
2022-11-14 07:24:31 +00:00
struct TopicJumpCache;
2022-11-11 09:24:37 +00:00
class TopicsView;
[[nodiscard]] TextWithEntities DialogsPreviewText(TextWithEntities text);
class MessageView final {
public:
MessageView();
~MessageView();
using ToPreviewOptions = HistoryView::ToPreviewOptions;
2021-10-04 19:37:55 +00:00
using ItemPreviewImage = HistoryView::ItemPreviewImage;
using ItemPreview = HistoryView::ItemPreview;
void itemInvalidated(not_null<const HistoryItem*> item);
[[nodiscard]] bool dependsOn(not_null<const HistoryItem*> item) const;
[[nodiscard]] bool prepared(
not_null<const HistoryItem*> item,
Data::Forum *forum) const;
void prepare(
not_null<const HistoryItem*> item,
Data::Forum *forum,
Fn<void()> customEmojiRepaint,
ToPreviewOptions options);
2022-11-11 09:24:37 +00:00
void paint(
Painter &p,
const QRect &geometry,
const PaintContext &context) const;
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();
void clearRipple();
2022-11-14 07:24:31 +00:00
private:
struct LoadingContext;
[[nodiscard]] int countWidth() const;
void paintJumpToLast(
Painter &p,
const QRect &rect,
const PaintContext &context,
int width1) const;
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;
mutable std::unique_ptr<SpoilerAnimation> _spoiler;
mutable std::unique_ptr<LoadingContext> _loadingContext;
mutable const style::DialogsMiniIcon *_leftIcon = nullptr;
mutable bool _hasPlainLinkAtBegin = false;
};
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
} // namespace Dialogs::Ui