From 311691a3bc6bd4efc7397ad2952b1a52937e826f Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 17 Aug 2023 13:54:53 +0200 Subject: [PATCH] Use FlatLabel::textMaxWidth. --- .../boxes/peers/edit_peer_permissions_box.cpp | 2 +- Telegram/SourceFiles/calls/calls_top_bar.cpp | 4 ++-- .../SourceFiles/calls/group/calls_group_panel.cpp | 14 +++++++------- .../SourceFiles/dialogs/dialogs_inner_widget.cpp | 9 +++------ .../history/view/history_view_translate_bar.cpp | 2 +- .../info/profile/info_profile_phone_menu.cpp | 2 +- .../media/stories/media_stories_header.cpp | 2 +- .../SourceFiles/payments/ui/payments_field.cpp | 2 +- .../payments/ui/payments_form_summary.cpp | 2 +- Telegram/lib_ui | 2 +- 10 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp index 579049f28..4c33b38fc 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp @@ -403,7 +403,7 @@ not_null AddInnerToggle( (s.height() - label->height()) / 2); arrow->moveToLeft( std::min( - labelLeft + label->naturalWidth(), + labelLeft + label->textMaxWidth(), labelRight - arrow->width()), (s.height() - arrow->height()) / 2); }, button->lifetime()); diff --git a/Telegram/SourceFiles/calls/calls_top_bar.cpp b/Telegram/SourceFiles/calls/calls_top_bar.cpp index f06f78cfd..17f0008e8 100644 --- a/Telegram/SourceFiles/calls/calls_top_bar.cpp +++ b/Telegram/SourceFiles/calls/calls_top_bar.cpp @@ -731,14 +731,14 @@ void TopBar::updateControlsGeometry() { width() - _mute->width() - _hangup->width(), height()); - auto fullWidth = _fullInfoLabel->naturalWidth(); + auto fullWidth = _fullInfoLabel->textMaxWidth(); auto showFull = (left + fullWidth + right <= width()); _fullInfoLabel->setVisible(showFull); _shortInfoLabel->setVisible(!showFull); auto setInfoLabelGeometry = [this, left, right](auto &&infoLabel) { auto minPadding = qMax(left, right); - auto infoWidth = infoLabel->naturalWidth(); + auto infoWidth = infoLabel->textMaxWidth(); auto infoLeft = (width() - infoWidth) / 2; if (infoLeft < minPadding) { infoLeft = left; diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp index a240ce118..d07c748f4 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp @@ -2060,7 +2060,7 @@ void Panel::showNiceTooltip( (normal ? widget().get() : container), std::move(text), st::groupCallNiceTooltipLabel); - label->resizeToNaturalWidth(label->naturalWidth()); + label->resizeToWidth(label->textMaxWidth()); if (normal) { return label; } @@ -2522,8 +2522,8 @@ void Panel::refreshTitleGeometry() { fullRect.height()) : fullRect; const auto sep = st::groupCallTitleSeparator; - const auto best = _title->naturalWidth() + (_viewers - ? (_titleSeparator->width() + sep * 2 + _viewers->naturalWidth()) + const auto best = _title->textMaxWidth() + (_viewers + ? (_titleSeparator->width() + sep * 2 + _viewers->textMaxWidth()) : 0); const auto from = (widget()->width() - best) / 2; const auto shownTop = (mode() == PanelMode::Default) @@ -2541,8 +2541,8 @@ void Panel::refreshTitleGeometry() { const auto left = titleRect.x(); const auto notEnough = std::max(0, best - titleRect.width()); - const auto titleMaxWidth = _title->naturalWidth(); - const auto viewersMaxWidth = _viewers ? _viewers->naturalWidth() : 0; + const auto titleMaxWidth = _title->textMaxWidth(); + const auto viewersMaxWidth = _viewers ? _viewers->textMaxWidth() : 0; const auto viewersNotEnough = std::clamp( viewersMaxWidth - titleMaxWidth, 0, @@ -2551,9 +2551,9 @@ void Panel::refreshTitleGeometry() { (notEnough - std::abs(viewersMaxWidth - titleMaxWidth)) / 2, 0); _title->resizeToWidth( - _title->naturalWidth() - (notEnough - viewersNotEnough)); + _title->textMaxWidth() - (notEnough - viewersNotEnough)); if (_viewers) { - _viewers->resizeToWidth(_viewers->naturalWidth() - viewersNotEnough); + _viewers->resizeToWidth(_viewers->textMaxWidth() - viewersNotEnough); } const auto layout = [&](int position) { _title->moveToLeft(position, top); diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index d0d01778b..697862166 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -2818,12 +2818,9 @@ void InnerWidget::resizeEmptyLabel() { if (!_empty) { return; } - const auto useWidth = std::min( - _empty->naturalWidth(), - width() - 2 * st::dialogsEmptySkip); - const auto left = (width() - useWidth) / 2; - _empty->resizeToWidth(useWidth); - _empty->move(left, (st::dialogsEmptyHeight - _empty->height()) / 2); + const auto skip = st::dialogsEmptySkip; + _empty->resizeToWidth(width() - 2 * skip); + _empty->move(skip, (st::dialogsEmptyHeight - _empty->height()) / 2); } void InnerWidget::clearMouseSelection(bool clearSelection) { diff --git a/Telegram/SourceFiles/history/view/history_view_translate_bar.cpp b/Telegram/SourceFiles/history/view/history_view_translate_bar.cpp index 4207c59ca..92b4a4744 100644 --- a/Telegram/SourceFiles/history/view/history_view_translate_bar.cpp +++ b/Telegram/SourceFiles/history/view/history_view_translate_bar.cpp @@ -310,7 +310,7 @@ void TranslateBar::setup(not_null history) { const auto updateLabelGeometry = [=] { const auto full = _wrap.width() - icon->width(); const auto skip = st::semiboldFont->spacew * 2; - const auto natural = label->naturalWidth(); + const auto natural = label->textMaxWidth(); const auto top = [&] { return (_wrap.height() - label->height()) / 2; }; diff --git a/Telegram/SourceFiles/info/profile/info_profile_phone_menu.cpp b/Telegram/SourceFiles/info/profile/info_profile_phone_menu.cpp index 54bf15735..1939dde64 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_phone_menu.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_phone_menu.cpp @@ -52,7 +52,7 @@ private: return label->height(); }; auto widthMin = basicWidth; - auto widthMax = label->naturalWidth(); + auto widthMax = label->textMaxWidth(); if (height(widthMin) <= heightLimit || height(widthMax) > heightLimit) { return basicWidth; } diff --git a/Telegram/SourceFiles/media/stories/media_stories_header.cpp b/Telegram/SourceFiles/media/stories/media_stories_header.cpp index ac85729ee..9156ac35d 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_header.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_header.cpp @@ -356,7 +356,7 @@ void Header::show(HeaderData data) { _widget.get(), std::move(counter), st::storiesHeaderDate); - _counter->resizeToNaturalWidth(_counter->naturalWidth()); + _counter->resizeToWidth(_counter->textMaxWidth()); _counter->setAttribute(Qt::WA_TransparentForMouseEvents); _counter->setOpacity(kNameOpacity); _counter->show(); diff --git a/Telegram/SourceFiles/payments/ui/payments_field.cpp b/Telegram/SourceFiles/payments/ui/payments_field.cpp index 601b3629d..914cc1ccf 100644 --- a/Telegram/SourceFiles/payments/ui/payments_field.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_field.cpp @@ -322,7 +322,7 @@ struct SimpleFieldState { QString(), st::paymentsFieldAdditional); const auto leftSkip = state->left - ? (state->left->naturalWidth() + state->currencySkip) + ? (state->left->textMaxWidth() + state->currencySkip) : 0; const auto rightSkip = st::paymentsFieldAdditional.style.font->width( QString(QChar(rule.decimal)) diff --git a/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp b/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp index 4a9ab7e4c..4779e64be 100644 --- a/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp @@ -305,7 +305,7 @@ void FormSummary::setupPrices(not_null layout) { padding.left(), padding.top(), (padding.right() - + right->naturalWidth() + + right->textMaxWidth() + 2 * st.style.font->spacew), padding.bottom())); rpl::combine( diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 632626b19..b3580f798 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 632626b1921e99aaea6d02a9f7ebbb6354161365 +Subproject commit b3580f7987d81b0c7aecee99f7f70f7873f6b35c