diff --git a/ui/layers/box_layer_widget.cpp b/ui/layers/box_layer_widget.cpp index e0b90a4..6f356f9 100644 --- a/ui/layers/box_layer_widget.cpp +++ b/ui/layers/box_layer_widget.cpp @@ -250,11 +250,11 @@ void BoxLayerWidget::updateTitlePosition() { _titleLeft = st::boxTitlePosition.x(); _titleTop = st::boxTitlePosition.y(); if (_title) { - const auto topButtonSkip = _topButton ? (_topButton->width() / 2) : 0; - _title->resizeToWidth( - std::min( - _title->naturalWidth(), - width() - _titleLeft * 2 - topButtonSkip)); + const auto topButtonSkip = _topButton + ? (_topButton->width() / 2) + : 0; + _title->resizeToNaturalWidth( + width() - _titleLeft * 2 - topButtonSkip); _title->moveToLeft(_titleLeft, _titleTop); } } diff --git a/ui/rp_widget.h b/ui/rp_widget.h index 232affb..a00282e 100644 --- a/ui/rp_widget.h +++ b/ui/rp_widget.h @@ -199,8 +199,8 @@ public: // Resize to minimum of natural width and available width. void resizeToNaturalWidth(int newWidth) { - auto maxWidth = naturalWidth(); - resizeToWidth((maxWidth >= 0) ? qMin(newWidth, maxWidth) : newWidth); + const auto natural = naturalWidth(); + resizeToWidth((natural >= 0) ? qMin(newWidth, natural) : newWidth); } QRect rectNoMargins() const { diff --git a/ui/widgets/menu/menu_multiline_action.cpp b/ui/widgets/menu/menu_multiline_action.cpp index c4f3dbd..320ae10 100644 --- a/ui/widgets/menu/menu_multiline_action.cpp +++ b/ui/widgets/menu/menu_multiline_action.cpp @@ -65,8 +65,8 @@ void MultilineAction::paintEvent(QPaintEvent *e) { void MultilineAction::updateMinWidth() { const auto skip = _labelPosition.x(); - auto min = _text->naturalWidth() / 2; - auto max = _icon ? _st.widthMax : (_text->naturalWidth() - skip); + auto min = _text->textMaxWidth() / 2; + auto max = _icon ? _st.widthMax : (_text->textMaxWidth() - skip); _text->resizeToWidth(max); const auto height = _icon ? ((_st.itemIconPosition.y() * 2) + _icon->height()) diff --git a/ui/widgets/tooltip.cpp b/ui/widgets/tooltip.cpp index 1613af3..bd05590 100644 --- a/ui/widgets/tooltip.cpp +++ b/ui/widgets/tooltip.cpp @@ -446,10 +446,13 @@ object_ptr MakeNiceTooltipLabel( stMenu); const auto raw = result.data(); std::move(text) | rpl::start_with_next([=, &st] { - raw->resizeToNaturalWidth(maxWidth); - if (raw->naturalWidth() <= maxWidth) { + raw->resizeToWidth(qMin(maxWidth, raw->textMaxWidth())); + const auto desired = raw->textMaxWidth(); + if (desired <= maxWidth) { + raw->resizeToWidth(desired); return; } + raw->resizeToWidth(maxWidth); const auto niceWidth = FindNiceTooltipWidth( st.minWidth, maxWidth,