"Fossies" - the Fresh Open Source Software Archive 
Member "tdesktop-4.8.1/Telegram/SourceFiles/history/view/history_view_message.h" (24 Apr 2023, 9067 Bytes) of package /linux/misc/tdesktop-4.8.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "history_view_message.h" see the
Fossies "Dox" file reference documentation.
1 /*
2 This file is part of Telegram Desktop,
3 the official desktop application for the Telegram messaging service.
4
5 For license and copyright information please follow this link:
6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
7 */
8 #pragma once
9
10 #include "history/view/history_view_element.h"
11 #include "history/view/history_view_bottom_info.h"
12 #include "ui/effects/animations.h"
13
14 class HistoryItem;
15 struct HistoryMessageEdited;
16 struct HistoryMessageForwarded;
17 struct HistoryMessageReplyMarkup;
18
19 namespace Data {
20 struct ReactionId;
21 } // namespace Data
22
23 namespace Ui {
24 struct BubbleRounding;
25 } // namespace Ui
26
27 namespace HistoryView {
28
29 class ViewButton;
30 class WebPage;
31
32 namespace Reactions {
33 class InlineList;
34 } // namespace Reactions
35
36 // Special type of Component for the channel actions log.
37 struct LogEntryOriginal
38 : public RuntimeComponent<LogEntryOriginal, Element> {
39 LogEntryOriginal();
40 LogEntryOriginal(LogEntryOriginal &&other);
41 LogEntryOriginal &operator=(LogEntryOriginal &&other);
42 ~LogEntryOriginal();
43
44 std::unique_ptr<WebPage> page;
45 };
46
47 struct PsaTooltipState : public RuntimeComponent<PsaTooltipState, Element> {
48 QString type;
49 mutable ClickHandlerPtr link;
50 mutable Ui::Animations::Simple buttonVisibleAnimation;
51 mutable bool buttonVisible = true;
52 };
53
54 struct BottomRippleMask {
55 QImage image;
56 int shift = 0;
57 };
58
59 [[nodiscard]] style::color FromNameFg(
60 const Ui::ChatPaintContext &context,
61 PeerId peerId);
62
63 class Message final : public Element {
64 public:
65 Message(
66 not_null<ElementDelegate*> delegate,
67 not_null<HistoryItem*> data,
68 Element *replacing);
69 ~Message();
70
71 void clickHandlerPressedChanged(
72 const ClickHandlerPtr &handler,
73 bool pressed) override;
74
75 [[nodiscard]] const HistoryMessageEdited *displayedEditBadge() const;
76 [[nodiscard]] HistoryMessageEdited *displayedEditBadge();
77
78 [[nodiscard]] bool embedReactionsInBottomInfo() const;
79 [[nodiscard]] bool embedReactionsInBubble() const;
80
81 int marginTop() const override;
82 int marginBottom() const override;
83 void draw(Painter &p, const PaintContext &context) const override;
84 PointState pointState(QPoint point) const override;
85 TextState textState(
86 QPoint point,
87 StateRequest request) const override;
88 void updatePressed(QPoint point) override;
89 void drawInfo(
90 Painter &p,
91 const PaintContext &context,
92 int right,
93 int bottom,
94 int width,
95 InfoDisplayType type) const override;
96 TextState bottomInfoTextState(
97 int right,
98 int bottom,
99 QPoint point,
100 InfoDisplayType type) const override;
101 TextForMimeData selectedText(TextSelection selection) const override;
102 TextSelection adjustSelection(
103 TextSelection selection,
104 TextSelectType type) const override;
105
106 Reactions::ButtonParameters reactionButtonParameters(
107 QPoint position,
108 const TextState &reactionState) const override;
109 int reactionsOptimalWidth() const override;
110
111 bool hasHeavyPart() const override;
112 void unloadHeavyPart() override;
113
114 // hasFromPhoto() returns true even if we don't display the photo
115 // but we need to skip a place at the left side for this photo
116 bool hasFromPhoto() const override;
117 bool displayFromPhoto() const override;
118 bool hasFromName() const override;
119 bool displayFromName() const override;
120 bool displayForwardedFrom() const override;
121 bool hasOutLayout() const override;
122 bool drawBubble() const override;
123 bool hasBubble() const override;
124 TopicButton *displayedTopicButton() const override;
125 bool unwrapped() const override;
126 int minWidthForMedia() const override;
127 bool hasFastReply() const override;
128 bool displayFastReply() const override;
129 bool displayRightActionComments() const;
130 std::optional<QSize> rightActionSize() const override;
131 void drawRightAction(
132 Painter &p,
133 const PaintContext &context,
134 int left,
135 int top,
136 int outerWidth) const override;
137 [[nodiscard]] ClickHandlerPtr rightActionLink(
138 std::optional<QPoint> pressPoint) const override;
139 [[nodiscard]] TimeId displayedEditDate() const override;
140 [[nodiscard]] HistoryMessageReply *displayedReply() const override;
141 [[nodiscard]] bool toggleSelectionByHandlerClick(
142 const ClickHandlerPtr &handler) const override;
143 [[nodiscard]] int infoWidth() const override;
144 [[nodiscard]] int bottomInfoFirstLineWidth() const override;
145 [[nodiscard]] bool bottomInfoIsWide() const override;
146 [[nodiscard]] bool isSignedAuthorElided() const override;
147
148 void itemDataChanged() override;
149
150 VerticalRepaintRange verticalRepaintRange() const override;
151
152 void applyGroupAdminChanges(
153 const base::flat_set<UserId> &changes) override;
154
155 void animateReaction(Ui::ReactionFlyAnimationArgs &&args) override;
156 auto takeReactionAnimations()
157 -> base::flat_map<
158 Data::ReactionId,
159 std::unique_ptr<Ui::ReactionFlyAnimation>> override;
160
161 QRect innerGeometry() const override;
162 [[nodiscard]] BottomRippleMask bottomRippleMask(int buttonHeight) const;
163
164 protected:
165 void refreshDataIdHook() override;
166
167 private:
168 struct CommentsButton;
169 struct FromNameStatus;
170 struct RightAction;
171
172 void initLogEntryOriginal();
173 void initPsa();
174 void fromNameUpdated(int width) const;
175
176 [[nodiscard]] bool showForwardsFromSender(
177 not_null<HistoryMessageForwarded*> forwarded) const;
178 [[nodiscard]] TextSelection skipTextSelection(
179 TextSelection selection) const;
180 [[nodiscard]] TextSelection unskipTextSelection(
181 TextSelection selection) const;
182
183 void toggleCommentsButtonRipple(bool pressed);
184 void createCommentsButtonRipple();
185
186 void toggleTopicButtonRipple(bool pressed);
187 void createTopicButtonRipple();
188
189 void toggleRightActionRipple(bool pressed);
190 void createRightActionRipple();
191
192 void paintCommentsButton(
193 Painter &p,
194 QRect &g,
195 const PaintContext &context) const;
196 void paintFromName(
197 Painter &p,
198 QRect &trect,
199 const PaintContext &context) const;
200 void paintTopicButton(
201 Painter &p,
202 QRect &trect,
203 const PaintContext &context) const;
204 void paintForwardedInfo(
205 Painter &p,
206 QRect &trect,
207 const PaintContext &context) const;
208 void paintReplyInfo(
209 Painter &p,
210 QRect &trect,
211 const PaintContext &context) const;
212 // This method draws "via @bot" if it is not painted
213 // in forwarded info or in from name.
214 void paintViaBotIdInfo(
215 Painter &p,
216 QRect &trect,
217 const PaintContext &context) const;
218 void paintText(
219 Painter &p,
220 QRect &trect,
221 const PaintContext &context) const;
222
223 bool getStateCommentsButton(
224 QPoint point,
225 QRect &g,
226 not_null<TextState*> outResult) const;
227 bool getStateFromName(
228 QPoint point,
229 QRect &trect,
230 not_null<TextState*> outResult) const;
231 bool getStateTopicButton(
232 QPoint point,
233 QRect &trect,
234 not_null<TextState*> outResult) const;
235 bool getStateForwardedInfo(
236 QPoint point,
237 QRect &trect,
238 not_null<TextState*> outResult,
239 StateRequest request) const;
240 bool getStateReplyInfo(
241 QPoint point,
242 QRect &trect,
243 not_null<TextState*> outResult) const;
244 bool getStateViaBotIdInfo(
245 QPoint point,
246 QRect &trect,
247 not_null<TextState*> outResult) const;
248 bool getStateText(
249 QPoint point,
250 QRect &trect,
251 not_null<TextState*> outResult,
252 StateRequest request) const;
253
254 void updateMediaInBubbleState();
255 QRect countGeometry() const;
256 [[nodiscard]] Ui::BubbleRounding countMessageRounding() const;
257 [[nodiscard]] Ui::BubbleRounding countBubbleRounding(
258 Ui::BubbleRounding messageRounding) const;
259 [[nodiscard]] Ui::BubbleRounding countBubbleRounding() const;
260
261 int resizeContentGetHeight(int newWidth);
262 QSize performCountOptimalSize() override;
263 QSize performCountCurrentSize(int newWidth) override;
264 bool hasVisibleText() const override;
265 [[nodiscard]] int visibleTextLength() const;
266 [[nodiscard]] int visibleMediaTextLength() const;
267 [[nodiscard]] bool needInfoDisplay() const;
268
269 [[nodiscard]] bool isPinnedContext() const;
270
271 [[nodiscard]] bool displayFastShare() const;
272 [[nodiscard]] bool displayGoToOriginal() const;
273 [[nodiscard]] ClickHandlerPtr fastReplyLink() const;
274 [[nodiscard]] ClickHandlerPtr prepareRightActionLink() const;
275
276 void ensureRightAction() const;
277 void refreshTopicButton();
278 void refreshInfoSkipBlock();
279 [[nodiscard]] int plainMaxWidth() const;
280 [[nodiscard]] int monospaceMaxWidth() const;
281
282 void validateInlineKeyboard(HistoryMessageReplyMarkup *markup);
283 void updateViewButtonExistence();
284 [[nodiscard]] int viewButtonHeight() const;
285
286 [[nodiscard]] WebPage *logEntryOriginal() const;
287
288 [[nodiscard]] ClickHandlerPtr createGoToCommentsLink() const;
289 [[nodiscard]] ClickHandlerPtr psaTooltipLink() const;
290 void psaTooltipToggled(bool shown) const;
291
292 void refreshRightBadge();
293 void refreshReactions();
294 void validateFromNameText(PeerData *from) const;
295
296 mutable std::unique_ptr<RightAction> _rightAction;
297 mutable ClickHandlerPtr _fastReplyLink;
298 mutable std::unique_ptr<ViewButton> _viewButton;
299 std::unique_ptr<Reactions::InlineList> _reactions;
300 std::unique_ptr<TopicButton> _topicButton;
301 mutable std::unique_ptr<CommentsButton> _comments;
302
303 mutable Ui::Text::String _fromName;
304 mutable std::unique_ptr<FromNameStatus> _fromNameStatus;
305 Ui::Text::String _rightBadge;
306 mutable int _fromNameVersion = 0;
307 int _bubbleWidthLimit = 0;
308
309 BottomInfo _bottomInfo;
310
311 };
312
313 } // namespace HistoryView