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();
|
_titleLeft = st::boxTitlePosition.x();
|
||||||
_titleTop = st::boxTitlePosition.y();
|
_titleTop = st::boxTitlePosition.y();
|
||||||
if (_title) {
|
if (_title) {
|
||||||
const auto topButtonSkip = _topButton ? (_topButton->width() / 2) : 0;
|
const auto topButtonSkip = _topButton
|
||||||
_title->resizeToWidth(
|
? (_topButton->width() / 2)
|
||||||
std::min(
|
: 0;
|
||||||
_title->naturalWidth(),
|
_title->resizeToNaturalWidth(
|
||||||
width() - _titleLeft * 2 - topButtonSkip));
|
width() - _titleLeft * 2 - topButtonSkip);
|
||||||
_title->moveToLeft(_titleLeft, _titleTop);
|
_title->moveToLeft(_titleLeft, _titleTop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -199,8 +199,8 @@ public:
|
||||||
|
|
||||||
// Resize to minimum of natural width and available width.
|
// Resize to minimum of natural width and available width.
|
||||||
void resizeToNaturalWidth(int newWidth) {
|
void resizeToNaturalWidth(int newWidth) {
|
||||||
auto maxWidth = naturalWidth();
|
const auto natural = naturalWidth();
|
||||||
resizeToWidth((maxWidth >= 0) ? qMin(newWidth, maxWidth) : newWidth);
|
resizeToWidth((natural >= 0) ? qMin(newWidth, natural) : newWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect rectNoMargins() const {
|
QRect rectNoMargins() const {
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,8 @@ void MultilineAction::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
void MultilineAction::updateMinWidth() {
|
void MultilineAction::updateMinWidth() {
|
||||||
const auto skip = _labelPosition.x();
|
const auto skip = _labelPosition.x();
|
||||||
auto min = _text->naturalWidth() / 2;
|
auto min = _text->textMaxWidth() / 2;
|
||||||
auto max = _icon ? _st.widthMax : (_text->naturalWidth() - skip);
|
auto max = _icon ? _st.widthMax : (_text->textMaxWidth() - skip);
|
||||||
_text->resizeToWidth(max);
|
_text->resizeToWidth(max);
|
||||||
const auto height = _icon
|
const auto height = _icon
|
||||||
? ((_st.itemIconPosition.y() * 2) + _icon->height())
|
? ((_st.itemIconPosition.y() * 2) + _icon->height())
|
||||||
|
|
|
||||||
|
|
@ -446,10 +446,13 @@ object_ptr<FlatLabel> MakeNiceTooltipLabel(
|
||||||
stMenu);
|
stMenu);
|
||||||
const auto raw = result.data();
|
const auto raw = result.data();
|
||||||
std::move(text) | rpl::start_with_next([=, &st] {
|
std::move(text) | rpl::start_with_next([=, &st] {
|
||||||
raw->resizeToNaturalWidth(maxWidth);
|
raw->resizeToWidth(qMin(maxWidth, raw->textMaxWidth()));
|
||||||
if (raw->naturalWidth() <= maxWidth) {
|
const auto desired = raw->textMaxWidth();
|
||||||
|
if (desired <= maxWidth) {
|
||||||
|
raw->resizeToWidth(desired);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
raw->resizeToWidth(maxWidth);
|
||||||
const auto niceWidth = FindNiceTooltipWidth(
|
const auto niceWidth = FindNiceTooltipWidth(
|
||||||
st.minWidth,
|
st.minWidth,
|
||||||
maxWidth,
|
maxWidth,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue