| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 |
- /*
- 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 "history/view/history_view_element.h"
- #include "history/view/history_view_bottom_info.h"
- #include "ui/effects/animations.h"
- class HistoryItem;
- struct HistoryMessageEdited;
- struct HistoryMessageForwarded;
- struct HistoryMessageReplyMarkup;
- namespace Data {
- struct ReactionId;
- } // namespace Data
- namespace Ui {
- struct BubbleRounding;
- class RoundCheckbox;
- } // namespace Ui
- namespace HistoryView {
- class ViewButton;
- class WebPage;
- namespace Reactions {
- class InlineList;
- } // namespace Reactions
- // Special type of Component for the channel actions log.
- struct LogEntryOriginal
- : public RuntimeComponent<LogEntryOriginal, Element> {
- LogEntryOriginal();
- LogEntryOriginal(LogEntryOriginal &&other);
- LogEntryOriginal &operator=(LogEntryOriginal &&other);
- ~LogEntryOriginal();
- std::unique_ptr<WebPage> page;
- };
- struct Factcheck
- : public RuntimeComponent<Factcheck, Element> {
- std::unique_ptr<WebPage> page;
- bool expanded = false;
- };
- struct PsaTooltipState : public RuntimeComponent<PsaTooltipState, Element> {
- QString type;
- mutable ClickHandlerPtr link;
- mutable Ui::Animations::Simple buttonVisibleAnimation;
- mutable bool buttonVisible = true;
- };
- struct BottomRippleMask {
- QImage image;
- int shift = 0;
- };
- class Message final : public Element {
- public:
- Message(
- not_null<ElementDelegate*> delegate,
- not_null<HistoryItem*> data,
- Element *replacing);
- ~Message();
- void clickHandlerPressedChanged(
- const ClickHandlerPtr &handler,
- bool pressed) override;
- [[nodiscard]] const HistoryMessageEdited *displayedEditBadge() const;
- [[nodiscard]] HistoryMessageEdited *displayedEditBadge();
- bool embedReactionsInBubble() const override;
- int marginTop() const override;
- int marginBottom() 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;
- void drawInfo(
- Painter &p,
- const PaintContext &context,
- int right,
- int bottom,
- int width,
- InfoDisplayType type) const override;
- TextState bottomInfoTextState(
- int right,
- int bottom,
- QPoint point,
- InfoDisplayType type) const override;
- TextForMimeData selectedText(TextSelection selection) const override;
- SelectedQuote selectedQuote(TextSelection selection) const override;
- TextSelection selectionFromQuote(
- const SelectedQuote "e) const override;
- TextSelection adjustSelection(
- TextSelection selection,
- TextSelectType type) const override;
- Reactions::ButtonParameters reactionButtonParameters(
- QPoint position,
- const TextState &reactionState) const override;
- int reactionsOptimalWidth() const override;
- bool hasHeavyPart() const override;
- void unloadHeavyPart() override;
- // hasFromPhoto() returns true even if we don't display the photo
- // but we need to skip a place at the left side for this photo
- bool hasFromPhoto() const override;
- bool displayFromPhoto() const override;
- bool hasFromName() const override;
- bool displayFromName() const override;
- bool displayForwardedFrom() const override;
- bool hasOutLayout() const override;
- bool drawBubble() const override;
- bool hasBubble() const override;
- TopicButton *displayedTopicButton() const override;
- bool unwrapped() const override;
- int minWidthForMedia() const override;
- bool displayRightActionComments() const;
- std::optional<QSize> rightActionSize() const override;
- void drawRightAction(
- Painter &p,
- const PaintContext &context,
- int left,
- int top,
- int outerWidth) const override;
- [[nodiscard]] ClickHandlerPtr rightActionLink(
- std::optional<QPoint> pressPoint) const override;
- [[nodiscard]] TimeId displayedEditDate() const override;
- [[nodiscard]] bool toggleSelectionByHandlerClick(
- const ClickHandlerPtr &handler) const override;
- [[nodiscard]] bool allowTextSelectionByHandler(
- const ClickHandlerPtr &handler) const override;
- [[nodiscard]] int infoWidth() const override;
- [[nodiscard]] int bottomInfoFirstLineWidth() const override;
- [[nodiscard]] bool bottomInfoIsWide() const override;
- [[nodiscard]] bool isSignedAuthorElided() const override;
- void itemDataChanged() override;
- VerticalRepaintRange verticalRepaintRange() const override;
- void applyGroupAdminChanges(
- const base::flat_set<UserId> &changes) override;
- void animateReaction(Ui::ReactionFlyAnimationArgs &&args) override;
- void animateEffect(Ui::ReactionFlyAnimationArgs &&args) override;
- auto takeEffectAnimation()
- -> std::unique_ptr<Ui::ReactionFlyAnimation> override;
- QRect effectIconGeometry() const override;
- QRect innerGeometry() const override;
- [[nodiscard]] BottomRippleMask bottomRippleMask(int buttonHeight) const;
- protected:
- void refreshDataIdHook() override;
- private:
- struct CommentsButton;
- struct FromNameStatus;
- struct RightAction;
- bool updateBottomInfo();
- void initPaidInformation();
- void initLogEntryOriginal();
- void initPsa();
- void fromNameUpdated(int width) const;
- [[nodiscard]] TextSelection skipTextSelection(
- TextSelection selection) const;
- [[nodiscard]] TextSelection unskipTextSelection(
- TextSelection selection) const;
- void toggleCommentsButtonRipple(bool pressed);
- void createCommentsButtonRipple();
- void toggleTopicButtonRipple(bool pressed);
- void createTopicButtonRipple();
- void toggleRightActionRipple(bool pressed);
- void toggleReplyRipple(bool pressed);
- void paintCommentsButton(
- Painter &p,
- QRect &g,
- const PaintContext &context) const;
- void paintFromName(
- Painter &p,
- QRect &trect,
- const PaintContext &context) const;
- void paintTopicButton(
- Painter &p,
- QRect &trect,
- const PaintContext &context) const;
- void paintForwardedInfo(
- Painter &p,
- QRect &trect,
- const PaintContext &context) const;
- void paintReplyInfo(
- Painter &p,
- QRect &trect,
- const PaintContext &context) const;
- // This method draws "via @bot" if it is not painted
- // in forwarded info or in from name.
- void paintViaBotIdInfo(
- Painter &p,
- QRect &trect,
- const PaintContext &context) const;
- void paintText(
- Painter &p,
- QRect &trect,
- const PaintContext &context) const;
- bool getStateCommentsButton(
- QPoint point,
- QRect &g,
- not_null<TextState*> outResult) const;
- bool getStateFromName(
- QPoint point,
- QRect &trect,
- not_null<TextState*> outResult) const;
- bool getStateTopicButton(
- QPoint point,
- QRect &trect,
- not_null<TextState*> outResult) const;
- bool getStateForwardedInfo(
- QPoint point,
- QRect &trect,
- not_null<TextState*> outResult,
- StateRequest request) const;
- bool getStateReplyInfo(
- QPoint point,
- QRect &trect,
- not_null<TextState*> outResult) const;
- bool getStateViaBotIdInfo(
- QPoint point,
- QRect &trect,
- not_null<TextState*> outResult) const;
- bool getStateText(
- QPoint point,
- QRect &trect,
- not_null<TextState*> outResult,
- StateRequest request) const;
- void updateMediaInBubbleState();
- QRect countGeometry() const;
- [[nodiscard]] Ui::BubbleRounding countMessageRounding() const;
- [[nodiscard]] Ui::BubbleRounding countBubbleRounding(
- Ui::BubbleRounding messageRounding) const;
- [[nodiscard]] Ui::BubbleRounding countBubbleRounding() const;
- int resizeContentGetHeight(int newWidth);
- QSize performCountOptimalSize() override;
- QSize performCountCurrentSize(int newWidth) override;
- bool hasVisibleText() const override;
- [[nodiscard]] int visibleTextLength() const;
- [[nodiscard]] int visibleMediaTextLength() const;
- [[nodiscard]] bool needInfoDisplay() const;
- [[nodiscard]] bool invertMedia() const;
- [[nodiscard]] bool hasFastReply() const;
- [[nodiscard]] bool hasFastForward() const;
- [[nodiscard]] bool displayFastReply() const;
- [[nodiscard]] bool displayFastForward() const;
- [[nodiscard]] bool isPinnedContext() const;
- [[nodiscard]] bool displayFastShare() const;
- [[nodiscard]] bool displayGoToOriginal() const;
- [[nodiscard]] ClickHandlerPtr fastReplyLink() const;
- [[nodiscard]] ClickHandlerPtr prepareRightActionLink() const;
- void ensureRightAction() const;
- void refreshTopicButton();
- void refreshInfoSkipBlock(HistoryItem *textItem);
- [[nodiscard]] int monospaceMaxWidth() const;
- void validateInlineKeyboard(HistoryMessageReplyMarkup *markup);
- void updateViewButtonExistence();
- [[nodiscard]] int viewButtonHeight() const;
- [[nodiscard]] WebPage *logEntryOriginal() const;
- [[nodiscard]] WebPage *factcheckBlock() const;
- [[nodiscard]] ClickHandlerPtr createGoToCommentsLink() const;
- [[nodiscard]] ClickHandlerPtr psaTooltipLink() const;
- void psaTooltipToggled(bool shown) const;
- void refreshRightBadge();
- void validateFromNameText(PeerData *from) const;
- void ensureFromNameStatusLink(not_null<PeerData*> peer) const;
- mutable std::unique_ptr<RightAction> _rightAction;
- mutable ClickHandlerPtr _fastReplyLink;
- mutable std::unique_ptr<ViewButton> _viewButton;
- std::unique_ptr<TopicButton> _topicButton;
- mutable std::unique_ptr<CommentsButton> _comments;
- mutable Ui::Text::String _fromName;
- mutable std::unique_ptr<FromNameStatus> _fromNameStatus;
- mutable std::unique_ptr<Ui::RoundCheckbox> _selectionRoundCheckbox;
- Ui::Text::String _rightBadge;
- mutable int _fromNameVersion = 0;
- uint32 _bubbleWidthLimit : 28 = 0;
- uint32 _invertMedia : 1 = 0;
- uint32 _hideReply : 1 = 0;
- uint32 _rightBadgeHasBoosts : 1 = 0;
- uint32 _postShowingAuthor : 1 = 0;
- BottomInfo _bottomInfo;
- };
- } // namespace HistoryView
|