Use FlatLabel::textMaxWidth.
This commit is contained in:
parent
632626b192
commit
b3580f7987
4 changed files with 14 additions and 11 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -446,10 +446,13 @@ object_ptr<FlatLabel> 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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue