Show comments button for unwrapped medias.

This commit is contained in:
John Preston 2020-09-17 19:25:06 +03:00
parent 1a40f2b3ef
commit 7862443fcb
13 changed files with 159 additions and 76 deletions

View file

@ -530,6 +530,7 @@ historyFastShareLeft: 13px;
historyFastShareBottom: 5px; historyFastShareBottom: 5px;
historyFastShareIcon: icon {{ "fast_share", msgServiceFg, point(4px, 3px)}}; historyFastShareIcon: icon {{ "fast_share", msgServiceFg, point(4px, 3px)}};
historyGoToOriginalIcon: icon {{ "title_back-flip_horizontal", msgServiceFg, point(8px, 7px) }}; historyGoToOriginalIcon: icon {{ "title_back-flip_horizontal", msgServiceFg, point(8px, 7px) }};
historyFastCommentsIcon: icon {{ "history_comments", msgServiceFg }};
historySavedFont: font(semibold 14px); historySavedFont: font(semibold 14px);

View file

@ -44,6 +44,7 @@ struct HistoryMessageViews : public RuntimeComponent<HistoryMessageViews, Histor
std::vector<PeerId> recentRepliers; std::vector<PeerId> recentRepliers;
Part views; Part views;
Part replies; Part replies;
Part repliesSmall;
ChannelId commentsChannelId = 0; ChannelId commentsChannelId = 0;
MsgId commentsRootId = 0; MsgId commentsRootId = 0;
MsgId commentsReadTillId = 0; MsgId commentsReadTillId = 0;

View file

@ -1018,10 +1018,16 @@ void HistoryMessage::setupForwardedComponent(const CreateConfig &config) {
} }
void HistoryMessage::refreshMedia(const MTPMessageMedia *media) { void HistoryMessage::refreshMedia(const MTPMessageMedia *media) {
const auto was = (_media != nullptr);
_media = nullptr; _media = nullptr;
if (media) { if (media) {
setMedia(*media); setMedia(*media);
} }
if (was || _media) {
if (const auto views = Get<HistoryMessageViews>()) {
refreshRepliesText(views);
}
}
} }
void HistoryMessage::refreshSentMedia(const MTPMessageMedia *media) { void HistoryMessage::refreshSentMedia(const MTPMessageMedia *media) {
@ -1567,6 +1573,11 @@ void HistoryMessage::refreshRepliesText(
: tr::lng_comments_open_none(tr::now); : tr::lng_comments_open_none(tr::now);
views->replies.textWidth = st::semiboldFont->width( views->replies.textWidth = st::semiboldFont->width(
views->replies.text); views->replies.text);
views->repliesSmall.text = (views->replies.count > 0)
? Lang::FormatCountToShort(views->replies.count).string
: QString();
views->repliesSmall.textWidth = st::semiboldFont->width(
views->repliesSmall.text);
} else { } else {
views->replies.text = (views->replies.count > 0) views->replies.text = (views->replies.count > 0)
? Lang::FormatCountToShort(views->replies.count).string ? Lang::FormatCountToShort(views->replies.count).string

View file

@ -599,8 +599,8 @@ bool Element::displayFastReply() const {
return false; return false;
} }
bool Element::displayRightAction() const { std::optional<QSize> Element::rightActionSize() const {
return false; return std::nullopt;
} }
void Element::drawRightAction( void Element::drawRightAction(

View file

@ -262,7 +262,7 @@ public:
virtual bool hasBubble() const; virtual bool hasBubble() const;
virtual bool hasFastReply() const; virtual bool hasFastReply() const;
virtual bool displayFastReply() const; virtual bool displayFastReply() const;
virtual bool displayRightAction() const; virtual std::optional<QSize> rightActionSize() const;
virtual void drawRightAction( virtual void drawRightAction(
Painter &p, Painter &p,
int left, int left,

View file

@ -201,6 +201,10 @@ struct Message::CommentsButton {
QImage cachedUserpics; QImage cachedUserpics;
ClickHandlerPtr link; ClickHandlerPtr link;
QPoint lastPoint; QPoint lastPoint;
QString rightActionCountString;
int rightActionCount = 0;
int rightActionCountWidth = 0;
}; };
LogEntryOriginal::LogEntryOriginal() = default; LogEntryOriginal::LogEntryOriginal() = default;
@ -611,13 +615,13 @@ void Message::draw(
p.setOpacity(o); p.setOpacity(o);
} }
} }
if (displayRightAction()) { if (const auto size = rightActionSize()) {
const auto fastShareSkip = std::clamp( const auto fastShareSkip = std::clamp(
(gBubble.height() - st::historyFastShareSize) / 2, (gBubble.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 - st::historyFastShareSize; const auto fastShareTop = g.top() + gBubble.height() - fastShareSkip - size->height();
drawRightAction(p, fastShareLeft, fastShareTop, width()); drawRightAction(p, fastShareLeft, fastShareTop, width());
} }
@ -1227,18 +1231,18 @@ TextState Message::textState(
} }
} }
checkForPointInTime(); checkForPointInTime();
if (displayRightAction()) { if (const auto size = rightActionSize()) {
const auto fastShareSkip = snap( const auto fastShareSkip = snap(
(gBubble.height() - st::historyFastShareSize) / 2, (gBubble.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 - st::historyFastShareSize; const auto fastShareTop = g.top() + gBubble.height() - fastShareSkip - size->height();
if (QRect( if (QRect(
fastShareLeft, fastShareLeft,
fastShareTop, fastShareTop,
st::historyFastShareSize, size->width(),
st::historyFastShareSize size->height()
).contains(point)) { ).contains(point)) {
result.link = rightActionLink(); result.link = rightActionLink();
} }
@ -1276,16 +1280,7 @@ bool Message::getStateCommentsButton(
return false; return false;
} }
if (!_comments->link && data()->repliesAreComments()) { if (!_comments->link && data()->repliesAreComments()) {
const auto fullId = data()->fullId(); _comments->link = createGoToCommentsLink();
_comments->link = std::make_shared<LambdaClickHandler>([=] {
if (const auto window = App::wnd()) {
if (const auto controller = window->sessionController()) {
if (const auto item = controller->session().data().message(fullId)) {
controller->showRepliesForMessage(item->history(), item->id);
}
}
}
});
} else if (!_comments->link && data()->externalReply()) { } else if (!_comments->link && data()->externalReply()) {
_comments->link = rightActionLink(); _comments->link = rightActionLink();
} }
@ -1294,6 +1289,19 @@ bool Message::getStateCommentsButton(
return true; return true;
} }
ClickHandlerPtr Message::createGoToCommentsLink() const {
const auto fullId = data()->fullId();
return std::make_shared<LambdaClickHandler>([=] {
if (const auto window = App::wnd()) {
if (const auto controller = window->sessionController()) {
if (const auto item = controller->session().data().message(fullId)) {
controller->showRepliesForMessage(item->history(), item->id);
}
}
}
});
}
bool Message::getStateFromName( bool Message::getStateFromName(
QPoint point, QPoint point,
QRect &trect, QRect &trect,
@ -2017,8 +2025,28 @@ bool Message::displayFastReply() const {
&& !delegate()->elementInSelectionMode(); && !delegate()->elementInSelectionMode();
} }
bool Message::displayRightAction() const { bool Message::displayRightActionComments() const {
return displayFastShare() || displayGoToOriginal(); return data()->repliesAreComments()
&& media()
&& media()->isDisplayed()
&& media()->customInfoLayout();
}
std::optional<QSize> Message::rightActionSize() const {
if (displayRightActionComments()) {
const auto views = data()->Get<HistoryMessageViews>();
Assert(views != nullptr);
return (views->repliesSmall.textWidth > 0)
? QSize(
std::max(
st::historyFastShareSize,
2 * st::historyFastShareBottom + views->repliesSmall.textWidth),
st::historyFastShareSize + st::historyFastShareBottom + st::semiboldFont->height)
: QSize(st::historyFastShareSize, st::historyFastShareSize);
}
return (displayFastShare() || displayGoToOriginal())
? QSize(st::historyFastShareSize, st::historyFastShareSize)
: std::optional<QSize>();
} }
bool Message::displayFastShare() const { bool Message::displayFastShare() const {
@ -2060,18 +2088,44 @@ void Message::drawRightAction(
int left, int left,
int top, int top,
int outerWidth) const { int outerWidth) const {
const auto size = rightActionSize();
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
p.setBrush(st::msgServiceBg); p.setBrush(st::msgServiceBg);
{ {
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
p.drawEllipse(style::rtlrect( const auto rect = style::rtlrect(
left, left,
top, top,
st::historyFastShareSize, size->width(),
st::historyFastShareSize, size->height(),
outerWidth)); outerWidth);
const auto usual = st::historyFastShareSize;
if (size->width() == size->height() && size->width() == usual) {
p.drawEllipse(rect);
} else {
p.drawRoundedRect(rect, usual / 2, usual / 2);
}
} }
if (displayFastShare()) { if (displayRightActionComments()) {
const auto &icon = st::historyFastCommentsIcon;
icon.paint(
p,
left + (size->width() - icon.width()) / 2,
top + (st::historyFastShareSize - icon.height()) / 2,
outerWidth);
const auto views = data()->Get<HistoryMessageViews>();
Assert(views != nullptr);
if (views->repliesSmall.textWidth > 0) {
p.setPen(st::msgServiceFg);
p.setFont(st::semiboldFont);
p.drawTextLeft(
left + (size->width() - views->repliesSmall.textWidth) / 2,
top + st::historyFastShareSize,
outerWidth,
views->repliesSmall.text,
views->repliesSmall.textWidth);
}
} else if (displayFastShare()) {
st::historyFastShareIcon.paint(p, left, top, outerWidth); st::historyFastShareIcon.paint(p, left, top, outerWidth);
} else { } else {
st::historyGoToOriginalIcon.paint(p, left, top, outerWidth); st::historyGoToOriginalIcon.paint(p, left, top, outerWidth);
@ -2080,6 +2134,10 @@ void Message::drawRightAction(
ClickHandlerPtr Message::rightActionLink() const { ClickHandlerPtr Message::rightActionLink() const {
if (!_rightActionLink) { if (!_rightActionLink) {
if (displayRightActionComments()) {
_rightActionLink = createGoToCommentsLink();
return _rightActionLink;
}
const auto owner = &data()->history()->owner(); const auto owner = &data()->history()->owner();
const auto itemId = data()->fullId(); const auto itemId = data()->fullId();
const auto forwarded = data()->Get<HistoryMessageForwarded>(); const auto forwarded = data()->Get<HistoryMessageForwarded>();
@ -2231,8 +2289,8 @@ QRect Message::countGeometry() const {
auto contentWidth = availableWidth; auto contentWidth = availableWidth;
if (hasFromPhoto()) { if (hasFromPhoto()) {
contentLeft += st::msgPhotoSkip; contentLeft += st::msgPhotoSkip;
if (displayRightAction()) { if (const auto size = rightActionSize()) {
contentWidth -= st::msgPhotoSkip; contentWidth -= size->width() + (st::msgPhotoSkip - st::historyFastShareSize);
} }
//} else if (!Adaptive::Wide() && !out() && !fromChannel() && st::msgPhotoSkip - (hmaxwidth - hwidth) > 0) { //} else if (!Adaptive::Wide() && !out() && !fromChannel() && st::msgPhotoSkip - (hmaxwidth - hwidth) > 0) {
// contentLeft += st::msgPhotoSkip - (hmaxwidth - hwidth); // contentLeft += st::msgPhotoSkip - (hmaxwidth - hwidth);
@ -2276,8 +2334,10 @@ int Message::resizeContentGetHeight(int newWidth) {
// This code duplicates countGeometry() but also resizes media. // This code duplicates countGeometry() but also resizes media.
auto contentWidth = newWidth - (st::msgMargin.left() + st::msgMargin.right()); auto contentWidth = newWidth - (st::msgMargin.left() + st::msgMargin.right());
if (hasFromPhoto() && displayRightAction()) { if (hasFromPhoto()) {
contentWidth -= st::msgPhotoSkip; if (const auto size = rightActionSize()) {
contentWidth -= size->width() + (st::msgPhotoSkip - st::historyFastShareSize);
}
} }
accumulate_min(contentWidth, maxWidth()); accumulate_min(contentWidth, maxWidth());
_bubbleWidthLimit = std::max(st::msgMaxWidth, monospaceMaxWidth()); _bubbleWidthLimit = std::max(st::msgMaxWidth, monospaceMaxWidth());

View file

@ -93,7 +93,8 @@ public:
bool hasBubble() const override; bool hasBubble() const override;
bool hasFastReply() const override; bool hasFastReply() const override;
bool displayFastReply() const override; bool displayFastReply() const override;
bool displayRightAction() const override; bool displayRightActionComments() const;
std::optional<QSize> rightActionSize() const override;
void drawRightAction( void drawRightAction(
Painter &p, Painter &p,
int left, int left,
@ -186,6 +187,7 @@ private:
WebPage *logEntryOriginal() const; WebPage *logEntryOriginal() const;
[[nodiscard]] ClickHandlerPtr createGoToCommentsLink() const;
[[nodiscard]] ClickHandlerPtr psaTooltipLink() const; [[nodiscard]] ClickHandlerPtr psaTooltipLink() const;
void psaTooltipToggled(bool shown) const; void psaTooltipToggled(bool shown) const;

View file

@ -632,11 +632,11 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms
if (isRound || needInfoDisplay()) { if (isRound || needInfoDisplay()) {
_parent->drawInfo(p, fullRight, fullBottom, 2 * paintx + paintw, selected, isRound ? InfoDisplayType::Background : InfoDisplayType::Image); _parent->drawInfo(p, fullRight, fullBottom, 2 * paintx + paintw, selected, isRound ? InfoDisplayType::Background : InfoDisplayType::Image);
} }
if (!bubble && _parent->displayRightAction()) { if (const auto size = bubble ? std::nullopt : _parent->rightActionSize()) {
auto fastShareLeft = (fullRight + st::historyFastShareLeft); auto fastShareLeft = (fullRight + st::historyFastShareLeft);
auto fastShareTop = (fullBottom - st::historyFastShareBottom - st::historyFastShareSize); auto fastShareTop = (fullBottom - st::historyFastShareBottom - size->height());
if (fastShareLeft + st::historyFastShareSize > maxRight) { if (fastShareLeft + size->width() > maxRight) {
fastShareLeft = (fullRight - st::historyFastShareSize - st::msgDateImgDelta); fastShareLeft = (fullRight - size->width() - st::msgDateImgDelta);
fastShareTop -= (st::msgDateImgDelta + st::msgDateImgPadding.y() + st::msgDateFont->height + st::msgDateImgPadding.y()); fastShareTop -= (st::msgDateImgDelta + st::msgDateImgPadding.y() + st::msgDateFont->height + st::msgDateImgPadding.y());
} }
_parent->drawRightAction(p, fastShareLeft, fastShareTop, 2 * paintx + paintw); _parent->drawRightAction(p, fastShareLeft, fastShareTop, 2 * paintx + paintw);
@ -860,14 +860,14 @@ TextState Gif::textState(QPoint point, StateRequest request) const {
result.cursor = CursorState::Date; result.cursor = CursorState::Date;
} }
} }
if (!bubble && _parent->displayRightAction()) { if (const auto size = bubble ? std::nullopt : _parent->rightActionSize()) {
auto fastShareLeft = (fullRight + st::historyFastShareLeft); auto fastShareLeft = (fullRight + st::historyFastShareLeft);
auto fastShareTop = (fullBottom - st::historyFastShareBottom - st::historyFastShareSize); auto fastShareTop = (fullBottom - st::historyFastShareBottom - size->height());
if (fastShareLeft + st::historyFastShareSize > maxRight) { if (fastShareLeft + size->width() > maxRight) {
fastShareLeft = (fullRight - st::historyFastShareSize - st::msgDateImgDelta); fastShareLeft = (fullRight - size->width() - st::msgDateImgDelta);
fastShareTop -= st::msgDateImgDelta + st::msgDateImgPadding.y() + st::msgDateFont->height + st::msgDateImgPadding.y(); fastShareTop -= st::msgDateImgDelta + st::msgDateImgPadding.y() + st::msgDateFont->height + st::msgDateImgPadding.y();
} }
if (QRect(fastShareLeft, fastShareTop, st::historyFastShareSize, st::historyFastShareSize).contains(point)) { if (QRect(fastShareLeft, fastShareTop, size->width(), size->height()).contains(point)) {
result.link = _parent->rightActionLink(); result.link = _parent->rightActionLink();
} }
} }

View file

@ -210,9 +210,9 @@ void Location::draw(Painter &p, const QRect &r, TextSelection selection, crl::ti
auto fullRight = paintx + paintw; auto fullRight = paintx + paintw;
auto fullBottom = height(); auto fullBottom = height();
_parent->drawInfo(p, fullRight, fullBottom, paintx * 2 + paintw, selected, InfoDisplayType::Image); _parent->drawInfo(p, fullRight, fullBottom, paintx * 2 + paintw, selected, InfoDisplayType::Image);
if (!bubble && _parent->displayRightAction()) { if (const auto size = bubble ? std::nullopt : _parent->rightActionSize()) {
auto fastShareLeft = (fullRight + st::historyFastShareLeft); auto fastShareLeft = (fullRight + st::historyFastShareLeft);
auto fastShareTop = (fullBottom - st::historyFastShareBottom - st::historyFastShareSize); auto fastShareTop = (fullBottom - st::historyFastShareBottom - size->height());
_parent->drawRightAction(p, fastShareLeft, fastShareTop, 2 * paintx + paintw); _parent->drawRightAction(p, fastShareLeft, fastShareTop, 2 * paintx + paintw);
} }
} }
@ -278,10 +278,10 @@ TextState Location::textState(QPoint point, StateRequest request) const {
if (_parent->pointInTime(fullRight, fullBottom, point, InfoDisplayType::Image)) { if (_parent->pointInTime(fullRight, fullBottom, point, InfoDisplayType::Image)) {
result.cursor = CursorState::Date; result.cursor = CursorState::Date;
} }
if (!bubble && _parent->displayRightAction()) { if (const auto size = bubble ? std::nullopt : _parent->rightActionSize()) {
auto fastShareLeft = (fullRight + st::historyFastShareLeft); auto fastShareLeft = (fullRight + st::historyFastShareLeft);
auto fastShareTop = (fullBottom - st::historyFastShareBottom - st::historyFastShareSize); auto fastShareTop = (fullBottom - st::historyFastShareBottom - size->height());
if (QRect(fastShareLeft, fastShareTop, st::historyFastShareSize, st::historyFastShareSize).contains(point)) { if (QRect(fastShareLeft, fastShareTop, size->width(), size->height()).contains(point)) {
result.link = _parent->rightActionLink(); result.link = _parent->rightActionLink();
} }
} }

View file

@ -216,9 +216,9 @@ void GroupedMedia::draw(
if (needInfoDisplay()) { if (needInfoDisplay()) {
_parent->drawInfo(p, fullRight, fullBottom, width(), selected, InfoDisplayType::Image); _parent->drawInfo(p, fullRight, fullBottom, width(), selected, InfoDisplayType::Image);
} }
if (!_parent->hasBubble() && _parent->displayRightAction()) { if (const auto size = _parent->hasBubble() ? std::nullopt : _parent->rightActionSize()) {
auto fastShareLeft = (fullRight + st::historyFastShareLeft); auto fastShareLeft = (fullRight + st::historyFastShareLeft);
auto fastShareTop = (fullBottom - st::historyFastShareBottom - st::historyFastShareSize); auto fastShareTop = (fullBottom - st::historyFastShareBottom - size->height());
_parent->drawRightAction(p, fastShareLeft, fastShareTop, width()); _parent->drawRightAction(p, fastShareLeft, fastShareTop, width());
} }
} }
@ -272,10 +272,10 @@ TextState GroupedMedia::textState(QPoint point, StateRequest request) const {
if (_parent->pointInTime(fullRight, fullBottom, point, InfoDisplayType::Image)) { if (_parent->pointInTime(fullRight, fullBottom, point, InfoDisplayType::Image)) {
result.cursor = CursorState::Date; result.cursor = CursorState::Date;
} }
if (!_parent->hasBubble() && _parent->displayRightAction()) { if (const auto size = _parent->hasBubble() ? std::nullopt : _parent->rightActionSize()) {
auto fastShareLeft = (fullRight + st::historyFastShareLeft); auto fastShareLeft = (fullRight + st::historyFastShareLeft);
auto fastShareTop = (fullBottom - st::historyFastShareBottom - st::historyFastShareSize); auto fastShareTop = (fullBottom - st::historyFastShareBottom - size->height());
if (QRect(fastShareLeft, fastShareTop, st::historyFastShareSize, st::historyFastShareSize).contains(point)) { if (QRect(fastShareLeft, fastShareTop, size->width(), size->height()).contains(point)) {
result.link = _parent->rightActionLink(); result.link = _parent->rightActionLink();
} }
} }

View file

@ -66,6 +66,11 @@ QSize UnwrappedMedia::countOptimalSize() {
+ infoHeight; + infoHeight;
minHeight = std::max(minHeight, minimal); minHeight = std::max(minHeight, minimal);
} }
if (const auto size = _parent->rightActionSize()) {
minHeight = std::max(
minHeight,
st::historyFastShareBottom + size->height());
}
} }
return { maxWidth, minHeight }; return { maxWidth, minHeight };
} }
@ -181,7 +186,7 @@ void UnwrappedMedia::drawSurrounding(
const HistoryMessageReply *reply, const HistoryMessageReply *reply,
const HistoryMessageForwarded *forwarded) const { const HistoryMessageForwarded *forwarded) const {
const auto rightAligned = _parent->hasOutLayout() && !Core::App().settings().chatWide(); const auto rightAligned = _parent->hasOutLayout() && !Core::App().settings().chatWide();
const auto rightAction = _parent->displayRightAction(); const auto rightActionSize = _parent->rightActionSize();
const auto fullRight = calculateFullRight(inner); const auto fullRight = calculateFullRight(inner);
auto fullBottom = height(); auto fullBottom = height();
if (needInfoDisplay()) { if (needInfoDisplay()) {
@ -224,11 +229,12 @@ void UnwrappedMedia::drawSurrounding(
} }
replyRight = rectx + rectw; replyRight = rectx + rectw;
} }
if (rightAction) { if (rightActionSize) {
const auto position = calculateFastActionPosition( const auto position = calculateFastActionPosition(
fullBottom, fullBottom,
replyRight, replyRight,
fullRight); fullRight,
*rightActionSize);
const auto outer = 2 * inner.x() + inner.width(); const auto outer = 2 * inner.x() + inner.width();
_parent->drawRightAction(p, position.x(), position.y(), outer); _parent->drawRightAction(p, position.x(), position.y(), outer);
} }
@ -355,18 +361,18 @@ TextState UnwrappedMedia::textState(QPoint point, StateRequest request) const {
replyRight = rectx + rectw - st::msgReplyPadding.right(); replyRight = rectx + rectw - st::msgReplyPadding.right();
} }
const auto fullRight = calculateFullRight(inner); const auto fullRight = calculateFullRight(inner);
const auto rightAction = _parent->displayRightAction(); const auto rightActionSize = _parent->rightActionSize();
auto fullBottom = height(); auto fullBottom = height();
if (_parent->pointInTime(fullRight, fullBottom, point, InfoDisplayType::Background)) { if (_parent->pointInTime(fullRight, fullBottom, point, InfoDisplayType::Background)) {
result.cursor = CursorState::Date; result.cursor = CursorState::Date;
} }
if (rightAction) { if (rightActionSize) {
const auto size = st::historyFastShareSize;
const auto position = calculateFastActionPosition( const auto position = calculateFastActionPosition(
fullBottom, fullBottom,
replyRight, replyRight,
fullRight); fullRight,
if (QRect(position.x(), position.y(), size, size).contains(point)) { *rightActionSize);
if (QRect(position.x(), position.y(), rightActionSize->width(), rightActionSize->height()).contains(point)) {
result.link = _parent->rightActionLink(); result.link = _parent->rightActionLink();
return result; return result;
} }
@ -396,9 +402,10 @@ int UnwrappedMedia::calculateFullRight(const QRect &inner) const {
const auto infoWidth = _parent->infoWidth() const auto infoWidth = _parent->infoWidth()
+ st::msgDateImgPadding.x() * 2 + st::msgDateImgPadding.x() * 2
+ st::msgReplyPadding.left(); + st::msgReplyPadding.left();
const auto rightActionWidth = _parent->displayRightAction() const auto rightActionSize = _parent->rightActionSize();
const auto rightActionWidth = rightActionSize
? (st::historyFastShareLeft * 2 ? (st::historyFastShareLeft * 2
+ st::historyFastShareSize + rightActionSize->width()
+ st::msgPadding.left() + st::msgPadding.left()
+ (_parent->hasFromPhoto() + (_parent->hasFromPhoto()
? st::msgMargin.right() ? st::msgMargin.right()
@ -414,13 +421,13 @@ int UnwrappedMedia::calculateFullRight(const QRect &inner) const {
} }
QPoint UnwrappedMedia::calculateFastActionPosition( QPoint UnwrappedMedia::calculateFastActionPosition(
int fullBottom, int fullBottom,
int replyRight, int replyRight,
int fullRight) const { int fullRight,
const auto size = st::historyFastShareSize; QSize size) const {
const auto fastShareTop = (fullBottom const auto fastShareTop = (fullBottom
- st::historyFastShareBottom - st::historyFastShareBottom
- size); - size.height());
const auto doesRightActionHitReply = replyRight && (fastShareTop < const auto doesRightActionHitReply = replyRight && (fastShareTop <
st::msgReplyBarSize.height() st::msgReplyBarSize.height()
+ st::msgReplyPadding.top() + st::msgReplyPadding.top()
@ -434,7 +441,7 @@ QPoint UnwrappedMedia::calculateFastActionPosition(
bool UnwrappedMedia::needInfoDisplay() const { bool UnwrappedMedia::needInfoDisplay() const {
return (_parent->data()->id < 0) return (_parent->data()->id < 0)
|| (_parent->isUnderCursor()) || (_parent->isUnderCursor())
|| (_parent->displayRightAction()) || (_parent->rightActionSize())
|| (_parent->isLastAndSelfMessage()) || (_parent->isLastAndSelfMessage())
|| (_parent->hasOutLayout() || (_parent->hasOutLayout()
&& !Core::App().settings().chatWide() && !Core::App().settings().chatWide()

View file

@ -130,11 +130,12 @@ private:
const HistoryMessageReply *reply, const HistoryMessageReply *reply,
const HistoryMessageForwarded *forwarded) const; const HistoryMessageForwarded *forwarded) const;
inline int calculateFullRight(const QRect &inner) const; int calculateFullRight(const QRect &inner) const;
inline QPoint calculateFastActionPosition( QPoint calculateFastActionPosition(
int fullBottom, int fullBottom,
int replyRight, int replyRight,
int fullRight) const; int fullRight,
QSize size) const;
const HistoryMessageForwarded *getDisplayedForwardedInfo() const; const HistoryMessageForwarded *getDisplayedForwardedInfo() const;

View file

@ -322,9 +322,9 @@ void Photo::draw(Painter &p, const QRect &r, TextSelection selection, crl::time
if (needInfoDisplay()) { if (needInfoDisplay()) {
_parent->drawInfo(p, fullRight, fullBottom, 2 * paintx + paintw, selected, InfoDisplayType::Image); _parent->drawInfo(p, fullRight, fullBottom, 2 * paintx + paintw, selected, InfoDisplayType::Image);
} }
if (!bubble && _parent->displayRightAction()) { if (const auto size = bubble ? std::nullopt : _parent->rightActionSize()) {
auto fastShareLeft = (fullRight + st::historyFastShareLeft); auto fastShareLeft = (fullRight + st::historyFastShareLeft);
auto fastShareTop = (fullBottom - st::historyFastShareBottom - st::historyFastShareSize); auto fastShareTop = (fullBottom - st::historyFastShareBottom - size->height());
_parent->drawRightAction(p, fastShareLeft, fastShareTop, 2 * paintx + paintw); _parent->drawRightAction(p, fastShareLeft, fastShareTop, 2 * paintx + paintw);
} }
} }
@ -450,10 +450,10 @@ TextState Photo::textState(QPoint point, StateRequest request) const {
if (_parent->pointInTime(fullRight, fullBottom, point, InfoDisplayType::Image)) { if (_parent->pointInTime(fullRight, fullBottom, point, InfoDisplayType::Image)) {
result.cursor = CursorState::Date; result.cursor = CursorState::Date;
} }
if (!bubble && _parent->displayRightAction()) { if (const auto size = bubble ? std::nullopt : _parent->rightActionSize()) {
auto fastShareLeft = (fullRight + st::historyFastShareLeft); auto fastShareLeft = (fullRight + st::historyFastShareLeft);
auto fastShareTop = (fullBottom - st::historyFastShareBottom - st::historyFastShareSize); auto fastShareTop = (fullBottom - st::historyFastShareBottom - size->height());
if (QRect(fastShareLeft, fastShareTop, st::historyFastShareSize, st::historyFastShareSize).contains(point)) { if (QRect(fastShareLeft, fastShareTop, size->width(), size->height()).contains(point)) {
result.link = _parent->rightActionLink(); result.link = _parent->rightActionLink();
} }
} }