Use Ui::Text::String in Ui::RoundButton.

This commit is contained in:
John Preston 2024-08-30 18:01:49 +04:00
parent ec28f258fb
commit f79d70d112
27 changed files with 93 additions and 65 deletions

View file

@ -787,7 +787,7 @@ backgroundConfirmPadding: margins(24px, 16px, 24px, 16px);
backgroundConfirm: RoundButton(defaultActiveButton) {
height: 44px;
textTop: 12px;
font: font(13px semibold);
style: semiboldTextStyle;
}
backgroundConfirmCancel: RoundButton(backgroundConfirm) {
textFg: mediaviewSaveMsgFg;
@ -799,7 +799,7 @@ backgroundConfirmCancel: RoundButton(backgroundConfirm) {
height: 44px;
textTop: 12px;
font: font(13px semibold);
style: semiboldTextStyle;
ripple: RippleAnimation(defaultRippleAnimation) {
color: shadowFg;
@ -951,7 +951,7 @@ sponsoredUrlButton: RoundButton(defaultActiveButton) {
textFg: historyLinkInFg;
textFgOver: historyLinkInFg;
textTop: 7px;
font: normalFont;
style: defaultTextStyle;
ripple: RippleAnimation(defaultRippleAnimation) {
color: windowBgOver;

View file

@ -241,8 +241,8 @@ RequestsBoxController::RowHelper::RowHelper(bool isGroup)
? tr::lng_group_requests_add(tr::now)
: tr::lng_group_requests_add_channel(tr::now))
, _rejectText(tr::lng_group_requests_dismiss(tr::now))
, _acceptTextWidth(st::requestsAcceptButton.font->width(_acceptText))
, _rejectTextWidth(st::requestsRejectButton.font->width(_rejectText)) {
, _acceptTextWidth(st::requestsAcceptButton.style.font->width(_acceptText))
, _rejectTextWidth(st::requestsRejectButton.style.font->width(_rejectText)) {
}
RequestsBoxController::RequestsBoxController(
@ -491,7 +491,7 @@ void RequestsBoxController::RowHelper::paintButton(
const auto textLeft = geometry.x()
+ ((geometry.width() - textWidth) / 2);
const auto textTop = geometry.y() + st.textTop;
p.setFont(st.font);
p.setFont(st.style.font);
p.setPen(over ? st.textFgOver : st.textFg);
p.drawTextLeft(textLeft, textTop, outerWidth, text);
}

View file

@ -1216,11 +1216,12 @@ StickersBox::Inner::Inner(
})
, _itemsTop(st::lineWidth)
, _addText(tr::lng_stickers_featured_add(tr::now))
, _addWidth(st::stickersTrendingAdd.font->width(_addText))
, _addWidth(st::stickersTrendingAdd.style.font->width(_addText))
, _undoText(tr::lng_stickers_return(tr::now))
, _undoWidth(st::stickersUndoRemove.font->width(_undoText))
, _undoWidth(st::stickersUndoRemove.style.font->width(_undoText))
, _installedText(tr::lng_stickers_featured_installed(tr::now))
, _installedWidth(st::stickersTrendingInstalled.font->width(_installedText)) {
, _installedWidth(st::stickersTrendingInstalled.style.font->width(
_installedText)) {
setup();
}
@ -1666,7 +1667,7 @@ void StickersBox::Inner::paintFakeButton(Painter &p, not_null<Row*> row, int ind
row->ripple.reset();
}
}
p.setFont(st.font);
p.setFont(st.style.font);
p.setPen(st.textFg);
p.drawTextLeft(rect.x() - (st.width / 2), rect.y() + st.textTop, width(), text, textWidth);
} else {
@ -1700,7 +1701,7 @@ void StickersBox::Inner::paintFakeButton(Painter &p, not_null<Row*> row, int ind
row->ripple.reset();
}
}
p.setFont(st.font);
p.setFont(st.style.font);
p.setPen(selected ? st.textFgOver : st.textFg);
p.drawTextLeft(rect.x() - (st.width / 2), rect.y() + st.textTop, width(), text, textWidth);
}

View file

@ -296,7 +296,9 @@ emojiPanButton: RoundButton(defaultActiveButton) {
textTop: 2px;
}
emojiPanExpand: RoundButton(defaultActiveButton) {
font: font(12px bold);
style: TextStyle(semiboldTextStyle) {
font: font(12px bold);
}
width: -8px;
height: 19px;
textTop: 1px;
@ -1499,5 +1501,7 @@ pickLocationChooseOnMap: RoundButton(defaultActiveButton) {
height: 44px;
textTop: 11px;
width: -96px;
font: font(15px semibold);
style: TextStyle(semiboldTextStyle) {
font: font(15px semibold);
}
}

View file

@ -1450,17 +1450,17 @@ void EmojiListWidget::drawCollapsedBadge(
int count) {
const auto &st = st::emojiPanExpand;
const auto text = u"+%1"_q.arg(count - _columnCount * kCollapsedRows + 1);
const auto textWidth = st.font->width(text);
const auto textWidth = st.style.font->width(text);
const auto buttonw = std::max(textWidth - st.width, st.height);
const auto buttonh = st.height;
const auto buttonx = position.x() + (_singleSize.width() - buttonw) / 2;
const auto buttony = position.y() + (_singleSize.height() - buttonh) / 2;
_collapsedBg.paint(p, QRect(buttonx, buttony, buttonw, buttonh));
p.setPen(this->st().bg);
p.setFont(st.font);
p.setFont(st.style.font);
p.drawText(
buttonx + (buttonw - textWidth) / 2,
(buttony + st.textTop + st.font->ascent),
(buttony + st.textTop + st.style.font->ascent),
text);
}
@ -2546,12 +2546,12 @@ int EmojiListWidget::paintButtonGetWidth(
: selected
? st::emojiPanButton.textFgOver
: st::emojiPanButton.textFg);
p.setFont(st::emojiPanButton.font);
p.setFont(st::emojiPanButton.style.font);
p.drawText(
rect.x() - (st::emojiPanButton.width / 2),
(rect.y()
+ st::emojiPanButton.textTop
+ st::emojiPanButton.font->ascent),
+ st::emojiPanButton.style.font->ascent),
button.text);
return emojiRight() - rect.x();
}
@ -2678,7 +2678,7 @@ void EmojiListWidget::initButton(
const QString &text,
bool gradient) {
button.text = text;
button.textWidth = st::emojiPanButton.font->width(text);
button.textWidth = st::emojiPanButton.style.font->width(text);
const auto width = button.textWidth - st::emojiPanButton.width;
const auto height = st::emojiPanButton.height;
const auto factor = style::DevicePixelRatio();

View file

@ -213,11 +213,14 @@ StickersListWidget::StickersListWidget(
st().pathBg,
st().pathFg,
[=] { update(); }))
, _megagroupSetAbout(st::columnMinimalWidthThird - st::emojiScroll.width - st().headerLeft)
, _megagroupSetAbout(st::columnMinimalWidthThird
- st::emojiScroll.width
- st().headerLeft)
, _addText(tr::lng_stickers_featured_add(tr::now))
, _addWidth(st::stickersTrendingAdd.font->width(_addText))
, _addWidth(st::stickersTrendingAdd.style.font->width(_addText))
, _installedText(tr::lng_stickers_featured_installed(tr::now))
, _installedWidth(st::stickersTrendingInstalled.font->width(_installedText))
, _installedWidth(
st::stickersTrendingInstalled.style.font->width(_installedText))
, _settings(this, tr::lng_stickers_you_have(tr::now))
, _previewTimer([=] { showPreview(); })
, _premiumMark(std::make_unique<StickerPremiumMark>(
@ -974,7 +977,7 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
const auto &st = installedSet
? st::stickersTrendingInstalled
: st::stickersTrendingAdd;
p.setFont(st.font);
p.setFont(st.style.font);
p.setPen(selected ? st.textFgOver : st.textFg);
p.drawTextLeft(
add.x() - (st.width / 2),
@ -1238,7 +1241,7 @@ void StickersListWidget::paintMegagroupEmptySet(Painter &p, int y, bool buttonSe
_megagroupSetButtonRipple.reset();
}
}
p.setFont(st::stickerGroupCategoryAdd.font);
p.setFont(st::stickerGroupCategoryAdd.style.font);
p.setPen(buttonSelected ? st::stickerGroupCategoryAdd.textFgOver : st::stickerGroupCategoryAdd.textFg);
p.drawTextLeft(button.x() - (st::stickerGroupCategoryAdd.width / 2), button.y() + st::stickerGroupCategoryAdd.textTop, width(), _megagroupSetButtonText, _megagroupSetButtonTextWidth);
}
@ -2734,7 +2737,7 @@ void StickersListWidget::refreshMegagroupSetGeometry() {
auto left = megagroupSetInfoLeft();
auto availableWidth = (width() - left);
auto top = _megagroupSetAbout.countHeight(availableWidth) + st::stickerGroupCategoryAddMargin.top();
_megagroupSetButtonTextWidth = st::stickerGroupCategoryAdd.font->width(_megagroupSetButtonText);
_megagroupSetButtonTextWidth = st::stickerGroupCategoryAdd.style.font->width(_megagroupSetButtonText);
auto buttonWidth = _megagroupSetButtonTextWidth - st::stickerGroupCategoryAdd.width;
_megagroupSetButtonRect = QRect(left, top, buttonWidth, st::stickerGroupCategoryAdd.height);
}

View file

@ -70,14 +70,18 @@ exportCancelButton: RoundButton(attentionBoxButton) {
width: 200px;
height: 44px;
textTop: 12px;
font: font(semibold 15px);
style: TextStyle(semiboldTextStyle) {
font: font(semibold 15px);
}
}
exportCancelBottom: 30px;
exportDoneButton: RoundButton(defaultActiveButton) {
width: 200px;
height: 44px;
textTop: 12px;
font: font(semibold 15px);
style: TextStyle(semiboldTextStyle) {
font: font(semibold 15px);
}
}
exportAboutLabel: FlatLabel(boxLabel) {

View file

@ -362,9 +362,9 @@ void ProgressWidget::showDone() {
tr::lng_export_done(),
st::exportDoneButton);
const auto desired = std::min(
st::exportDoneButton.font->width(tr::lng_export_done(tr::now))
st::exportDoneButton.style.font->width(tr::lng_export_done(tr::now))
+ st::exportDoneButton.height
- st::exportDoneButton.font->height,
- st::exportDoneButton.style.font->height,
st::exportPanelSize.width() - 2 * st::exportCancelBottom);
if (_done->width() < desired) {
_done->setFullWidth(desired);

View file

@ -91,7 +91,7 @@ constexpr auto kPremiumToastDuration = 5 * crl::time(1000);
result->paintRequest() | rpl::start_with_next([=] {
auto p = QPainter(result);
const auto font = st::historyPremiumViewSet.font;
const auto font = st::historyPremiumViewSet.style.font;
const auto top = (result->height() - font->height) / 2;
auto pen = st::historyPremiumViewSet.textFg->p;
p.setPen(pen);
@ -229,7 +229,7 @@ void PaidReactionToast::showFor(
child->show();
const auto leftSkip = skip + size + skip - st.padding.left();
const auto undoFont = st::historyPremiumViewSet.font;
const auto undoFont = st::historyPremiumViewSet.style.font;
const auto rightSkip = undoFont->width(undoText)
+ st::toastUndoSpace

View file

@ -154,7 +154,7 @@ void StickerToast::showWithTitle(const QString &title) {
? tr::lng_animated_emoji_saved_open(tr::now)
: tr::lng_sticker_premium_view(tr::now);
_st.padding.setLeft(skip + size + skip);
_st.padding.setRight(st::historyPremiumViewSet.font->width(view)
_st.padding.setRight(st::historyPremiumViewSet.style.font->width(view)
- st::historyPremiumViewSet.width);
clearHiddenHiding();

View file

@ -518,7 +518,7 @@ void TranslateBar::showToast(
const QString &buttonText,
Fn<void()> buttonCallback) {
const auto st = std::make_shared<style::Toast>(st::historyPremiumToast);
st->padding.setRight(st::historyPremiumViewSet.font->width(buttonText)
st->padding.setRight(st::historyPremiumViewSet.style.font->width(buttonText)
- st::historyPremiumViewSet.width);
const auto weak = Ui::Toast::Show(_wrap.window(), Ui::Toast::Config{

View file

@ -60,9 +60,7 @@ giveawayGiftCodeQuantitySubtitle: FlatLabel(defaultFlatLabel) {
align: align(right);
}
giveawayGiftCodeQuantityFloat: FlatLabel(defaultFlatLabel) {
style: TextStyle(semiboldTextStyle) {
font: font(13px);
}
style: semiboldTextStyle;
textFg: windowActiveTextFg;
minWidth: 50px;
align: align(center);
@ -164,7 +162,7 @@ giveawayGiftCodeBox: Box(defaultBox) {
button: RoundButton(defaultActiveButton) {
height: 42px;
textTop: 12px;
font: font(13px semibold);
style: semiboldTextStyle;
}
shadowIgnoreTopSkip: true;
}

View file

@ -32,8 +32,7 @@ channelEarnOverviewSubMinorLabel: FlatLabel(channelEarnOverviewMinorLabel) {
}
channelEarnOverviewSubMinorLabelPos: point(4px, 2px);
channelEarnSemiboldLabel: FlatLabel(channelEarnOverviewMajorLabel) {
style: TextStyle(semiboldTextStyle) {
}
style: semiboldTextStyle;
}
channelEarnHeaderLabel: FlatLabel(channelEarnOverviewMajorLabel) {
style: TextStyle(statisticsHeaderTitleTextStyle) {
@ -91,7 +90,7 @@ channelEarnHistoryRecipientButton: RoundButton {
iconPosition: point(0px, 0px);
font: semiboldFont;
style: semiboldTextStyle;
ripple: RippleAnimation(defaultRippleAnimation) {
color: windowBgRipple;

View file

@ -368,7 +368,9 @@ infoProfileCover: InfoProfileCover {
width: -12px;
height: 18px;
textTop: 0px;
font: font(12px);
style: TextStyle(defaultTextStyle) {
font: font(12px);
}
ripple: defaultRippleAnimation;
}
showLastSeenPosition: point(3px, 58px);
@ -607,8 +609,7 @@ infoMembersCancelSearch: CrossButton {
}
infoMembersSearchTop: 15px;
infoMediaHeaderStyle: TextStyle(semiboldTextStyle) {
}
infoMediaHeaderStyle: semiboldTextStyle;
infoMediaHeaderHeight: 28px;
infoMediaHeaderPosition: point(14px, 6px);
infoMediaSkip: 2px;
@ -1100,7 +1101,7 @@ similarChannelsLockFade: 58px;
similarChannelsLock: RoundButton(defaultActiveButton) {
height: 44px;
textTop: 12px;
font: font(13px semibold);
style: semiboldTextStyle;
}
similarChannelsLockLabel: FlatLabel(defaultFlatLabel) {
textFg: premiumButtonFg;

View file

@ -81,7 +81,9 @@ introNextButton: RoundButton(defaultActiveButton) {
height: 42px;
radius: 6px;
textTop: 11px;
font: font(boxFontSize semibold);
style: TextStyle(semiboldTextStyle) {
font: font(boxFontSize semibold);
}
}
introFragmentIcon: icon{{ "fragment", activeButtonFg }};
introFragmentIconOver: icon{{ "fragment", activeButtonFgOver }};

View file

@ -371,11 +371,15 @@ themePreviewLoadingFont: font(16px);
themePreviewLoadingFg: windowSubTextFg;
themePreviewApplyButton: RoundButton(defaultActiveButton) {
height: 38px;
font: font(15px semibold);
style: TextStyle(semiboldTextStyle) {
font: font(15px semibold);
}
}
themePreviewCancelButton: RoundButton(defaultLightButton) {
height: 38px;
font: font(15px semibold);
style: TextStyle(semiboldTextStyle) {
font: font(15px semibold);
}
}
themePreviewButtonsSkip: 20px;
themePreviewDialogsWidth: 312px;
@ -796,7 +800,9 @@ storiesComposeControls: ComposeControls(defaultComposeControls) {
width: -12px;
height: 18px;
textTop: 0px;
font: font(12px);
style: TextStyle(defaultTextStyle) {
font: font(12px);
}
ripple: storiesComposeRipple;
}
buttonSkip: 6px;
@ -959,7 +965,7 @@ storiesStealthBox: Box(defaultBox) {
button: RoundButton(defaultBoxButton) {
height: 42px;
textTop: 12px;
font: font(13px semibold);
style: semiboldTextStyle;
textFg: storiesComposeWhiteText;
textFgOver: storiesComposeWhiteText;

View file

@ -4917,7 +4917,7 @@ void OverlayWidget::paintThemePreviewContent(
+ (_themeShare->y() - _themePreviewRect.y())
+ st::themePreviewCancelButton.padding.top()
+ st::themePreviewCancelButton.textTop
+ st::themePreviewCancelButton.font->ascent;
+ st::themePreviewCancelButton.style.font->ascent;
p.drawText(
left,
baseline,

View file

@ -49,7 +49,9 @@ passportPasswordSubmit: RoundButton(defaultActiveButton) {
width: 200px;
height: 44px;
textTop: 12px;
font: font(semibold 15px);
style: TextStyle(semiboldTextStyle) {
font: font(semibold 15px);
}
}
passportPasswordSubmitBottom: 72px;
passportPasswordForgotBottom: 36px;

View file

@ -14,12 +14,16 @@ paymentsPanelSize: size(392px, 600px);
paymentsPanelButton: RoundButton(defaultBoxButton) {
width: -36px;
height: 36px;
font: boxButtonFont;
style: TextStyle(defaultTextStyle) {
font: boxButtonFont;
}
}
paymentsPanelSubmit: RoundButton(defaultActiveButton) {
width: -36px;
height: 36px;
font: boxButtonFont;
style: TextStyle(defaultTextStyle) {
font: boxButtonFont;
}
}
paymentsPanelPadding: margins(8px, 12px, 15px, 12px);
@ -139,6 +143,8 @@ paymentsLoading: InfiniteRadialAnimation(defaultInfiniteRadialAnimation) {
botWebViewPanelSize: size(384px, 694px);
botWebViewBottomButton: RoundButton(paymentsPanelSubmit) {
height: 56px;
font: boxButtonFont;
style: TextStyle(defaultTextStyle) {
font: boxButtonFont;
}
textTop: 19px;
}

View file

@ -61,7 +61,7 @@ void BackButton::paintEvent(QPaintEvent *e) {
p.fillRect(e->rect(), st::profileBg);
st::topBarBack.paint(p, (st::topBarArrowPadding.left() - st::topBarBack.width()) / 2, (st::topBarHeight - st::topBarBack.height()) / 2, width());
p.setFont(st::topBarButton.font);
p.setFont(st::topBarButton.style.font);
p.setPen(st::topBarButton.textFg);
p.drawTextLeft(st::topBarArrowPadding.left(), st::topBarButton.padding.top() + st::topBarButton.textTop, width(), _text);
}

View file

@ -531,7 +531,7 @@ filterInviteBox: Box(defaultBox) {
button: RoundButton(defaultActiveButton) {
height: 42px;
textTop: 12px;
font: font(13px semibold);
style: semiboldTextStyle;
}
}
filterInviteButtonStyle: TextStyle(defaultTextStyle) {

View file

@ -1429,7 +1429,7 @@ not_null<Ui::RoundButton*> CreateLockedButton(
const auto labelSt = result->lifetime().make_state<style::FlatLabel>(
st::defaultFlatLabel);
labelSt->style.font = st.font;
labelSt->style.font = st.style.font;
labelSt->textFg = st.textFg;
const auto label = Ui::CreateChild<Ui::FlatLabel>(

View file

@ -68,7 +68,9 @@ statisticsHeaderButton: RoundButton(defaultLightButton) {
width: -14px;
height: 20px;
textTop: 2px;
font: font(11px semibold);
style: TextStyle(semiboldTextStyle) {
font: font(11px semibold);
}
}
statisticsLoadingSubtext: FlatLabel(changePhoneDescription) {

View file

@ -276,7 +276,7 @@ void Panel::Button::paintEvent(QPaintEvent *e) {
paintRipple(p, rect().topLeft(), &ripple);
}
p.setFont(_st.font);
p.setFont(_st.style.font);
const auto height = rect().height();
const auto progress = st::paymentsLoading.size;

View file

@ -396,7 +396,7 @@ object_ptr<RoundButton> FilterLinkProcessButton(
const auto label = result->lifetime().make_state<Label>(result.data());
label->setAttribute(Qt::WA_TransparentForMouseEvents);
result->sizeValue() | rpl::start_with_next([=](QSize size) {
const auto xskip = st->font->spacew;
const auto xskip = st->style.font->spacew;
const auto yskip = xskip / 2;
label->setGeometry(QRect(QPoint(), size).marginsRemoved(
{ xskip, yskip, xskip, yskip }));

View file

@ -97,7 +97,7 @@ premiumPreviewBox: Box(defaultBox) {
button: RoundButton(defaultActiveButton) {
height: 44px;
textTop: 12px;
font: font(13px semibold);
style: semiboldTextStyle;
}
}
premiumPreviewDoubledLimitsBox: Box(premiumPreviewBox) {
@ -295,7 +295,7 @@ boostBox: Box(premiumPreviewDoubledLimitsBox) {
button: RoundButton(defaultActiveButton) {
height: 42px;
textTop: 12px;
font: font(13px semibold);
style: semiboldTextStyle;
}
}
@ -323,7 +323,7 @@ showOrShowButton: RoundButton(defaultActiveButton) {
width: 308px;
height: 42px;
textTop: 12px;
font: font(13px semibold);
style: semiboldTextStyle;
}
showOrLabel: FlatLabel(boostText) {
textFg: windowSubTextFg;
@ -372,7 +372,7 @@ paidReactBox: Box(boostBox) {
button: RoundButton(defaultActiveButton) {
height: 42px;
textTop: 12px;
font: font(13px semibold);
style: semiboldTextStyle;
}
}
paidReactBubbleIcon: icon{{ "settings/premium/star", premiumButtonFg }};

@ -1 +1 @@
Subproject commit a30e22d268827449d31d7342e63967392686844e
Subproject commit 60cf1cad7a3ea742972037fe6c7e058a1cedf17e