From f5486e309011e034ce58b75c737605c00d6cb022 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 31 Mar 2026 14:22:56 +0300 Subject: [PATCH] Moved location venue text below map thumbnail to match mobile. --- .../view/media/history_view_location.cpp | 81 ++++++------------- .../view/media/history_view_location.h | 7 +- 2 files changed, 29 insertions(+), 59 deletions(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_location.cpp b/Telegram/SourceFiles/history/view/media/history_view_location.cpp index 94c877f672..20e20a40b3 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_location.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_location.cpp @@ -285,14 +285,8 @@ QSize Location::countOptimalSize() { } if (!_title.isEmpty() || !_description.isEmpty()) { minHeight += st::mediaInBubbleSkip; - if (_live) { - if (isBubbleBottom()) { - minHeight += st::msgPadding.bottom(); - } - } else { - if (isBubbleTop()) { - minHeight += st::msgPadding.top(); - } + if (isBubbleBottom()) { + minHeight += st::msgPadding.bottom(); } } } @@ -320,6 +314,7 @@ QSize Location::countCurrentSize(int newWidth) { std::min(newWidth, st::maxMediaSize)); accumulate_max(newWidth, minWidth); accumulate_max(newHeight, st::minPhotoSize); + _thumbnailHeight = newHeight; if (_live) { _live->thumbnailHeight = newHeight; } @@ -332,14 +327,8 @@ QSize Location::countCurrentSize(int newWidth) { } if (!_title.isEmpty() || !_description.isEmpty()) { newHeight += st::mediaInBubbleSkip; - if (_live) { - if (isBubbleBottom()) { - newHeight += st::msgPadding.bottom(); - } - } else { - if (isBubbleTop()) { - newHeight += st::msgPadding.top(); - } + if (isBubbleBottom()) { + newHeight += st::msgPadding.bottom(); } } } @@ -366,19 +355,14 @@ void Location::draw(Painter &p, const PaintContext &context) const { const auto stm = context.messageStyle(); const auto hasText = !_title.isEmpty() || !_description.isEmpty(); - const auto rounding = adjustedBubbleRounding(_live + const auto rounding = adjustedBubbleRounding(hasText ? RectPart::FullBottom - : hasText - ? RectPart::FullTop : RectPart()); const auto paintText = [&] { - if (_live) { - painty += st::mediaInBubbleSkip; - } else if (!hasText) { + if (!hasText && !_live) { return; - } else if (isBubbleTop()) { - painty += st::msgPadding.top(); } + painty += st::mediaInBubbleSkip; auto textw = width() - st::msgPadding.left() - st::msgPadding.right(); @@ -394,15 +378,8 @@ void Location::draw(Painter &p, const PaintContext &context) const { _description.drawLeftElided(p, paintx + st::msgPadding.left(), painty, textw, width(), 3, style::al_left, 0, -1, 0, false, toDescriptionSelection(context.selection)); painty += qMin(_description.countHeight(textw), 3 * st::webPageDescriptionFont->height); } - if (!_live) { - painty += st::mediaInBubbleSkip; - painth -= painty; - } }; - if (!_live) { - paintText(); - } - const auto thumbh = _live ? _live->thumbnailHeight : painth; + const auto thumbh = _thumbnailHeight; auto rthumb = QRect(paintx, painty, paintw, thumbh); if (!bubble) { fillImageShadow(p, rthumb, rounding, context); @@ -452,12 +429,13 @@ void Location::draw(Painter &p, const PaintContext &context) const { if (context.selected()) { fillImageOverlay(p, rthumb, rounding, context); } + painty += thumbh; if (_live) { - painty += _live->thumbnailHeight; - painth -= _live->thumbnailHeight; + painth -= thumbh; paintLiveRemaining(p, context, { paintx, painty, paintw, painth }); - paintText(); - } else if (_parent->media() == this) { + } + paintText(); + if (!_live && !hasText && _parent->media() == this) { auto fullRight = paintx + paintw; auto fullBottom = height(); _parent->drawInfo( @@ -597,17 +575,15 @@ TextState Location::textState(QPoint point, StateRequest request) const { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) { return result; } - auto paintx = 0, painty = 0, paintw = width(), painth = height(); + auto paintx = 0, painty = 0, paintw = width(); bool bubble = _parent->hasBubble(); + const auto hasText = !_title.isEmpty() || !_description.isEmpty(); auto checkText = [&] { - if (_live) { - painty += st::mediaInBubbleSkip; - } else if (_title.isEmpty() && _description.isEmpty()) { + if (!hasText && !_live) { return false; - } else if (isBubbleTop()) { - painty += st::msgPadding.top(); } + painty += st::mediaInBubbleSkip; auto textw = width() - st::msgPadding.left() - st::msgPadding.right(); @@ -640,26 +616,17 @@ TextState Location::textState(QPoint point, StateRequest request) const { } painty += descriptionh; } - if (!_title.isEmpty() || !_description.isEmpty()) { - painty += st::mediaInBubbleSkip; - } - painth -= painty; return false; }; - if (!_live && checkText()) { - return result; - } - const auto thumbh = _live ? _live->thumbnailHeight : painth; + const auto thumbh = _thumbnailHeight; if (QRect(paintx, painty, paintw, thumbh).contains(point) && _data) { result.link = _link; } - if (_live) { - painty += _live->thumbnailHeight; - painth -= _live->thumbnailHeight; - if (checkText()) { - return result; - } - } else if (_parent->media() == this) { + painty += thumbh; + if (checkText()) { + return result; + } + if (!_live && !hasText && _parent->media() == this) { auto fullRight = paintx + paintw; auto fullBottom = height(); const auto bottomInfoResult = _parent->bottomInfoTextState( diff --git a/Telegram/SourceFiles/history/view/media/history_view_location.h b/Telegram/SourceFiles/history/view/media/history_view_location.h index 9e431ef740..be95762e43 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_location.h +++ b/Telegram/SourceFiles/history/view/media/history_view_location.h @@ -56,12 +56,14 @@ public: bool needsBubble() const override; bool customInfoLayout() const override { - return true; + return _title.isEmpty() && _description.isEmpty(); } QPoint resolveCustomInfoRightBottom() const override; bool skipBubbleTail() const override { - return isRoundedInBubbleBottom(); + return _title.isEmpty() + && _description.isEmpty() + && isRoundedInBubbleBottom(); } QImage locationTakeImage() override; @@ -113,6 +115,7 @@ private: Ui::Text::String _title, _description; ClickHandlerPtr _link; + int _thumbnailHeight = 0; mutable QImage _imageCache; mutable Ui::BubbleRounding _imageCacheRounding;