Added ability to count inner geometry in HistoryView::Element.

This commit is contained in:
23rd 2022-02-08 05:46:02 +03:00 committed by John Preston
parent 7cd14b8c4e
commit 298c5026be
5 changed files with 23 additions and 0 deletions

View file

@ -415,6 +415,8 @@ public:
void previousInBlocksChanged(); void previousInBlocksChanged();
void nextInBlocksRemoved(); void nextInBlocksRemoved();
virtual QRect innerGeometry() const = 0;
[[nodiscard]] ClickHandlerPtr fromPhotoLink() const { [[nodiscard]] ClickHandlerPtr fromPhotoLink() const {
return fromLink(); return fromLink();
} }

View file

@ -2748,6 +2748,19 @@ TextSelection Message::unskipTextSelection(TextSelection selection) const {
return HistoryView::ShiftItemSelection(selection, message()->_text); 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 { QRect Message::countGeometry() const {
const auto commentsRoot = (context() == Context::Replies) const auto commentsRoot = (context() == Context::Replies)
&& data()->isDiscussionPost(); && data()->isDiscussionPost();

View file

@ -139,6 +139,8 @@ public:
auto takeReactionAnimations() auto takeReactionAnimations()
-> base::flat_map<QString, std::unique_ptr<Reactions::Animation>> override; -> base::flat_map<QString, std::unique_ptr<Reactions::Animation>> override;
QRect innerGeometry() const override;
protected: protected:
void refreshDataIdHook() override; void refreshDataIdHook() override;

View file

@ -393,6 +393,10 @@ not_null<HistoryService*> Service::message() const {
return static_cast<HistoryService*>(data().get()); return static_cast<HistoryService*>(data().get());
} }
QRect Service::innerGeometry() const {
return countGeometry();
}
QRect Service::countGeometry() const { QRect Service::countGeometry() const {
auto result = QRect(0, 0, width(), height()); auto result = QRect(0, 0, width(), height());
if (delegate()->elementIsChatWide()) { if (delegate()->elementIsChatWide()) {

View file

@ -39,6 +39,8 @@ public:
TextSelection selection, TextSelection selection,
TextSelectType type) const override; TextSelectType type) const override;
QRect innerGeometry() const override;
private: private:
not_null<HistoryService*> message() const; not_null<HistoryService*> message() const;