mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Use FlatLabel::textMaxWidth.
This commit is contained in:
parent
4b0c4eee30
commit
311691a3bc
10 changed files with 19 additions and 22 deletions
|
@ -403,7 +403,7 @@ not_null<Ui::RpWidget*> 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());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -310,7 +310,7 @@ void TranslateBar::setup(not_null<History*> 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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -305,7 +305,7 @@ void FormSummary::setupPrices(not_null<VerticalLayout*> layout) {
|
|||
padding.left(),
|
||||
padding.top(),
|
||||
(padding.right()
|
||||
+ right->naturalWidth()
|
||||
+ right->textMaxWidth()
|
||||
+ 2 * st.style.font->spacew),
|
||||
padding.bottom()));
|
||||
rpl::combine(
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 632626b1921e99aaea6d02a9f7ebbb6354161365
|
||||
Subproject commit b3580f7987d81b0c7aecee99f7f70f7873f6b35c
|
Loading…
Add table
Reference in a new issue