mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix layout of reactions in files / contacts.
This commit is contained in:
parent
ad1476e80f
commit
b5edaf4c23
8 changed files with 35 additions and 18 deletions
|
@ -91,6 +91,14 @@ int BottomInfo::firstLineWidth() const {
|
||||||
return maxWidth() - _reactionsMaxWidth;
|
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(
|
TextState BottomInfo::textState(
|
||||||
not_null<const HistoryItem*> item,
|
not_null<const HistoryItem*> item,
|
||||||
QPoint position) const {
|
QPoint position) const {
|
||||||
|
@ -273,9 +281,9 @@ void BottomInfo::layoutDateText() {
|
||||||
: QString();
|
: QString();
|
||||||
const auto author = _data.author;
|
const auto author = _data.author;
|
||||||
const auto prefix = author.isEmpty() ? qsl(", ") : QString();
|
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);
|
_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 afterAuthorWidth = st::msgDateFont->width(afterAuthor);
|
||||||
const auto authorWidth = st::msgDateFont->width(author);
|
const auto authorWidth = st::msgDateFont->width(author);
|
||||||
const auto maxWidth = st::maxSignatureSize;
|
const auto maxWidth = st::maxSignatureSize;
|
||||||
|
@ -286,7 +294,7 @@ void BottomInfo::layoutDateText() {
|
||||||
: author;
|
: author;
|
||||||
const auto full = (_data.flags & Data::Flag::Sponsored)
|
const auto full = (_data.flags & Data::Flag::Sponsored)
|
||||||
? tr::lng_sponsored(tr::now)
|
? tr::lng_sponsored(tr::now)
|
||||||
: name + date;
|
: name.isEmpty() ? date : (name + afterAuthor);
|
||||||
_authorEditedDate.setText(
|
_authorEditedDate.setText(
|
||||||
st::msgDateTextStyle,
|
st::msgDateTextStyle,
|
||||||
full,
|
full,
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
void update(Data &&data, int availableWidth);
|
void update(Data &&data, int availableWidth);
|
||||||
|
|
||||||
[[nodiscard]] int firstLineWidth() const;
|
[[nodiscard]] int firstLineWidth() const;
|
||||||
|
[[nodiscard]] bool isWide() const;
|
||||||
[[nodiscard]] TextState textState(
|
[[nodiscard]] TextState textState(
|
||||||
not_null<const HistoryItem*> item,
|
not_null<const HistoryItem*> item,
|
||||||
QPoint position) const;
|
QPoint position) const;
|
||||||
|
|
|
@ -475,6 +475,10 @@ int Element::bottomInfoFirstLineWidth() const {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Element::bottomInfoIsWide() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Element::isHiddenByGroup() const {
|
bool Element::isHiddenByGroup() const {
|
||||||
return _flags & Flag::HiddenByGroup;
|
return _flags & Flag::HiddenByGroup;
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,6 +272,7 @@ public:
|
||||||
QString skipBlock() const;
|
QString skipBlock() const;
|
||||||
virtual int infoWidth() const;
|
virtual int infoWidth() const;
|
||||||
virtual int bottomInfoFirstLineWidth() const;
|
virtual int bottomInfoFirstLineWidth() const;
|
||||||
|
virtual bool bottomInfoIsWide() const;
|
||||||
|
|
||||||
bool isHiddenByGroup() const;
|
bool isHiddenByGroup() const;
|
||||||
virtual bool isHidden() const;
|
virtual bool isHidden() const;
|
||||||
|
|
|
@ -364,7 +364,10 @@ QSize Message::performCountOptimalSize() {
|
||||||
(st::msgPadding.left()
|
(st::msgPadding.left()
|
||||||
+ _reactions->maxWidth()
|
+ _reactions->maxWidth()
|
||||||
+ st::msgPadding.right())));
|
+ st::msgPadding.right())));
|
||||||
minHeight += st::mediaInBubbleSkip + _reactions->minHeight();
|
if (!mediaDisplayed) {
|
||||||
|
minHeight += st::mediaInBubbleSkip;
|
||||||
|
}
|
||||||
|
minHeight += _reactions->minHeight();
|
||||||
}
|
}
|
||||||
if (!mediaOnBottom) {
|
if (!mediaOnBottom) {
|
||||||
minHeight += st::msgPadding.bottom();
|
minHeight += st::msgPadding.bottom();
|
||||||
|
@ -1904,6 +1907,13 @@ int Message::bottomInfoFirstLineWidth() const {
|
||||||
return _bottomInfo.firstLineWidth();
|
return _bottomInfo.firstLineWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Message::bottomInfoIsWide() const {
|
||||||
|
if (_reactions && embedReactionsInBubble()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return _bottomInfo.isWide();
|
||||||
|
}
|
||||||
|
|
||||||
bool Message::isSignedAuthorElided() const {
|
bool Message::isSignedAuthorElided() const {
|
||||||
return _bottomInfo.isSignedAuthorElided();
|
return _bottomInfo.isSignedAuthorElided();
|
||||||
}
|
}
|
||||||
|
@ -2661,7 +2671,10 @@ int Message::resizeContentGetHeight(int newWidth) {
|
||||||
newHeight += entry->resizeGetHeight(contentWidth);
|
newHeight += entry->resizeGetHeight(contentWidth);
|
||||||
}
|
}
|
||||||
if (reactionsInBubble) {
|
if (reactionsInBubble) {
|
||||||
newHeight += st::mediaInBubbleSkip + _reactions->height();
|
if (!mediaDisplayed) {
|
||||||
|
newHeight += st::mediaInBubbleSkip;
|
||||||
|
}
|
||||||
|
newHeight += _reactions->height();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,7 @@ public:
|
||||||
const ClickHandlerPtr &handler) const override;
|
const ClickHandlerPtr &handler) const override;
|
||||||
[[nodiscard]] int infoWidth() const override;
|
[[nodiscard]] int infoWidth() const override;
|
||||||
[[nodiscard]] int bottomInfoFirstLineWidth() const override;
|
[[nodiscard]] int bottomInfoFirstLineWidth() const override;
|
||||||
|
[[nodiscard]] bool bottomInfoIsWide() const override;
|
||||||
[[nodiscard]] bool isSignedAuthorElided() const override;
|
[[nodiscard]] bool isSignedAuthorElided() const override;
|
||||||
|
|
||||||
void itemDataChanged() override;
|
void itemDataChanged() override;
|
||||||
|
|
|
@ -148,12 +148,7 @@ QSize Contact::countOptimalSize() {
|
||||||
accumulate_max(maxWidth, tleft + _name.maxWidth() + tright);
|
accumulate_max(maxWidth, tleft + _name.maxWidth() + tright);
|
||||||
accumulate_min(maxWidth, st::msgMaxWidth);
|
accumulate_min(maxWidth, st::msgMaxWidth);
|
||||||
auto minHeight = st.padding.top() + st.thumbSize + st.padding.bottom();
|
auto minHeight = st.padding.top() + st.thumbSize + st.padding.bottom();
|
||||||
const auto msgsigned = item->Get<HistoryMessageSigned>();
|
if (_parent->bottomInfoIsWide()) {
|
||||||
const auto views = item->Get<HistoryMessageViews>();
|
|
||||||
if ((msgsigned && !msgsigned->isAnonymousRank)
|
|
||||||
|| (views
|
|
||||||
&& (views->views.count >= 0 || views->replies.count > 0))
|
|
||||||
|| !item->reactions().empty()) {
|
|
||||||
minHeight += st::msgDateFont->height - st::msgDateDelta.y();
|
minHeight += st::msgDateFont->height - st::msgDateDelta.y();
|
||||||
}
|
}
|
||||||
if (!isBubbleTop()) {
|
if (!isBubbleTop()) {
|
||||||
|
|
|
@ -268,13 +268,7 @@ QSize Document::countOptimalSize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto minHeight = st.padding.top() + st.thumbSize + st.padding.bottom();
|
auto minHeight = st.padding.top() + st.thumbSize + st.padding.bottom();
|
||||||
const auto msgsigned = item->Get<HistoryMessageSigned>();
|
if (!captioned && _parent->bottomInfoIsWide()) {
|
||||||
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())) {
|
|
||||||
minHeight += st::msgDateFont->height - st::msgDateDelta.y();
|
minHeight += st::msgDateFont->height - st::msgDateDelta.y();
|
||||||
}
|
}
|
||||||
if (!isBubbleTop()) {
|
if (!isBubbleTop()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue