diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index cfd123c93..f17389f1b 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -237,7 +237,7 @@ shareColumnSkip: 6px; shareActivateDuration: 150; shareScrollDuration: 300; shareComment: InputField(defaultInputField) { - font: normalFont; + style: defaultTextStyle; textMargins: margins(8px, 8px, 8px, 6px); heightMin: 36px; heightMax: 72px; @@ -585,7 +585,7 @@ groupStickersRemovePosition: point(6px, 6px); groupStickersFieldPadding: margins(8px, 6px, 8px, 6px); groupStickersField: InputField(defaultMultiSelectSearchField) { placeholderFont: boxTextFont; - font: boxTextFont; + style: boxTextStyle; placeholderMargins: margins(0px, 0px, 0px, 0px); textMargins: margins(0px, 7px, 0px, 0px); textBg: boxBg; @@ -672,7 +672,6 @@ themesMenuToggle: IconButton(defaultIconButton) { themesMenuPosition: point(-2px, 25px); createPollField: InputField(defaultInputField) { - font: boxTextFont; textMargins: margins(0px, 4px, 0px, 4px); textAlign: align(left); heightMin: 36px; @@ -877,7 +876,6 @@ scheduleDateField: InputField(defaultInputField) { placeholderScale: 0.; heightMin: 30px; textAlign: align(top); - font: font(14px); } scheduleTimeField: InputField(scheduleDateField) { border: 0px; @@ -905,7 +903,6 @@ muteBoxTimeField: InputField(scheduleDateField) { placeholderScale: 0.; heightMin: 30px; textAlign: align(left); - font: font(14px); } muteBoxTimeFieldPadding: margins(5px, 0px, 5px, 0px); diff --git a/Telegram/SourceFiles/boxes/max_invite_box.cpp b/Telegram/SourceFiles/boxes/max_invite_box.cpp index b6230b673..a7c1f8408 100644 --- a/Telegram/SourceFiles/boxes/max_invite_box.cpp +++ b/Telegram/SourceFiles/boxes/max_invite_box.cpp @@ -133,8 +133,8 @@ void MaxInviteBox::paintEvent(QPaintEvent *e) { auto option = QTextOption(style::al_left); option.setWrapMode(QTextOption::WrapAnywhere); p.setFont(_linkOver - ? st::defaultInputField.font->underline() - : st::defaultInputField.font); + ? st::defaultInputField.style.font->underline() + : st::defaultInputField.style.font); p.setPen(st::defaultLinkButton.color); const auto inviteLinkText = _channel->inviteLink().isEmpty() ? tr::lng_group_invite_create(tr::now) diff --git a/Telegram/SourceFiles/calls/calls.style b/Telegram/SourceFiles/calls/calls.style index cc009ad43..a133bba68 100644 --- a/Telegram/SourceFiles/calls/calls.style +++ b/Telegram/SourceFiles/calls/calls.style @@ -1393,7 +1393,6 @@ groupCallScheduleDateField: InputField(groupCallField) { placeholderScale: 0.; heightMin: 30px; textAlign: align(top); - font: font(14px); } groupCallScheduleTimeField: InputField(groupCallScheduleDateField) { textBg: groupCallMembersBg; diff --git a/Telegram/SourceFiles/chat_helpers/chat_helpers.style b/Telegram/SourceFiles/chat_helpers/chat_helpers.style index b3f7e73c9..ef96e4366 100644 --- a/Telegram/SourceFiles/chat_helpers/chat_helpers.style +++ b/Telegram/SourceFiles/chat_helpers/chat_helpers.style @@ -990,7 +990,7 @@ historyUnreadReactions: TwoIconButton(historyToDown) { historyUnreadThingsSkip: 4px; historyComposeField: InputField(defaultInputField) { - font: normalFont; + style: defaultTextStyle; textMargins: margins(0px, 0px, 0px, 0px); textAlign: align(left); textFg: historyComposeAreaFg; diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index 779bfb4d5..bb328564c 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -569,10 +569,10 @@ void InitMessageFieldFade( Ui::DestroyChild(b.data()); }, topFade->lifetime()); + const auto descent = field->st().style.font->descent; topFade->show(); - bottomFade->showOn( - field->scrollTop().value( - ) | rpl::map([field, descent = field->st().font->descent](int scroll) { + bottomFade->showOn(field->scrollTop().value( + ) | rpl::map([field, descent](int scroll) { return (scroll + descent) < field->scrollTopMax(); }) | rpl::distinct_until_changed()); } @@ -766,11 +766,7 @@ bool MessageLinksParser::eventFilter(QObject *object, QEvent *event) { const auto text = static_cast(event)->text(); if (!text.isEmpty() && text.size() < 3) { const auto ch = text[0]; - if (false - || ch == '\n' - || ch == '\r' - || ch.isSpace() - || ch == QChar::LineSeparator) { + if (IsSpace(ch)) { _timer.callOnce(0); } } @@ -1117,8 +1113,8 @@ void SelectTextInFieldWithMargins( auto textCursor = field->textCursor(); // Try to set equal margins for top and bottom sides. const auto charsCountInLine = field->width() - / field->st().font->width('W'); - const auto linesCount = (field->height() / field->st().font->height); + / field->st().style.font->width('W'); + const auto linesCount = field->height() / field->st().style.font->height; const auto selectedLines = (selection.to - selection.from) / charsCountInLine; constexpr auto kMinDiff = ushort(3); diff --git a/Telegram/SourceFiles/dialogs/dialogs.style b/Telegram/SourceFiles/dialogs/dialogs.style index dee018efd..279defe7d 100644 --- a/Telegram/SourceFiles/dialogs/dialogs.style +++ b/Telegram/SourceFiles/dialogs/dialogs.style @@ -285,7 +285,7 @@ dialogsFilter: InputField(defaultInputField) { borderRadius: 18px; borderDenominator: 2; - font: normalFont; + style: defaultTextStyle; heightMin: 35px; } diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style index ab16a1bd1..8e44a7a79 100644 --- a/Telegram/SourceFiles/info/info.style +++ b/Telegram/SourceFiles/info/info.style @@ -701,7 +701,7 @@ manageGroupReactionsField: InputField(defaultInputField) { placeholderScale: 0.; placeholderFont: normalFont; placeholderShift: -50px; - font: normalFont; + style: defaultTextStyle; heightMin: 36px; heightMax: 158px; } @@ -764,8 +764,6 @@ editPeerDescription: InputField(defaultInputField) { borderActive: 0px; heightMin: 32px; - - font: boxTextFont; } editPeerDescriptionMargins: margins(22px, 3px, 22px, 2px); editPeerPrivaciesMargins: margins(15px, 7px, 22px, 0px); diff --git a/Telegram/SourceFiles/intro/intro.style b/Telegram/SourceFiles/intro/intro.style index bedbad748..ae504be09 100644 --- a/Telegram/SourceFiles/intro/intro.style +++ b/Telegram/SourceFiles/intro/intro.style @@ -96,7 +96,9 @@ introPhoneTop: 6px; introLinkTop: 24px; introCountry: InputField(defaultInputField) { textMargins: margins(3px, 27px, 3px, 6px); - font: font(16px); + style: TextStyle(defaultTextStyle) { + font: font(16px); + } width: 300px; heightMin: 61px; } diff --git a/Telegram/SourceFiles/passport/passport.style b/Telegram/SourceFiles/passport/passport.style index c7e2a9466..c5bf74443 100644 --- a/Telegram/SourceFiles/passport/passport.style +++ b/Telegram/SourceFiles/passport/passport.style @@ -159,7 +159,7 @@ passportDetailsField: InputField(defaultInputField) { placeholderScale: 0.; placeholderFont: normalFont; heightMin: 32px; - font: normalFont; + style: defaultTextStyle; } passportDetailsDateField: InputField(passportDetailsField) { textMargins: margins(2px, 8px, 2px, 0px); @@ -178,7 +178,7 @@ passportDetailsSeparator: FlatLabel(passportPasswordLabelBold) { } passportDetailsSeparatorPadding: margins(5px, 8px, 5px, 0px); passportContactField: InputField(defaultInputField) { - font: normalFont; + style: defaultTextStyle; } passportDetailsFieldLeft: 116px; passportDetailsFieldTop: 2px; diff --git a/Telegram/SourceFiles/payments/ui/payments_field.cpp b/Telegram/SourceFiles/payments/ui/payments_field.cpp index 1314674ce..e5fbcb34e 100644 --- a/Telegram/SourceFiles/payments/ui/payments_field.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_field.cpp @@ -305,7 +305,7 @@ struct SimpleFieldState { .st = st::paymentsMoneyField, }); const auto &rule = state->rule; - state->currencySkip = rule.space ? state->st.font->spacew : 0; + state->currencySkip = rule.space ? state->st.style.font->spacew : 0; state->currencyText = ((!rule.left && rule.space) ? QString(QChar(' ')) : QString()) + (*rule.international @@ -343,7 +343,7 @@ struct SimpleFieldState { } const auto updateRight = [=] { const auto text = result->getLastText(); - const auto width = state->st.font->width(text); + const auto width = state->st.style.font->width(text); const auto &rule = state->rule; const auto symbol = QChar(rule.decimal); const auto decimal = text.indexOf(symbol); diff --git a/Telegram/SourceFiles/settings/settings.style b/Telegram/SourceFiles/settings/settings.style index d931f1df7..5fb976285 100644 --- a/Telegram/SourceFiles/settings/settings.style +++ b/Telegram/SourceFiles/settings/settings.style @@ -214,8 +214,6 @@ settingsBio: InputField(defaultInputField) { borderActive: 0px; heightMin: 32px; - - font: boxTextFont; } settingsBioMargins: margins(22px, 6px, 22px, 4px); @@ -309,8 +307,6 @@ settingsDeviceName: InputField(defaultInputField) { placeholderFont: normalFont; heightMin: 29px; - - font: boxTextFont; } dictionariesSectionButton: SettingsButton(settingsUpdateToggle) { @@ -677,5 +673,5 @@ settingsChatLinkField: InputField(defaultInputField) { heightMin: 32px; - font: normalFont; + style: defaultTextStyle; } diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index 732697926..7f8207521 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -1162,5 +1162,5 @@ factcheckField: InputField(defaultInputField) { heightMin: 24px; - font: normalFont; + style: defaultTextStyle; } diff --git a/Telegram/SourceFiles/ui/countryinput.cpp b/Telegram/SourceFiles/ui/countryinput.cpp index a9c9e1add..bdf77d1c1 100644 --- a/Telegram/SourceFiles/ui/countryinput.cpp +++ b/Telegram/SourceFiles/ui/countryinput.cpp @@ -55,7 +55,7 @@ void CountryInput::paintEvent(QPaintEvent *e) { st::introCountryIconPosition.y(), width()); - p.setFont(_st.font); + p.setFont(_st.style.font); p.setPen(_st.textFg); p.drawText(rect().marginsRemoved(_st.textMargins), _text, _st.textAlign); } @@ -159,7 +159,7 @@ rpl::producer CountryInput::codeChanged() const { } void CountryInput::setText(const QString &newText) { - _text = _st.font->elided( + _text = _st.style.font->elided( newText, width() - _st.textMargins.left() - _st.textMargins.right()); } diff --git a/Telegram/SourceFiles/ui/widgets/color_editor.cpp b/Telegram/SourceFiles/ui/widgets/color_editor.cpp index 3141faef3..bf2ba26fc 100644 --- a/Telegram/SourceFiles/ui/widgets/color_editor.cpp +++ b/Telegram/SourceFiles/ui/widgets/color_editor.cpp @@ -704,7 +704,7 @@ void ColorEditor::Field::correctValue( } void ColorEditor::Field::paintAdditionalPlaceholder(QPainter &p) { - p.setFont(_st.font); + p.setFont(_st.style.font); p.setPen(_st.placeholderFg); const auto inner = QRect( _st.textMargins.right(), @@ -829,7 +829,7 @@ void ColorEditor::ResultField::correctValue( } void ColorEditor::ResultField::paintAdditionalPlaceholder(QPainter &p) { - p.setFont(_st.font); + p.setFont(_st.style.font); p.setPen(_st.placeholderFg); p.drawText( QRect( diff --git a/Telegram/SourceFiles/ui/widgets/fields/special_fields.cpp b/Telegram/SourceFiles/ui/widgets/fields/special_fields.cpp index 81b1b1a0d..0b7487caf 100644 --- a/Telegram/SourceFiles/ui/widgets/fields/special_fields.cpp +++ b/Telegram/SourceFiles/ui/widgets/fields/special_fields.cpp @@ -267,14 +267,14 @@ UsernameInput::UsernameInput( void UsernameInput::setLinkPlaceholder(const QString &placeholder) { _linkPlaceholder = placeholder; if (!_linkPlaceholder.isEmpty()) { - setTextMargins(style::margins(_st.textMargins.left() + _st.font->width(_linkPlaceholder), _st.textMargins.top(), _st.textMargins.right(), _st.textMargins.bottom())); + setTextMargins(style::margins(_st.textMargins.left() + _st.style.font->width(_linkPlaceholder), _st.textMargins.top(), _st.textMargins.right(), _st.textMargins.bottom())); setPlaceholderHidden(true); } } void UsernameInput::paintAdditionalPlaceholder(QPainter &p) { if (!_linkPlaceholder.isEmpty()) { - p.setFont(_st.font); + p.setFont(_st.style.font); p.setPen(_st.placeholderFg); p.drawText(QRect(_st.textMargins.left(), _st.textMargins.top(), width(), height() - _st.textMargins.top() - _st.textMargins.bottom()), _linkPlaceholder, style::al_topleft); } diff --git a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp index d486e81b3..42f1abb3c 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp @@ -604,7 +604,7 @@ void Generator::paintComposeArea() { _p->setClipRect(field); _p->save(); - _p->setFont(st::historyComposeField.font); + _p->setFont(st::historyComposeField.style.font); _p->setPen(st::historyComposeField.placeholderFg[_palette]); auto placeholderRect = QRect( @@ -658,7 +658,7 @@ void Generator::paintDialogs() { _p->save(); _p->setClipRect(filter); auto phRect = QRect(filter.x() + st::dialogsFilter.textMargins.left() + st::dialogsFilter.placeholderMargins.left(), filter.y() + st::dialogsFilter.textMargins.top() + st::dialogsFilter.placeholderMargins.top(), filter.width() - st::dialogsFilter.textMargins.left() - st::dialogsFilter.textMargins.right(), filter.height() - st::dialogsFilter.textMargins.top() - st::dialogsFilter.textMargins.bottom()); - _p->setFont(st::dialogsFilter.font); + _p->setFont(st::dialogsFilter.style.font); _p->setPen(st::dialogsFilter.placeholderFg[_palette]); _p->drawText(phRect, tr::lng_dlg_filter(tr::now), QTextOption(st::dialogsFilter.placeholderAlign)); _p->restore(); diff --git a/Telegram/SourceFiles/window/window.style b/Telegram/SourceFiles/window/window.style index 8b13c0a36..37654c990 100644 --- a/Telegram/SourceFiles/window/window.style +++ b/Telegram/SourceFiles/window/window.style @@ -61,7 +61,7 @@ notifyActionsDuration: 200; notifyHideAllHeight: 36px; notifyReplyArea: InputField(defaultInputField) { - font: normalFont; + style: defaultTextStyle; textMargins: margins(8px, 8px, 8px, 6px); heightMin: 36px; heightMax: 72px; @@ -235,8 +235,6 @@ createThemeLink: InputField(defaultInputField) { placeholderFont: boxTextFont; heightMin: 34px; - - font: boxTextFont; } windowFiltersWidth: 72px; diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 599b4d051..924301cd6 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 599b4d0517dcbd70e2367aa7af0e8986e6c22052 +Subproject commit 924301cd62d918ef25ab81d758ed4b2fff903f2e