tdesktop/Telegram/SourceFiles/history/view/history_view_service_message.h

157 lines
3.3 KiB
C
Raw Normal View History

2016-05-31 11:46:31 +02:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
2016-05-31 11:46:31 +02:00
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
2016-05-31 11:46:31 +02:00
*/
#pragma once
#include "history/view/history_view_element.h"
2022-12-14 13:15:46 +01:00
class HistoryItem;
namespace Ui {
class ChatStyle;
struct CornersPixmaps;
} // namespace Ui
2022-10-25 18:40:26 +02:00
namespace Data {
class ForumTopic;
} // namespace Data
namespace Info::Profile {
class TopicIconView;
} // namespace Info::Profile
2018-01-09 18:08:31 +01:00
namespace HistoryView {
2016-05-31 11:46:31 +02:00
class Service final : public Element {
public:
Service(
not_null<ElementDelegate*> delegate,
2022-12-14 13:15:46 +01:00
not_null<HistoryItem*> data,
Element *replacing);
2018-02-16 18:59:35 +01:00
int marginTop() const override;
int marginBottom() const override;
2018-01-30 14:17:50 +01:00
bool isHidden() const override;
void draw(Painter &p, const PaintContext &context) const override;
PointState pointState(QPoint point) const override;
TextState textState(
QPoint point,
StateRequest request) const override;
void updatePressed(QPoint point) override;
TextForMimeData selectedText(TextSelection selection) const override;
2023-10-31 19:37:59 +01:00
SelectedQuote selectedQuote(TextSelection selection) const override;
TextSelection selectionFromQuote(
2023-10-31 19:37:59 +01:00
not_null<HistoryItem*> item,
const TextWithEntities &quote) const override;
TextSelection adjustSelection(
TextSelection selection,
TextSelectType type) const override;
QRect innerGeometry() const override;
private:
2022-12-14 13:15:46 +01:00
[[nodiscard]] QRect countGeometry() const;
QSize performCountOptimalSize() override;
QSize performCountCurrentSize(int newWidth) override;
};
int WideChatWidth();
class ServiceMessagePainter {
public:
static void PaintDate(
Painter &p,
not_null<const Ui::ChatStyle*> st,
const QDateTime &date,
int y,
int w,
bool chatWide);
static void PaintDate(
Painter &p,
not_null<const Ui::ChatStyle*> st,
const QString &dateText,
int y,
int w,
bool chatWide);
static void PaintDate(
Painter &p,
not_null<const Ui::ChatStyle*> st,
const QString &dateText,
int dateTextWidth,
int y,
int w,
bool chatWide);
static void PaintDate(
Painter &p,
const style::color &bg,
const Ui::CornersPixmaps &corners,
const style::color &fg,
const QString &dateText,
int dateTextWidth,
int y,
int w,
bool chatWide);
static void PaintBubble(
Painter &p,
not_null<const Ui::ChatStyle*> st,
QRect rect);
static void PaintBubble(
Painter &p,
const style::color &bg,
const Ui::CornersPixmaps &corners,
QRect rect);
2016-07-08 12:06:41 +02:00
static void PaintComplexBubble(
Painter &p,
not_null<const Ui::ChatStyle*> st,
int left,
int width,
const Ui::Text::String &text,
const QRect &textRect);
private:
2023-10-03 15:50:33 +02:00
static std::vector<int> CountLineWidths(
const Ui::Text::String &text,
const QRect &textRect);
};
2019-01-18 09:11:15 +01:00
class EmptyPainter {
public:
explicit EmptyPainter(not_null<History*> history);
2022-10-25 18:40:26 +02:00
EmptyPainter(
not_null<Data::ForumTopic*> topic,
Fn<bool()> paused,
Fn<void()> update);
~EmptyPainter();
2019-01-18 09:11:15 +01:00
void paint(
Painter &p,
not_null<const Ui::ChatStyle*> st,
int width,
int height);
2019-01-18 09:11:15 +01:00
private:
void fillAboutGroup();
2022-10-25 18:40:26 +02:00
void fillAboutTopic();
2019-01-18 09:11:15 +01:00
not_null<History*> _history;
2022-10-25 18:40:26 +02:00
Data::ForumTopic *_topic = nullptr;
std::unique_ptr<Info::Profile::TopicIconView> _icon;
Ui::Text::String _header;
Ui::Text::String _text;
2019-06-12 15:26:04 +02:00
std::vector<Ui::Text::String> _phrases;
2019-01-18 09:11:15 +01:00
2022-10-25 18:40:26 +02:00
rpl::lifetime _lifetime;
2019-01-18 09:11:15 +01:00
};
2018-01-09 18:08:31 +01:00
} // namespace HistoryView