Fix layout of reactions in files / contacts.

This commit is contained in:
John Preston 2021-12-21 11:59:27 +00:00
parent ad1476e80f
commit b5edaf4c23
8 changed files with 35 additions and 18 deletions

View file

@ -91,6 +91,14 @@ int BottomInfo::firstLineWidth() const {
return maxWidth() - _reactionsMaxWidth;
}
bool BottomInfo::isWide() const {
return (_data.flags & Data::Flag::Edited)
|| !_data.author.isEmpty()
|| !_views.isEmpty()
|| !_replies.isEmpty()
|| !_reactions.empty();
}
TextState BottomInfo::textState(
not_null<const HistoryItem*> item,
QPoint position) const {
@ -273,9 +281,9 @@ void BottomInfo::layoutDateText() {
: QString();
const auto author = _data.author;
const auto prefix = author.isEmpty() ? qsl(", ") : QString();
const auto date = _data.date.toString(cTimeFormat());
const auto date = edited + _data.date.toString(cTimeFormat());
_dateWidth = st::msgDateFont->width(date);
const auto afterAuthor = prefix + edited + date;
const auto afterAuthor = prefix + date;
const auto afterAuthorWidth = st::msgDateFont->width(afterAuthor);
const auto authorWidth = st::msgDateFont->width(author);
const auto maxWidth = st::maxSignatureSize;
@ -286,7 +294,7 @@ void BottomInfo::layoutDateText() {
: author;
const auto full = (_data.flags & Data::Flag::Sponsored)
? tr::lng_sponsored(tr::now)
: name + date;
: name.isEmpty() ? date : (name + afterAuthor);
_authorEditedDate.setText(
st::msgDateTextStyle,
full,

View file

@ -52,6 +52,7 @@ public:
void update(Data &&data, int availableWidth);
[[nodiscard]] int firstLineWidth() const;
[[nodiscard]] bool isWide() const;
[[nodiscard]] TextState textState(
not_null<const HistoryItem*> item,
QPoint position) const;

View file

@ -475,6 +475,10 @@ int Element::bottomInfoFirstLineWidth() const {
return 0;
}
bool Element::bottomInfoIsWide() const {
return false;
}
bool Element::isHiddenByGroup() const {
return _flags & Flag::HiddenByGroup;
}

View file

@ -272,6 +272,7 @@ public:
QString skipBlock() const;
virtual int infoWidth() const;
virtual int bottomInfoFirstLineWidth() const;
virtual bool bottomInfoIsWide() const;
bool isHiddenByGroup() const;
virtual bool isHidden() const;

View file

@ -364,7 +364,10 @@ QSize Message::performCountOptimalSize() {
(st::msgPadding.left()
+ _reactions->maxWidth()
+ st::msgPadding.right())));
minHeight += st::mediaInBubbleSkip + _reactions->minHeight();
if (!mediaDisplayed) {
minHeight += st::mediaInBubbleSkip;
}
minHeight += _reactions->minHeight();
}
if (!mediaOnBottom) {
minHeight += st::msgPadding.bottom();
@ -1904,6 +1907,13 @@ int Message::bottomInfoFirstLineWidth() const {
return _bottomInfo.firstLineWidth();
}
bool Message::bottomInfoIsWide() const {
if (_reactions && embedReactionsInBubble()) {
return false;
}
return _bottomInfo.isWide();
}
bool Message::isSignedAuthorElided() const {
return _bottomInfo.isSignedAuthorElided();
}
@ -2661,7 +2671,10 @@ int Message::resizeContentGetHeight(int newWidth) {
newHeight += entry->resizeGetHeight(contentWidth);
}
if (reactionsInBubble) {
newHeight += st::mediaInBubbleSkip + _reactions->height();
if (!mediaDisplayed) {
newHeight += st::mediaInBubbleSkip;
}
newHeight += _reactions->height();
}
}

View file

@ -123,6 +123,7 @@ public:
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;

View file

@ -148,12 +148,7 @@ QSize Contact::countOptimalSize() {
accumulate_max(maxWidth, tleft + _name.maxWidth() + tright);
accumulate_min(maxWidth, st::msgMaxWidth);
auto minHeight = st.padding.top() + st.thumbSize + st.padding.bottom();
const auto msgsigned = item->Get<HistoryMessageSigned>();
const auto views = item->Get<HistoryMessageViews>();
if ((msgsigned && !msgsigned->isAnonymousRank)
|| (views
&& (views->views.count >= 0 || views->replies.count > 0))
|| !item->reactions().empty()) {
if (_parent->bottomInfoIsWide()) {
minHeight += st::msgDateFont->height - st::msgDateDelta.y();
}
if (!isBubbleTop()) {

View file

@ -268,13 +268,7 @@ QSize Document::countOptimalSize() {
}
auto minHeight = st.padding.top() + st.thumbSize + st.padding.bottom();
const auto msgsigned = item->Get<HistoryMessageSigned>();
const auto views = item->Get<HistoryMessageViews>();
if (!captioned && ((msgsigned && !msgsigned->isAnonymousRank)
|| (views
&& (views->views.count >= 0 || views->replies.count > 0))
|| !item->reactions().empty()
|| _parent->displayEditedBadge())) {
if (!captioned && _parent->bottomInfoIsWide()) {
minHeight += st::msgDateFont->height - st::msgDateDelta.y();
}
if (!isBubbleTop()) {