dialogs_message_view.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include <any>
  9. class Image;
  10. class HistoryItem;
  11. enum class ImageRoundRadius;
  12. namespace style {
  13. struct DialogRow;
  14. struct DialogsMiniIcon;
  15. } // namespace style
  16. namespace Ui {
  17. class SpoilerAnimation;
  18. } // namespace Ui
  19. namespace Data {
  20. class Forum;
  21. } // namespace Data
  22. namespace HistoryView {
  23. struct ToPreviewOptions;
  24. struct ItemPreviewImage;
  25. struct ItemPreview;
  26. } // namespace HistoryView
  27. namespace Dialogs::Ui {
  28. using namespace ::Ui;
  29. struct PaintContext;
  30. struct TopicJumpCache;
  31. class TopicsView;
  32. [[nodiscard]] TextWithEntities DialogsPreviewText(TextWithEntities text);
  33. class MessageView final {
  34. public:
  35. MessageView();
  36. ~MessageView();
  37. using ToPreviewOptions = HistoryView::ToPreviewOptions;
  38. using ItemPreviewImage = HistoryView::ItemPreviewImage;
  39. using ItemPreview = HistoryView::ItemPreview;
  40. void itemInvalidated(not_null<const HistoryItem*> item);
  41. [[nodiscard]] bool dependsOn(not_null<const HistoryItem*> item) const;
  42. [[nodiscard]] bool prepared(
  43. not_null<const HistoryItem*> item,
  44. Data::Forum *forum) const;
  45. void prepare(
  46. not_null<const HistoryItem*> item,
  47. Data::Forum *forum,
  48. Fn<void()> customEmojiRepaint,
  49. ToPreviewOptions options);
  50. void paint(
  51. Painter &p,
  52. const QRect &geometry,
  53. const PaintContext &context) const;
  54. [[nodiscard]] bool isInTopicJump(int x, int y) const;
  55. void addTopicJumpRipple(
  56. QPoint origin,
  57. not_null<TopicJumpCache*> topicJumpCache,
  58. Fn<void()> updateCallback);
  59. void stopLastRipple();
  60. void clearRipple();
  61. private:
  62. struct LoadingContext;
  63. [[nodiscard]] int countWidth() const;
  64. void paintJumpToLast(
  65. Painter &p,
  66. const QRect &rect,
  67. const PaintContext &context,
  68. int width1) const;
  69. mutable const HistoryItem *_textCachedFor = nullptr;
  70. mutable Text::String _senderCache;
  71. mutable std::unique_ptr<TopicsView> _topics;
  72. mutable Text::String _textCache;
  73. mutable std::vector<ItemPreviewImage> _imagesCache;
  74. mutable std::unique_ptr<SpoilerAnimation> _spoiler;
  75. mutable std::unique_ptr<LoadingContext> _loadingContext;
  76. mutable const style::DialogsMiniIcon *_leftIcon = nullptr;
  77. mutable QImage _cornersCache;
  78. mutable bool _hasPlainLinkAtBegin = false;
  79. };
  80. [[nodiscard]] HistoryView::ItemPreview PreviewWithSender(
  81. HistoryView::ItemPreview &&preview,
  82. const QString &sender,
  83. TextWithEntities topic);
  84. } // namespace Dialogs::Ui