Fix comments button getState / remove.

This commit is contained in:
John Preston 2020-10-05 16:20:55 +03:00
parent a33ca97298
commit 473803edb8
2 changed files with 24 additions and 19 deletions

View file

@ -1299,6 +1299,11 @@ void HistoryMessage::applyEdition(const MTPDmessage &message) {
setViewsCount(message.vviews().value_or(-1)); setViewsCount(message.vviews().value_or(-1));
setForwardsCount(message.vforwards().value_or(-1)); setForwardsCount(message.vforwards().value_or(-1));
setText(_media ? textWithEntities : EnsureNonEmpty(textWithEntities)); setText(_media ? textWithEntities : EnsureNonEmpty(textWithEntities));
if (const auto replies = message.vreplies()) {
setReplies(*replies);
} else {
clearReplies();
}
finishEdition(keyboardTop); finishEdition(keyboardTop);
} }

View file

@ -543,14 +543,14 @@ void Message::draw(
auto displayTail = skipTail ? RectPart::None : (outbg && !Core::App().settings().chatWide()) ? RectPart::Right : RectPart::Left; auto displayTail = skipTail ? RectPart::None : (outbg && !Core::App().settings().chatWide()) ? RectPart::Right : RectPart::Left;
PaintBubble(p, g, width(), selected, outbg, displayTail); PaintBubble(p, g, width(), selected, outbg, displayTail);
const auto gBubble = g; auto inner = g;
paintCommentsButton(p, g, selected); paintCommentsButton(p, inner, selected);
// Entry page is always a bubble bottom. // Entry page is always a bubble bottom.
auto mediaOnBottom = (mediaDisplayed && media->isBubbleBottom()) || (entry/* && entry->isBubbleBottom()*/); auto mediaOnBottom = (mediaDisplayed && media->isBubbleBottom()) || (entry/* && entry->isBubbleBottom()*/);
auto mediaOnTop = (mediaDisplayed && media->isBubbleTop()) || (entry && entry->isBubbleTop()); auto mediaOnTop = (mediaDisplayed && media->isBubbleTop()) || (entry && entry->isBubbleTop());
auto trect = g.marginsRemoved(st::msgPadding); auto trect = inner.marginsRemoved(st::msgPadding);
if (mediaOnBottom) { if (mediaOnBottom) {
trect.setHeight(trect.height() + st::msgPadding.bottom()); trect.setHeight(trect.height() + st::msgPadding.bottom());
} }
@ -568,7 +568,7 @@ void Message::draw(
paintText(p, trect, selection); paintText(p, trect, selection);
if (mediaDisplayed) { if (mediaDisplayed) {
auto mediaHeight = media->height(); auto mediaHeight = media->height();
auto mediaLeft = g.left(); auto mediaLeft = inner.left();
auto mediaTop = (trect.y() + trect.height() - mediaHeight); auto mediaTop = (trect.y() + trect.height() - mediaHeight);
p.translate(mediaLeft, mediaTop); p.translate(mediaLeft, mediaTop);
@ -576,7 +576,7 @@ void Message::draw(
p.translate(-mediaLeft, -mediaTop); p.translate(-mediaLeft, -mediaTop);
} }
if (entry) { if (entry) {
auto entryLeft = g.left(); auto entryLeft = inner.left();
auto entryTop = trect.y() + trect.height(); auto entryTop = trect.y() + trect.height();
p.translate(entryLeft, entryTop); p.translate(entryLeft, entryTop);
auto entrySelection = skipTextSelection(selection); auto entrySelection = skipTextSelection(selection);
@ -592,29 +592,29 @@ void Message::draw(
? !media->customInfoLayout() ? !media->customInfoLayout()
: true); : true);
if (needDrawInfo) { if (needDrawInfo) {
drawInfo(p, g.left() + g.width(), g.top() + g.height(), 2 * g.left() + g.width(), selected, InfoDisplayType::Default); drawInfo(p, inner.left() + inner.width(), inner.top() + inner.height(), 2 * inner.left() + inner.width(), selected, InfoDisplayType::Default);
if (g != gBubble) { if (g != inner) {
const auto o = p.opacity(); const auto o = p.opacity();
p.setOpacity(0.3); p.setOpacity(0.3);
const auto color = selected const auto color = selected
? (outbg ? st::msgOutDateFgSelected : st::msgInDateFgSelected) ? (outbg ? st::msgOutDateFgSelected : st::msgInDateFgSelected)
: (outbg ? st::msgOutDateFg : st::msgInDateFg); : (outbg ? st::msgOutDateFg : st::msgInDateFg);
p.fillRect(g.left(), g.top() + g.height() - st::lineWidth, g.width(), st::lineWidth, color); p.fillRect(inner.left(), inner.top() + inner.height() - st::lineWidth, inner.width(), st::lineWidth, color);
p.setOpacity(o); p.setOpacity(o);
} }
} }
if (const auto size = rightActionSize()) { if (const auto size = rightActionSize()) {
const auto fastShareSkip = std::clamp( const auto fastShareSkip = std::clamp(
(gBubble.height() - size->height()) / 2, (g.height() - size->height()) / 2,
0, 0,
st::historyFastShareBottom); st::historyFastShareBottom);
const auto fastShareLeft = g.left() + g.width() + st::historyFastShareLeft; const auto fastShareLeft = g.left() + g.width() + st::historyFastShareLeft;
const auto fastShareTop = g.top() + gBubble.height() - fastShareSkip - size->height(); const auto fastShareTop = g.top() + g.height() - fastShareSkip - size->height();
drawRightAction(p, fastShareLeft, fastShareTop, width()); drawRightAction(p, fastShareLeft, fastShareTop, width());
} }
if (media) { if (media) {
media->paintBubbleFireworks(p, gBubble, ms); media->paintBubbleFireworks(p, g, ms);
} }
} else if (media && media->isDisplayed()) { } else if (media && media->isDisplayed()) {
p.translate(g.topLeft()); p.translate(g.topLeft());
@ -1149,12 +1149,12 @@ TextState Message::textState(
auto mediaOnBottom = (mediaDisplayed && media->isBubbleBottom()) || (entry/* && entry->isBubbleBottom()*/); auto mediaOnBottom = (mediaDisplayed && media->isBubbleBottom()) || (entry/* && entry->isBubbleBottom()*/);
auto mediaOnTop = (mediaDisplayed && media->isBubbleTop()) || (entry && entry->isBubbleTop()); auto mediaOnTop = (mediaDisplayed && media->isBubbleTop()) || (entry && entry->isBubbleTop());
const auto gBubble = g; auto bubble = g;
if (getStateCommentsButton(point, g, &result)) { if (getStateCommentsButton(point, bubble, &result)) {
return result; return result;
} }
auto trect = g.marginsRemoved(st::msgPadding); auto trect = bubble.marginsRemoved(st::msgPadding);
if (mediaOnBottom) { if (mediaOnBottom) {
trect.setHeight(trect.height() + st::msgPadding.bottom()); trect.setHeight(trect.height() + st::msgPadding.bottom());
} }
@ -1177,7 +1177,7 @@ TextState Message::textState(
if (entry) { if (entry) {
auto entryHeight = entry->height(); auto entryHeight = entry->height();
trect.setHeight(trect.height() - entryHeight); trect.setHeight(trect.height() - entryHeight);
auto entryLeft = g.left(); auto entryLeft = bubble.left();
auto entryTop = trect.y() + trect.height(); auto entryTop = trect.y() + trect.height();
if (point.y() >= entryTop && point.y() < entryTop + entryHeight) { if (point.y() >= entryTop && point.y() < entryTop + entryHeight) {
result = entry->textState( result = entry->textState(
@ -1192,8 +1192,8 @@ TextState Message::textState(
return; return;
} }
const auto inDate = pointInTime( const auto inDate = pointInTime(
g.left() + g.width(), bubble.left() + bubble.width(),
g.top() + g.height(), bubble.top() + bubble.height(),
point, point,
InfoDisplayType::Default); InfoDisplayType::Default);
if (inDate) { if (inDate) {
@ -1225,11 +1225,11 @@ TextState Message::textState(
checkForPointInTime(); checkForPointInTime();
if (const auto size = rightActionSize()) { if (const auto size = rightActionSize()) {
const auto fastShareSkip = snap( const auto fastShareSkip = snap(
(gBubble.height() - size->height()) / 2, (g.height() - size->height()) / 2,
0, 0,
st::historyFastShareBottom); st::historyFastShareBottom);
const auto fastShareLeft = g.left() + g.width() + st::historyFastShareLeft; const auto fastShareLeft = g.left() + g.width() + st::historyFastShareLeft;
const auto fastShareTop = g.top() + gBubble.height() - fastShareSkip - size->height(); const auto fastShareTop = g.top() + g.height() - fastShareSkip - size->height();
if (QRect( if (QRect(
fastShareLeft, fastShareLeft,
fastShareTop, fastShareTop,