diff --git a/Telegram/SourceFiles/history/view/history_view_element.h b/Telegram/SourceFiles/history/view/history_view_element.h index 3dafea728..504a22f01 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.h +++ b/Telegram/SourceFiles/history/view/history_view_element.h @@ -415,6 +415,8 @@ public: void previousInBlocksChanged(); void nextInBlocksRemoved(); + virtual QRect innerGeometry() const = 0; + [[nodiscard]] ClickHandlerPtr fromPhotoLink() const { return fromLink(); } diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 17e02c918..523807798 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -2748,6 +2748,19 @@ TextSelection Message::unskipTextSelection(TextSelection selection) const { return HistoryView::ShiftItemSelection(selection, message()->_text); } +QRect Message::innerGeometry() const { + auto result = countGeometry(); + if (!hasOutLayout()) { + const auto w = std::max( + (media() ? media()->resolveCustomInfoRightBottom().x() : 0), + result.width()); + result.setWidth(std::min( + w + rightActionSize().value_or(QSize(0, 0)).width() * 2, + width())); + } + return result; +} + QRect Message::countGeometry() const { const auto commentsRoot = (context() == Context::Replies) && data()->isDiscussionPost(); diff --git a/Telegram/SourceFiles/history/view/history_view_message.h b/Telegram/SourceFiles/history/view/history_view_message.h index c8550d23f..fa95da1c9 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.h +++ b/Telegram/SourceFiles/history/view/history_view_message.h @@ -139,6 +139,8 @@ public: auto takeReactionAnimations() -> base::flat_map> override; + QRect innerGeometry() const override; + protected: void refreshDataIdHook() override; diff --git a/Telegram/SourceFiles/history/view/history_view_service_message.cpp b/Telegram/SourceFiles/history/view/history_view_service_message.cpp index df4200119..790e0bb41 100644 --- a/Telegram/SourceFiles/history/view/history_view_service_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_service_message.cpp @@ -393,6 +393,10 @@ not_null Service::message() const { return static_cast(data().get()); } +QRect Service::innerGeometry() const { + return countGeometry(); +} + QRect Service::countGeometry() const { auto result = QRect(0, 0, width(), height()); if (delegate()->elementIsChatWide()) { diff --git a/Telegram/SourceFiles/history/view/history_view_service_message.h b/Telegram/SourceFiles/history/view/history_view_service_message.h index b620dee66..df34de79d 100644 --- a/Telegram/SourceFiles/history/view/history_view_service_message.h +++ b/Telegram/SourceFiles/history/view/history_view_service_message.h @@ -39,6 +39,8 @@ public: TextSelection selection, TextSelectType type) const override; + QRect innerGeometry() const override; + private: not_null message() const;