Moved location venue text below map thumbnail to match mobile.

This commit is contained in:
23rd
2026-03-31 14:22:56 +03:00
parent 989cbf0837
commit f5486e3090
2 changed files with 29 additions and 59 deletions
@@ -285,14 +285,8 @@ QSize Location::countOptimalSize() {
} }
if (!_title.isEmpty() || !_description.isEmpty()) { if (!_title.isEmpty() || !_description.isEmpty()) {
minHeight += st::mediaInBubbleSkip; minHeight += st::mediaInBubbleSkip;
if (_live) { if (isBubbleBottom()) {
if (isBubbleBottom()) { minHeight += st::msgPadding.bottom();
minHeight += st::msgPadding.bottom();
}
} else {
if (isBubbleTop()) {
minHeight += st::msgPadding.top();
}
} }
} }
} }
@@ -320,6 +314,7 @@ QSize Location::countCurrentSize(int newWidth) {
std::min(newWidth, st::maxMediaSize)); std::min(newWidth, st::maxMediaSize));
accumulate_max(newWidth, minWidth); accumulate_max(newWidth, minWidth);
accumulate_max(newHeight, st::minPhotoSize); accumulate_max(newHeight, st::minPhotoSize);
_thumbnailHeight = newHeight;
if (_live) { if (_live) {
_live->thumbnailHeight = newHeight; _live->thumbnailHeight = newHeight;
} }
@@ -332,14 +327,8 @@ QSize Location::countCurrentSize(int newWidth) {
} }
if (!_title.isEmpty() || !_description.isEmpty()) { if (!_title.isEmpty() || !_description.isEmpty()) {
newHeight += st::mediaInBubbleSkip; newHeight += st::mediaInBubbleSkip;
if (_live) { if (isBubbleBottom()) {
if (isBubbleBottom()) { newHeight += st::msgPadding.bottom();
newHeight += st::msgPadding.bottom();
}
} else {
if (isBubbleTop()) {
newHeight += st::msgPadding.top();
}
} }
} }
} }
@@ -366,19 +355,14 @@ void Location::draw(Painter &p, const PaintContext &context) const {
const auto stm = context.messageStyle(); const auto stm = context.messageStyle();
const auto hasText = !_title.isEmpty() || !_description.isEmpty(); const auto hasText = !_title.isEmpty() || !_description.isEmpty();
const auto rounding = adjustedBubbleRounding(_live const auto rounding = adjustedBubbleRounding(hasText
? RectPart::FullBottom ? RectPart::FullBottom
: hasText
? RectPart::FullTop
: RectPart()); : RectPart());
const auto paintText = [&] { const auto paintText = [&] {
if (_live) { if (!hasText && !_live) {
painty += st::mediaInBubbleSkip;
} else if (!hasText) {
return; return;
} else if (isBubbleTop()) {
painty += st::msgPadding.top();
} }
painty += st::mediaInBubbleSkip;
auto textw = width() - st::msgPadding.left() - st::msgPadding.right(); 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)); _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); painty += qMin(_description.countHeight(textw), 3 * st::webPageDescriptionFont->height);
} }
if (!_live) {
painty += st::mediaInBubbleSkip;
painth -= painty;
}
}; };
if (!_live) { const auto thumbh = _thumbnailHeight;
paintText();
}
const auto thumbh = _live ? _live->thumbnailHeight : painth;
auto rthumb = QRect(paintx, painty, paintw, thumbh); auto rthumb = QRect(paintx, painty, paintw, thumbh);
if (!bubble) { if (!bubble) {
fillImageShadow(p, rthumb, rounding, context); fillImageShadow(p, rthumb, rounding, context);
@@ -452,12 +429,13 @@ void Location::draw(Painter &p, const PaintContext &context) const {
if (context.selected()) { if (context.selected()) {
fillImageOverlay(p, rthumb, rounding, context); fillImageOverlay(p, rthumb, rounding, context);
} }
painty += thumbh;
if (_live) { if (_live) {
painty += _live->thumbnailHeight; painth -= thumbh;
painth -= _live->thumbnailHeight;
paintLiveRemaining(p, context, { paintx, painty, paintw, painth }); 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 fullRight = paintx + paintw;
auto fullBottom = height(); auto fullBottom = height();
_parent->drawInfo( _parent->drawInfo(
@@ -597,17 +575,15 @@ TextState Location::textState(QPoint point, StateRequest request) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) {
return result; return result;
} }
auto paintx = 0, painty = 0, paintw = width(), painth = height(); auto paintx = 0, painty = 0, paintw = width();
bool bubble = _parent->hasBubble(); bool bubble = _parent->hasBubble();
const auto hasText = !_title.isEmpty() || !_description.isEmpty();
auto checkText = [&] { auto checkText = [&] {
if (_live) { if (!hasText && !_live) {
painty += st::mediaInBubbleSkip;
} else if (_title.isEmpty() && _description.isEmpty()) {
return false; return false;
} else if (isBubbleTop()) {
painty += st::msgPadding.top();
} }
painty += st::mediaInBubbleSkip;
auto textw = width() - st::msgPadding.left() - st::msgPadding.right(); auto textw = width() - st::msgPadding.left() - st::msgPadding.right();
@@ -640,26 +616,17 @@ TextState Location::textState(QPoint point, StateRequest request) const {
} }
painty += descriptionh; painty += descriptionh;
} }
if (!_title.isEmpty() || !_description.isEmpty()) {
painty += st::mediaInBubbleSkip;
}
painth -= painty;
return false; return false;
}; };
if (!_live && checkText()) { const auto thumbh = _thumbnailHeight;
return result;
}
const auto thumbh = _live ? _live->thumbnailHeight : painth;
if (QRect(paintx, painty, paintw, thumbh).contains(point) && _data) { if (QRect(paintx, painty, paintw, thumbh).contains(point) && _data) {
result.link = _link; result.link = _link;
} }
if (_live) { painty += thumbh;
painty += _live->thumbnailHeight; if (checkText()) {
painth -= _live->thumbnailHeight; return result;
if (checkText()) { }
return result; if (!_live && !hasText && _parent->media() == this) {
}
} else if (_parent->media() == this) {
auto fullRight = paintx + paintw; auto fullRight = paintx + paintw;
auto fullBottom = height(); auto fullBottom = height();
const auto bottomInfoResult = _parent->bottomInfoTextState( const auto bottomInfoResult = _parent->bottomInfoTextState(
@@ -56,12 +56,14 @@ public:
bool needsBubble() const override; bool needsBubble() const override;
bool customInfoLayout() const override { bool customInfoLayout() const override {
return true; return _title.isEmpty() && _description.isEmpty();
} }
QPoint resolveCustomInfoRightBottom() const override; QPoint resolveCustomInfoRightBottom() const override;
bool skipBubbleTail() const override { bool skipBubbleTail() const override {
return isRoundedInBubbleBottom(); return _title.isEmpty()
&& _description.isEmpty()
&& isRoundedInBubbleBottom();
} }
QImage locationTakeImage() override; QImage locationTakeImage() override;
@@ -113,6 +115,7 @@ private:
Ui::Text::String _title, _description; Ui::Text::String _title, _description;
ClickHandlerPtr _link; ClickHandlerPtr _link;
int _thumbnailHeight = 0;
mutable QImage _imageCache; mutable QImage _imageCache;
mutable Ui::BubbleRounding _imageCacheRounding; mutable Ui::BubbleRounding _imageCacheRounding;