From b2fb2d5821cd51d55740969d44d1821cbd1f3b19 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 11 Aug 2025 19:25:01 +0400 Subject: [PATCH] Attempt to fix the naturalWidth feature. --- Telegram/SourceFiles/api/api_chat_invite.cpp | 62 ++++---- .../boxes/filters/edit_filter_links.cpp | 35 ++-- .../SourceFiles/boxes/gift_credits_box.cpp | 23 ++- .../SourceFiles/boxes/gift_premium_box.cpp | 9 +- .../boxes/peers/add_participants_box.cpp | 12 +- .../boxes/peers/edit_peer_color_box.cpp | 21 ++- .../boxes/peers/edit_peer_invite_link.cpp | 22 +-- .../boxes/peers/replace_boost_box.cpp | 3 +- .../SourceFiles/boxes/premium_preview_box.cpp | 29 ++-- .../SourceFiles/boxes/send_credits_box.cpp | 14 +- Telegram/SourceFiles/boxes/star_gift_box.cpp | 12 +- .../calls/group/calls_group_common.cpp | 9 +- .../group/calls_group_invite_controller.cpp | 3 +- .../group/ui/calls_group_recording_box.cpp | 15 +- .../chat_helpers/message_field.cpp | 3 +- .../dialogs/dialogs_inner_widget.cpp | 7 +- .../dialogs/ui/posts_search_intro.cpp | 20 +-- .../controls/history_view_suggest_options.cpp | 23 +-- .../view/media/history_view_media_common.cpp | 15 +- .../bot/starref/info_bot_starref_common.cpp | 17 +- .../SourceFiles/info/info_wrap_widget.cpp | 2 +- .../peer_gifts/info_peer_gifts_common.cpp | 6 +- .../info/profile/info_profile_icon.cpp | 10 +- .../info/stories/info_stories_widget.cpp | 3 +- .../inline_bots/bot_attach_web_view.cpp | 49 +++--- .../media/stories/media_stories_stealth.cpp | 7 +- .../passport/passport_panel_form.cpp | 22 ++- .../passport/passport_panel_password.cpp | 54 +++---- .../payments/ui/payments_form_summary.cpp | 11 +- .../payments/ui/payments_reaction_box.cpp | 3 +- Telegram/SourceFiles/settings/settings.style | 2 +- .../settings/settings_blocked_peers.cpp | 22 ++- .../SourceFiles/settings/settings_common.cpp | 11 +- .../settings/settings_credits_graphics.cpp | 149 ++++++++++-------- .../SourceFiles/settings/settings_folders.cpp | 11 +- Telegram/SourceFiles/ui/boxes/boost_box.cpp | 6 +- .../ui/boxes/collectible_info_box.cpp | 6 +- .../ui/boxes/show_or_premium_box.cpp | 26 +-- .../SourceFiles/ui/controls/stars_rating.cpp | 20 ++- Telegram/SourceFiles/ui/effects/premium.style | 16 -- .../ui/widgets/slider_natural_width.h | 10 +- Telegram/lib_ui | 2 +- 42 files changed, 414 insertions(+), 388 deletions(-) diff --git a/Telegram/SourceFiles/api/api_chat_invite.cpp b/Telegram/SourceFiles/api/api_chat_invite.cpp index 0d5880fcb5..afc365c139 100644 --- a/Telegram/SourceFiles/api/api_chat_invite.cpp +++ b/Telegram/SourceFiles/api/api_chat_invite.cpp @@ -215,43 +215,43 @@ void ConfirmSubscriptionBox( 2.); box->addRow( - object_ptr>( + object_ptr( box, - object_ptr( - box, - tr::lng_channel_invite_subscription_title(), - st::inviteLinkSubscribeBoxTitle))); + tr::lng_channel_invite_subscription_title(), + st::inviteLinkSubscribeBoxTitle), + st::boxRowPadding, + style::al_top); box->addRow( - object_ptr>( + object_ptr( box, - object_ptr( - box, - tr::lng_channel_invite_subscription_about( - lt_channel, - rpl::single(Ui::Text::Bold(name)), - lt_price, - tr::lng_credits_summary_options_credits( - lt_count, - rpl::single(amount) | tr::to_count(), - Ui::Text::Bold), - Ui::Text::WithEntities), - st::inviteLinkSubscribeBoxAbout))); + tr::lng_channel_invite_subscription_about( + lt_channel, + rpl::single(Ui::Text::Bold(name)), + lt_price, + tr::lng_credits_summary_options_credits( + lt_count, + rpl::single(amount) | tr::to_count(), + Ui::Text::Bold), + Ui::Text::WithEntities), + st::inviteLinkSubscribeBoxAbout), + st::boxRowPadding, + style::al_top); Ui::AddSkip(content); box->addRow( - object_ptr>( + object_ptr( box, - object_ptr( - box, - tr::lng_channel_invite_subscription_terms( - lt_link, - rpl::combine( - tr::lng_paid_react_agree_link(), - tr::lng_group_invite_subscription_about_url() - ) | rpl::map([](const QString &text, const QString &url) { - return Ui::Text::Link(text, url); - }), - Ui::Text::RichLangValue), - st::inviteLinkSubscribeBoxTerms))); + tr::lng_channel_invite_subscription_terms( + lt_link, + rpl::combine( + tr::lng_paid_react_agree_link(), + tr::lng_group_invite_subscription_about_url() + ) | rpl::map([](const QString &text, const QString &url) { + return Ui::Text::Link(text, url); + }), + Ui::Text::RichLangValue), + st::inviteLinkSubscribeBoxTerms), + st::boxRowPadding, + style::al_top); { const auto balance = Settings::AddBalanceWidget( diff --git a/Telegram/SourceFiles/boxes/filters/edit_filter_links.cpp b/Telegram/SourceFiles/boxes/filters/edit_filter_links.cpp index acd6da5641..d420be8351 100644 --- a/Telegram/SourceFiles/boxes/filters/edit_filter_links.cpp +++ b/Telegram/SourceFiles/boxes/filters/edit_filter_links.cpp @@ -538,25 +538,24 @@ void LinkController::addHeader(not_null container) { const auto isStatic = _filterTitle.isStatic; verticalLayout->add( - object_ptr>( + object_ptr( verticalLayout, - object_ptr( - verticalLayout, - (_data.url.isEmpty() - ? tr::lng_filters_link_no_about(Ui::Text::WithEntities) - : tr::lng_filters_link_share_about( - lt_folder, - rpl::single(Ui::Text::Wrapped( - _filterTitle.text, - EntityType::Bold)), - Ui::Text::WithEntities)), - st::settingsFilterDividerLabel, - st::defaultPopupMenu, - Core::TextContext({ - .session = &_window->session(), - .customEmojiLoopLimit = isStatic ? -1 : 0, - }))), - st::filterLinkDividerLabelPadding); + (_data.url.isEmpty() + ? tr::lng_filters_link_no_about(Ui::Text::WithEntities) + : tr::lng_filters_link_share_about( + lt_folder, + rpl::single(Ui::Text::Wrapped( + _filterTitle.text, + EntityType::Bold)), + Ui::Text::WithEntities)), + st::settingsFilterDividerLabel, + st::defaultPopupMenu, + Core::TextContext({ + .session = &_window->session(), + .customEmojiLoopLimit = isStatic ? -1 : 0, + })), + st::filterLinkDividerLabelPadding, + style::al_top)->setTryMakeSimilarLines(true); verticalLayout->geometryValue( ) | rpl::start_with_next([=](const QRect &r) { diff --git a/Telegram/SourceFiles/boxes/gift_credits_box.cpp b/Telegram/SourceFiles/boxes/gift_credits_box.cpp index 8df343cec4..f96069a1b3 100644 --- a/Telegram/SourceFiles/boxes/gift_credits_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_credits_box.cpp @@ -78,19 +78,18 @@ void GiftCreditsBox( u"internal:stars_examples"_q); }); content->add( - object_ptr>( + Ui::CreateLabelWithCustomEmoji( content, - Ui::CreateLabelWithCustomEmoji( - content, - tr::lng_credits_box_history_entry_gift_out_about( - lt_user, - rpl::single(TextWithEntities{ peer->shortName() }), - lt_link, - std::move(link), - Ui::Text::RichLangValue), - Core::TextContext({ .session = &peer->session() }), - st::creditsBoxAbout)), - st::boxRowPadding); + tr::lng_credits_box_history_entry_gift_out_about( + lt_user, + rpl::single(TextWithEntities{ peer->shortName() }), + lt_link, + std::move(link), + Ui::Text::RichLangValue), + Core::TextContext({ .session = &peer->session() }), + st::creditsBoxAbout), + st::boxRowPadding, + style::al_top); } Ui::AddSkip(content); Ui::AddSkip(box->verticalLayout()); diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.cpp b/Telegram/SourceFiles/boxes/gift_premium_box.cpp index 0da643c073..daf79b39d3 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_premium_box.cpp @@ -741,7 +741,8 @@ void GiftCodeBox( std::move(shareLink), Ui::Text::WithEntities)), st::giveawayGiftCodeFooter), - st::giveawayGiftCodeFooterMargin); + st::giveawayGiftCodeFooterMargin, + style::al_top); footer->setClickHandlerFilter([=](const auto &...) { ShareWithFriend(controller, slug); return false; @@ -883,7 +884,8 @@ void GiftCodePendingBox( box, tr::lng_gift_link_pending_footer(), st::giveawayGiftCodeFooter), - st::giveawayGiftCodeFooterMargin); + st::giveawayGiftCodeFooterMargin, + style::al_top); const auto close = Ui::CreateChild( box.get(), @@ -1186,7 +1188,8 @@ void GiveawayInfoBox( : tr::lng_prizes_cancelled()), st::giveawayRefundedLabel), st::giveawayRefundedPadding), - { padding.left(), 0, padding.right(), padding.bottom() }); + { padding.left(), 0, padding.right(), padding.bottom() }, + style::al_top); const auto bg = wrap->lifetime().make_state( st::boxRadius, st::attentionBoxButton.textBgOver); diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp index 75ccf927d9..ed99b06ed5 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp @@ -233,7 +233,8 @@ void FillUpgradeToPremiumCover( container, rpl::single(text), st::inviteForbiddenInfo), - st::inviteForbiddenInfoPadding); + st::inviteForbiddenInfoPadding, + style::al_top); } void SimpleForbiddenBox( @@ -511,7 +512,8 @@ void InviteForbiddenController::setComplexCover() { if (_can) { container->add( MakeShowOrLabel(container, tr::lng_invite_upgrade_or()), - st::inviteForbiddenOrLabelPadding); + st::inviteForbiddenOrLabelPadding, + style::al_top); } container->add( object_ptr( @@ -520,7 +522,8 @@ void InviteForbiddenController::setComplexCover() { ? tr::lng_invite_upgrade_via_title() : tr::lng_via_link_cant()), st::inviteForbiddenTitle), - st::inviteForbiddenTitlePadding); + st::inviteForbiddenTitlePadding, + style::al_top); const auto about = _can ? (_peer->isBroadcast() @@ -544,7 +547,8 @@ void InviteForbiddenController::setComplexCover() { container, rpl::single(about), st::inviteForbiddenInfo), - st::inviteForbiddenInfoPadding); + st::inviteForbiddenInfoPadding, + style::al_top); } delegate()->peerListSetAboveWidget(std::move(cover)); } diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp index c7336a1a85..8542e862de 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp @@ -81,7 +81,6 @@ public: bool selected); [[nodiscard]] uint8 index() const; - int naturalWidth() const override; void setSelected(bool selected); @@ -181,6 +180,15 @@ ColorSample::ColorSample( colorIndex ) | rpl::start_with_next([=](uint8 index) { _index = index; + setNaturalWidth([&] { + if (_name.isEmpty() || _style->colorPatternIndex(_index)) { + return st::settingsColorSampleSize; + } + const auto padding = st::settingsColorSamplePadding; + return std::max( + padding.left() + _name.maxWidth() + padding.right(), + padding.top() + st::semiboldFont->height + padding.bottom()); + }()); update(); }, lifetime()); } @@ -195,6 +203,7 @@ ColorSample::ColorSample( , _index(colorIndex) , _selected(selected) , _simple(true) { + setNaturalWidth(st::settingsColorSampleSize); } void ColorSample::setSelected(bool selected) { @@ -276,16 +285,6 @@ uint8 ColorSample::index() const { return _index; } -int ColorSample::naturalWidth() const { - if (_name.isEmpty() || _style->colorPatternIndex(_index)) { - return st::settingsColorSampleSize; - } - const auto padding = st::settingsColorSamplePadding; - return std::max( - padding.left() + _name.maxWidth() + padding.right(), - padding.top() + st::semiboldFont->height + padding.bottom()); -} - PreviewWrap::PreviewWrap( not_null box, std::shared_ptr style, diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp index 3e4e451fd3..abd6113ad0 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp @@ -976,21 +976,22 @@ void Controller::rowClicked(not_null row) { Ui::AddSkip(content); Ui::AddSkip(content); - box->addRow(object_ptr>( - box, + box->addRow( object_ptr( box, tr::lng_credits_box_subscription_title(), - st::creditsBoxAboutTitle))); + st::creditsBoxAboutTitle), + st::boxRowPadding, + style::al_top); Ui::AddSkip(content); const auto subtitle1 = box->addRow( - object_ptr>( + object_ptr( box, - object_ptr( - box, - st::creditsTopupPrice)))->entity(); + st::creditsTopupPrice), + st::boxRowPadding, + style::al_top); subtitle1->setMarkedText( tr::lng_credits_subscription_subtitle( tr::now, @@ -1027,8 +1028,7 @@ void Controller::rowClicked(not_null row) { Ui::AddSkip(content); Ui::AddSkip(content); - box->addRow(object_ptr>( - box, + box->addRow( object_ptr( box, tr::lng_credits_box_out_about( @@ -1037,7 +1037,9 @@ void Controller::rowClicked(not_null row) { ) | Ui::Text::ToLink( tr::lng_credits_box_out_about_link(tr::now)), Ui::Text::WithEntities), - st::creditsBoxAboutDivider))); + st::creditsBoxAboutDivider), + st::boxRowPadding, + style::al_top); const auto button = box->addButton(tr::lng_box_ok(), [=] { box->closeBox(); diff --git a/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp b/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp index 85be6dd1ce..f76b4cc0b0 100644 --- a/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp @@ -221,7 +221,8 @@ void Controller::prepare() { Ui::Text::RichLangValue), Ui::Text::RichLangValue), st::boostReassignText), - st::boxRowPadding); + st::boxRowPadding, + style::al_top); delegate()->peerListSetAboveWidget(std::move(above)); const auto now = base::unixtime::now(); diff --git a/Telegram/SourceFiles/boxes/premium_preview_box.cpp b/Telegram/SourceFiles/boxes/premium_preview_box.cpp index da6f461d4b..e1fef3b9da 100644 --- a/Telegram/SourceFiles/boxes/premium_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/premium_preview_box.cpp @@ -1079,26 +1079,21 @@ void PreviewBox( auto text = state->selected.value( ) | rpl::map(SectionAbout) | rpl::flatten_latest(); - const auto padding = st::premiumPreviewAboutPadding; - const auto available = size.width() - padding.left() - padding.right(); - auto titleLabel = object_ptr( - box, - std::move(title), - st::premiumPreviewAboutTitle); - titleLabel->resizeToWidth(available); box->addRow( - object_ptr>( + object_ptr( box, - std::move(titleLabel)), - st::premiumPreviewAboutTitlePadding); - auto textLabel = object_ptr( - box, - std::move(text), - st::premiumPreviewAbout); - textLabel->resizeToWidth(available); + std::move(title), + st::premiumPreviewAboutTitle), + st::premiumPreviewAboutTitlePadding, + style::al_top); box->addRow( - object_ptr>(box, std::move(textLabel)), - padding); + object_ptr( + box, + std::move(text), + st::premiumPreviewAbout), + st::premiumPreviewAboutPadding, + style::al_top + )->setTryMakeSimilarLines(true); box->addRow( CreateSwitch(box->verticalLayout(), &state->selected, state->order), st::premiumDotsMargin); diff --git a/Telegram/SourceFiles/boxes/send_credits_box.cpp b/Telegram/SourceFiles/boxes/send_credits_box.cpp index 4ecd915df4..9b8fe27847 100644 --- a/Telegram/SourceFiles/boxes/send_credits_box.cpp +++ b/Telegram/SourceFiles/boxes/send_credits_box.cpp @@ -364,14 +364,15 @@ void SendCreditsBox( } Ui::AddSkip(content); - box->addRow(object_ptr>( - box, + box->addRow( object_ptr( box, form->invoice.subscriptionPeriod ? rpl::single(form->title) : tr::lng_credits_box_out_title(), - st::settingsPremiumUserTitle))); + st::settingsPremiumUserTitle), + st::boxRowPadding, + style::al_top); if (form->invoice.subscriptionPeriod && form->botId && form->photo) { Ui::AddSkip(content); Ui::AddSkip(content); @@ -383,12 +384,13 @@ void SendCreditsBox( Ui::AddSkip(content); } Ui::AddSkip(content); - box->addRow(object_ptr>( - box, + box->addRow( object_ptr( box, SendCreditsConfirmText(session, form.get()), - st::creditsBoxAbout))); + st::creditsBoxAbout), + st::boxRowPadding, + style::al_top); Ui::AddSkip(content); Ui::AddSkip(content); diff --git a/Telegram/SourceFiles/boxes/star_gift_box.cpp b/Telegram/SourceFiles/boxes/star_gift_box.cpp index ef50dea3d6..ca2ce8bbcf 100644 --- a/Telegram/SourceFiles/boxes/star_gift_box.cpp +++ b/Telegram/SourceFiles/boxes/star_gift_box.cpp @@ -2981,13 +2981,15 @@ void AddBlock( content, std::move(args.subtitle), st::giftBoxSubtitle), - st::giftBoxSubtitleMargin); + st::giftBoxSubtitleMargin, + style::al_top); const auto about = content->add( object_ptr( content, std::move(args.about), st::giftBoxAbout), - st::giftBoxAboutMargin); + st::giftBoxAboutMargin, + style::al_top); about->setClickHandlerFilter(std::move(args.aboutFilter)); content->add(std::move(args.content)); } @@ -4381,13 +4383,15 @@ void ShowUniqueGiftWearBox( lt_name, rpl::single(UniqueGiftName(gift))), st.title ? *st.title : st::uniqueGiftTitle), - st::settingsPremiumRowTitlePadding); + st::settingsPremiumRowTitlePadding, + style::al_top); content->add( object_ptr( content, tr::lng_gift_wear_about(), st.subtitle ? *st.subtitle : st::uniqueGiftSubtitle), - st::settingsPremiumRowAboutPadding); + st::settingsPremiumRowAboutPadding, + style::al_top); infoRow( tr::lng_gift_wear_badge_title(), (channel diff --git a/Telegram/SourceFiles/calls/group/calls_group_common.cpp b/Telegram/SourceFiles/calls/group/calls_group_common.cpp index 066d140861..008ca1107d 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_common.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_common.cpp @@ -136,7 +136,8 @@ void ConferenceCallJoinConfirm( Ui::Text::RichLangValue) : tr::lng_confcall_join_text(Ui::Text::RichLangValue)), st::confcallLinkCenteredText), - st::boxRowPadding + st::boxRowPadding, + style::al_top )->setTryMakeSimilarLines(true); const auto &participants = call->participants(); @@ -209,7 +210,8 @@ void ConferenceCallJoinConfirm( box, std::move(text), st::confcallLinkCenteredText), - st::boxRowPadding + st::boxRowPadding, + style::al_top )->setTryMakeSimilarLines(true); } const auto joinAndClose = [=] { @@ -335,7 +337,8 @@ void ShowConferenceCallLinkBox( (st.centerLabel ? *st.centerLabel : st::confcallLinkCenteredText)), - st::boxRowPadding + st::boxRowPadding, + style::al_top )->setTryMakeSimilarLines(true); Ui::AddSkip(box->verticalLayout(), st::defaultVerticalListSkip * 2); diff --git a/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp b/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp index 6994aff627..a79bfa65f3 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp @@ -1054,7 +1054,8 @@ not_null CreateReActivateHeader(not_null parent) { result, tr::lng_confcall_inactive_about(), st::confcallLinkCenteredText), - st::boxRowPadding + st::confcallLinkTitlePadding + st::boxRowPadding + st::confcallLinkTitlePadding, + style::al_top )->setTryMakeSimilarLines(true); Ui::AddDivider(result); diff --git a/Telegram/SourceFiles/calls/group/ui/calls_group_recording_box.cpp b/Telegram/SourceFiles/calls/group/ui/calls_group_recording_box.cpp index 513fa203c9..8f269593a4 100644 --- a/Telegram/SourceFiles/calls/group/ui/calls_group_recording_box.cpp +++ b/Telegram/SourceFiles/calls/group/ui/calls_group_recording_box.cpp @@ -196,22 +196,13 @@ void RecordingInfo::prepareVideo() { } void RecordingInfo::setLabel(const QString &text) { - const auto label = _container->add( + _container->add( object_ptr( _container, text, st::groupCallRecordingSubLabel), - st::groupCallRecordingSubLabelMargins); - - rpl::combine( - sizeValue(), - label->sizeValue() - ) | rpl::start_with_next([=](QSize my, QSize labelSize) { - label->moveToLeft( - (my.width() - labelSize.width()) / 2, - label->y(), - my.width()); - }, label->lifetime()); + st::groupCallRecordingSubLabelMargins, + style::al_top); } RecordingType RecordingInfo::type() const { diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index 8f5172c567..6fdf722bbf 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -1467,7 +1467,8 @@ void FrozenInfoBox( content, tr::lng_frozen_title(), st.title ? *st.title : st::uniqueGiftTitle), - st::settingsPremiumRowTitlePadding); + st::settingsPremiumRowTitlePadding, + style::al_top); Ui::AddSkip(content, st::defaultVerticalListSkip * 3); diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 4a7f9f57b4..683c34e082 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -4147,14 +4147,15 @@ void InnerWidget::refreshEmpty() { .name = u"no_chats"_q, .sizeOverride = Size(st::changePhoneIconSize), }); - _emptyList->add( - object_ptr>(_emptyList, std::move(icon.widget))); + _emptyList->add(std::move(icon.widget), {}, style::al_top); Ui::AddSkip(_emptyList); _emptyList->add( object_ptr( _emptyList, tr::lng_no_conversations(), - st::dialogEmptyButtonLabel)); + st::dialogEmptyButtonLabel), + {}, + style::al_top); if (_state == WidgetState::Default) { icon.animate(anim::repeat::once); } diff --git a/Telegram/SourceFiles/dialogs/ui/posts_search_intro.cpp b/Telegram/SourceFiles/dialogs/ui/posts_search_intro.cpp index 086976f035..8c9c59714d 100644 --- a/Telegram/SourceFiles/dialogs/ui/posts_search_intro.cpp +++ b/Telegram/SourceFiles/dialogs/ui/posts_search_intro.cpp @@ -170,30 +170,32 @@ void PostsSearchIntro::setup() { _content.get(), std::move(title), st::postsSearchIntroTitle), - st::postsSearchIntroTitleMargin); + st::postsSearchIntroTitleMargin, + style::al_top); _title->setTryMakeSimilarLines(true); _subtitle = _content->add( object_ptr( _content.get(), std::move(subtitle), st::postsSearchIntroSubtitle), - st::postsSearchIntroSubtitleMargin); + st::postsSearchIntroSubtitleMargin, + style::al_top); _subtitle->setTryMakeSimilarLines(true); _button = _content->add( - object_ptr>( + object_ptr( _content.get(), - object_ptr( - _content.get(), - rpl::single(QString()), - st::postsSearchIntroButton)) - )->entity(); + rpl::single(QString()), + st::postsSearchIntroButton), + {}, + style::al_top); _button->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); _footer = _content->add( object_ptr( _content.get(), std::move(footer), st::postsSearchIntroFooter), - st::postsSearchIntroFooterMargin); + st::postsSearchIntroFooterMargin, + style::al_top); _footer->setTryMakeSimilarLines(true); _state.value( diff --git a/Telegram/SourceFiles/history/view/controls/history_view_suggest_options.cpp b/Telegram/SourceFiles/history/view/controls/history_view_suggest_options.cpp index 95ad31b06e..fc4118399b 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_suggest_options.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_suggest_options.cpp @@ -389,12 +389,13 @@ void ChooseSuggestPriceBox( box->setNoContentMargin(true); Ui::AddSkip(container, st::boxTitleHeight * 1.1); - box->addRow(object_ptr>( - box, + box->addRow( object_ptr( box, std::move(title), - st::settingsPremiumUserTitle))); + st::settingsPremiumUserTitle), + st::boxRowPadding, + style::al_top); } state->buttons.push_back({ @@ -667,7 +668,7 @@ void ChooseSuggestPriceBox( return tr::lng_suggest_options_offer( tr::now, lt_amount, - TextWithEntities{ coloredTonIcon }.append( + Ui::Text::IconEmoji(&st::tonIconEmoji).append( Lang::FormatCreditsAmountDecimal(price)), Ui::Text::WithEntities); } @@ -786,19 +787,19 @@ void InsufficientTonBox( const auto nano = add.whole() * Ui::kNanosInOne + add.nano(); const auto amount = Ui::FormatTonAmount(nano).full; box->addRow( - object_ptr>( + object_ptr( box, - object_ptr( - box, - tr::lng_suggest_low_ton_title(tr::now, lt_amount, amount), - st::boxTitle)), - st::boxRowPadding + st::lowTonTitlePadding); + tr::lng_suggest_low_ton_title(tr::now, lt_amount, amount), + st::boxTitle), + st::boxRowPadding + st::lowTonTitlePadding, + style::al_top); const auto label = box->addRow( object_ptr( box, tr::lng_suggest_low_ton_text(Ui::Text::RichLangValue), st::lowTonText), - st::boxRowPadding + st::lowTonTextPadding); + st::boxRowPadding + st::lowTonTextPadding, + style::al_top); label->setTryMakeSimilarLines(true); label->resizeToWidth( st::boxWidth - st::boxRowPadding.left() - st::boxRowPadding.right()); diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_common.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_common.cpp index 56079194d1..8a9cec6910 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_common.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_common.cpp @@ -354,19 +354,22 @@ void ShowAgeVerification( box, tr::lng_age_verify_title(), st::settingsAgeVerifyTitle), - st::boxRowPadding + st::settingsAgeVerifyMargin); + st::boxRowPadding + st::settingsAgeVerifyMargin, + style::al_top); box->addRow( object_ptr( box, AgeVerifyAbout(&bot->session()), st::settingsAgeVerifyText), - st::boxRowPadding + st::settingsAgeVerifyMargin); + st::boxRowPadding + st::settingsAgeVerifyMargin, + style::al_top); box->addRow( object_ptr( box, tr::lng_age_verify_here(Ui::Text::RichLangValue), st::settingsAgeVerifyText), - st::boxRowPadding + st::settingsAgeVerifyMargin); + st::boxRowPadding + st::settingsAgeVerifyMargin, + style::al_top); const auto weak = QPointer(box); const auto done = crl::guard(&bot->session(), [=](int age) { @@ -446,13 +449,15 @@ void ShowAgeVerificationMobile( box, AgeVerifyAbout(session), st::settingsAgeVerifyText), - st::boxRowPadding + st::settingsAgeVerifyMargin); + st::boxRowPadding + st::settingsAgeVerifyMargin, + style::al_top); box->addRow( object_ptr( box, tr::lng_age_verify_mobile(Ui::Text::RichLangValue), st::settingsAgeVerifyText), - st::boxRowPadding + st::settingsAgeVerifyMargin); + st::boxRowPadding + st::settingsAgeVerifyMargin, + style::al_top); box->addButton(tr::lng_box_ok(), [=] { box->closeBox(); diff --git a/Telegram/SourceFiles/info/bot/starref/info_bot_starref_common.cpp b/Telegram/SourceFiles/info/bot/starref/info_bot_starref_common.cpp index 9ff2989746..45a539104d 100644 --- a/Telegram/SourceFiles/info/bot/starref/info_bot_starref_common.cpp +++ b/Telegram/SourceFiles/info/bot/starref/info_bot_starref_common.cpp @@ -470,7 +470,8 @@ object_ptr StarRefLinkBox( FormatForProgramDuration(program.durationMonths), Ui::Text::WithEntities), st::starrefCenteredText), - st::boxRowPadding); + st::boxRowPadding, + style::al_top); Ui::AddSkip(box->verticalLayout(), st::defaultVerticalListSkip * 3); @@ -478,7 +479,9 @@ object_ptr StarRefLinkBox( object_ptr( box, tr::lng_star_ref_link_recipient(), - st::starrefCenteredText)); + st::starrefCenteredText), + st::boxRowPadding, + style::al_top); Ui::AddSkip(box->verticalLayout()); box->addRow(object_ptr::fromRaw( MakePeerBubbleButton(box, peer).release() @@ -596,7 +599,8 @@ object_ptr JoinStarRefBox( FormatForProgramDuration(program.durationMonths), Ui::Text::WithEntities), st::starrefCenteredText), - st::boxRowPadding); + st::boxRowPadding, + style::al_top); Ui::AddSkip(box->verticalLayout(), st::defaultVerticalListSkip * 3); if (const auto average = program.revenuePerUser) { @@ -613,7 +617,8 @@ object_ptr JoinStarRefBox( Ui::Text::WithEntities), st::starrefRevenueText, st::defaultPopupMenu), - st::boxRowPadding); + st::boxRowPadding, + style::al_top); Ui::AddSkip(layout, st::defaultVerticalListSkip); } @@ -635,7 +640,9 @@ object_ptr JoinStarRefBox( object_ptr( box, tr::lng_star_ref_link_recipient(), - st::starrefCenteredText)); + st::starrefCenteredText), + st::boxRowPadding, + style::al_top); Ui::AddSkip(box->verticalLayout()); const auto recipientWrap = box->addRow( object_ptr(box), diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index 054ec8ce3f..9048245092 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -829,7 +829,7 @@ rpl::producer WrapWidget::desiredHeightValue() const { QRect WrapWidget::contentGeometry() const { const auto top = _topBar ? _topBar->height() : 0; - return rect().marginsRemoved({ 0, top, 0, 0 }); + return rect().marginsRemoved({ 0, std::min(top, height()), 0, 0}); } bool WrapWidget::returnToFirstStackFrame( diff --git a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp index 08dfe4aa74..289ea5844d 100644 --- a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp +++ b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp @@ -1009,13 +1009,15 @@ void SelectGiftToUnpin( box, tr::lng_gift_many_pinned_title(), st::giftBoxSubtitle), - st::giftBoxSubtitleMargin); + st::giftBoxSubtitleMargin, + style::al_top); box->addRow( object_ptr( box, tr::lng_gift_many_pinned_choose(), st::giftTooManyPinnedChoose), - st::giftBoxAboutMargin); + st::giftBoxAboutMargin, + style::al_top); const auto gifts = box->addRow( object_ptr(box), diff --git a/Telegram/SourceFiles/info/profile/info_profile_icon.cpp b/Telegram/SourceFiles/info/profile/info_profile_icon.cpp index 9f8dee9109..174b144cf8 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_icon.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_icon.cpp @@ -25,14 +25,10 @@ FloatingIcon::FloatingIcon( : RpWidget(parent) , _icon(&icon) , _point(position) { - resize( - _point.x() + _icon->width(), - _point.y() + _icon->height()); + setGeometry(QRect( + QPoint(0, 0), + QSize(_point.x() + _icon->width(), _point.y() + _icon->height()))); setAttribute(Qt::WA_TransparentForMouseEvents); - parent->widthValue( - ) | rpl::start_with_next( - [this] { moveToLeft(0, 0); }, - lifetime()); } void FloatingIcon::paintEvent(QPaintEvent *e) { diff --git a/Telegram/SourceFiles/info/stories/info_stories_widget.cpp b/Telegram/SourceFiles/info/stories/info_stories_widget.cpp index d093987a47..ad33ef4975 100644 --- a/Telegram/SourceFiles/info/stories/info_stories_widget.cpp +++ b/Telegram/SourceFiles/info/stories/info_stories_widget.cpp @@ -131,7 +131,8 @@ void Widget::restoreState(not_null memento) { void Widget::refreshBottom() { const auto albumId = _albumId.current(); - const auto withButton = albumId + const auto withButton = (albumId != Data::kStoriesAlbumIdSaved) + && (albumId != Data::kStoriesAlbumIdArchive) && controller()->storiesPeer()->canEditStories(); const auto wasBottom = _pinnedToBottom ? _pinnedToBottom->height() : 0; delete _pinnedToBottom.data(); diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index 02304eb965..be8fbdbefa 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -511,15 +511,18 @@ void ConfirmEmojiStatusAccessBox( AddSkip(box->verticalLayout(), 2 * st::defaultVerticalListSkip); auto name = Ui::Text::Bold(bot->name()); - box->addRow(object_ptr( - box, - tr::lng_bot_emoji_status_access_text( - lt_bot, - rpl::single(name), - lt_name, - rpl::single(name), - Ui::Text::RichLangValue), - st::botEmojiStatusText)); + box->addRow( + object_ptr( + box, + tr::lng_bot_emoji_status_access_text( + lt_bot, + rpl::single(name), + lt_name, + rpl::single(name), + Ui::Text::RichLangValue), + st::botEmojiStatusText), + st::boxRowPadding, + style::al_top); box->addButton(tr::lng_bot_emoji_status_access_allow(), [=] { if (!CheckEmojiStatusPremium(bot)) { @@ -557,19 +560,25 @@ void ConfirmEmojiStatusBox( box->closeBox(); }); - box->addRow(object_ptr( - box, - tr::lng_bot_emoji_status_title(), - st::botEmojiStatusTitle)); + box->addRow( + object_ptr( + box, + tr::lng_bot_emoji_status_title(), + st::botEmojiStatusTitle), + st::boxRowPadding, + style::al_top); AddSkip(box->verticalLayout()); - box->addRow(object_ptr( - box, - tr::lng_bot_emoji_status_text( - lt_bot, - rpl::single(Ui::Text::Bold(bot->name())), - Ui::Text::RichLangValue), - st::botEmojiStatusText)); + box->addRow( + object_ptr( + box, + tr::lng_bot_emoji_status_text( + lt_bot, + rpl::single(Ui::Text::Bold(bot->name())), + Ui::Text::RichLangValue), + st::botEmojiStatusText), + st::boxRowPadding, + style::al_top); AddSkip(box->verticalLayout(), 2 * st::defaultVerticalListSkip); diff --git a/Telegram/SourceFiles/media/stories/media_stories_stealth.cpp b/Telegram/SourceFiles/media/stories/media_stories_stealth.cpp index b64de9eafd..6bde919a7d 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_stealth.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_stealth.cpp @@ -327,8 +327,11 @@ struct Feature { box->setWidth(st::boxWideWidth); box->setStyle(st::storiesStealthBox); box->addRow(MakeLogo(box)); - box->addRow(MakeTitle(box)); - box->addRow(MakeAbout(box, data->state.value())); + box->addRow(MakeTitle(box), st::boxRowPadding, style::al_top); + box->addRow( + MakeAbout(box, data->state.value()), + st::boxRowPadding, + style::al_top); box->addRow(MakeFeature(box, FeaturePast())); box->addRow( MakeFeature(box, FeatureNext()), diff --git a/Telegram/SourceFiles/passport/passport_panel_form.cpp b/Telegram/SourceFiles/passport/passport_panel_form.cpp index 3c3d725338..5cbaa59412 100644 --- a/Telegram/SourceFiles/passport/passport_panel_form.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_form.cpp @@ -81,22 +81,20 @@ not_null PanelForm::setupContent() { }, _userpic->lifetime()); _about1 = inner->add( - object_ptr>( + object_ptr( inner, - object_ptr( - inner, - tr::lng_passport_request1(tr::now, lt_bot, bot->name()), - st::passportPasswordLabelBold)), - st::passportFormAbout1Padding)->entity(); + tr::lng_passport_request1(tr::now, lt_bot, bot->name()), + st::passportPasswordLabelBold), + st::passportFormAbout1Padding, + style::al_top); _about2 = inner->add( - object_ptr>( + object_ptr( inner, - object_ptr( - inner, - tr::lng_passport_request2(tr::now), - st::passportPasswordLabel)), - st::passportFormAbout2Padding)->entity(); + tr::lng_passport_request2(tr::now), + st::passportPasswordLabel), + st::passportFormAbout2Padding, + style::al_top); inner->add(object_ptr( inner, diff --git a/Telegram/SourceFiles/passport/passport_panel_password.cpp b/Telegram/SourceFiles/passport/passport_panel_password.cpp index 7046f14f08..322179fa63 100644 --- a/Telegram/SourceFiles/passport/passport_panel_password.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_password.cpp @@ -171,25 +171,23 @@ void PanelNoPassword::setupContent() { }, _inner->lifetime()); _inner->add( - object_ptr>( + object_ptr( _inner, - object_ptr( - _inner, - tr::lng_passport_request1( - tr::now, - lt_bot, - _controller->bot()->name()), - st::passportPasswordLabelBold)), - st::passportPasswordAbout1Padding)->entity(); + tr::lng_passport_request1( + tr::now, + lt_bot, + _controller->bot()->name()), + st::passportPasswordLabelBold), + st::passportPasswordAbout1Padding, + style::al_top); _inner->add( - object_ptr>( + object_ptr( _inner, - object_ptr( - _inner, - tr::lng_passport_request2(tr::now), - st::passportPasswordLabel)), - st::passportPasswordAbout2Padding)->entity(); + tr::lng_passport_request2(tr::now), + st::passportPasswordLabel), + st::passportPasswordAbout2Padding, + style::al_top); const auto iconWrap = _inner->add( object_ptr>( @@ -204,13 +202,12 @@ void PanelNoPassword::setupContent() { QPoint(0, 0)); _inner->add( - object_ptr>( + object_ptr( _inner, - object_ptr( - _inner, - tr::lng_passport_create_password(tr::now), - st::passportPasswordSetupLabel)), - st::passportFormAbout2Padding)->entity(); + tr::lng_passport_create_password(tr::now), + st::passportPasswordSetupLabel), + st::passportFormAbout2Padding, + style::al_top); refreshBottom(); } @@ -218,15 +215,14 @@ void PanelNoPassword::setupContent() { void PanelNoPassword::refreshBottom() { const auto pattern = _controller->unconfirmedEmailPattern(); _about.reset(_inner->add( - object_ptr>( + object_ptr( _inner, - object_ptr( - _inner, - (pattern.isEmpty() - ? tr::lng_passport_about_password(tr::now) - : tr::lng_passport_code_sent(tr::now, lt_email, pattern)), - st::passportPasswordSetupLabel)), - st::passportFormAbout2Padding)->entity()); + (pattern.isEmpty() + ? tr::lng_passport_about_password(tr::now) + : tr::lng_passport_code_sent(tr::now, lt_email, pattern)), + st::passportPasswordSetupLabel), + st::passportFormAbout2Padding, + style::al_top)); if (pattern.isEmpty()) { const auto button = _inner->add( object_ptr>( diff --git a/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp b/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp index ae68d8bdde..fd93541786 100644 --- a/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp @@ -119,10 +119,13 @@ bool FormSummary::showCriticalError(const TextWithEntities &text) { return false; } Ui::AddSkip(_layout.get(), st::paymentsPricesTopSkip); - _layout->add(object_ptr( - _layout.get(), - rpl::single(text), - st::paymentsCriticalError)); + _layout->add( + object_ptr( + _layout.get(), + rpl::single(text), + st::paymentsCriticalError), + {}, + style::al_top); return true; } diff --git a/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp b/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp index bc2b89a8aa..eb1366685a 100644 --- a/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp @@ -481,7 +481,8 @@ void PaidReactionsBox( box, tr::lng_paid_react_title(), st::boostCenteredTitle), - st::boxRowPadding + QMargins(0, st::paidReactTitleSkip, 0, 0)); + st::boxRowPadding + QMargins(0, st::paidReactTitleSkip, 0, 0), + style::al_top); const auto labelWrap = box->addRow( object_ptr(box), (st::boxRowPadding diff --git a/Telegram/SourceFiles/settings/settings.style b/Telegram/SourceFiles/settings/settings.style index c952f13c7f..c5610967d4 100644 --- a/Telegram/SourceFiles/settings/settings.style +++ b/Telegram/SourceFiles/settings/settings.style @@ -302,7 +302,7 @@ settingsAccentColorSkip: 4px; settingsAccentColorLine: 3px; settingsFilterDividerLabel: FlatLabel(boxDividerLabel) { - minWidth: 258px; + minWidth: 200px; maxHeight: 0px; align: align(top); } diff --git a/Telegram/SourceFiles/settings/settings_blocked_peers.cpp b/Telegram/SourceFiles/settings/settings_blocked_peers.cpp index fbb8a065ee..820e55988d 100644 --- a/Telegram/SourceFiles/settings/settings_blocked_peers.cpp +++ b/Telegram/SourceFiles/settings/settings_blocked_peers.cpp @@ -186,22 +186,20 @@ void Blocked::setupContent() { }, content->lifetime()); content->add( - object_ptr>( + object_ptr( content, - object_ptr( - content, - tr::lng_blocked_list_empty_title(), - st::changePhoneTitle)), - st::changePhoneTitlePadding); + tr::lng_blocked_list_empty_title(), + st::changePhoneTitle), + st::changePhoneTitlePadding, + style::al_top); content->add( - object_ptr>( + object_ptr( content, - object_ptr( - content, - tr::lng_blocked_list_empty_description(), - st::changePhoneDescription)), - st::changePhoneDescriptionPadding); + tr::lng_blocked_list_empty_description(), + st::changePhoneDescription), + st::changePhoneDescriptionPadding, + style::al_top); Ui::AddSkip(content, st::settingsBlockedListIconPadding.top()); } diff --git a/Telegram/SourceFiles/settings/settings_common.cpp b/Telegram/SourceFiles/settings/settings_common.cpp index d7f6139220..67ab82a18e 100644 --- a/Telegram/SourceFiles/settings/settings_common.cpp +++ b/Telegram/SourceFiles/settings/settings_common.cpp @@ -227,14 +227,13 @@ void AddDividerTextWithLottie( if (descriptor.about) { verticalLayout->add( - object_ptr>( + object_ptr( verticalLayout, - object_ptr( - verticalLayout, - std::move(descriptor.about), - st::settingsFilterDividerLabel)), + std::move(descriptor.about), + st::settingsFilterDividerLabel), descriptor.aboutMargins.value_or( - st::settingsFilterDividerLabelPadding)); + st::settingsFilterDividerLabelPadding), + style::al_top)->setTryMakeSimilarLines(true); } verticalLayout->geometryValue( diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index 9f5338da4b..2ef4636fd9 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -853,8 +853,7 @@ void BoostCreditsBox( AddCreditsBoostTable(controller->uiShow(), content, {}, b); Ui::AddSkip(content); - box->addRow(object_ptr>( - box, + box->addRow( object_ptr( box, tr::lng_credits_box_out_about( @@ -863,7 +862,9 @@ void BoostCreditsBox( ) | Ui::Text::ToLink( tr::lng_credits_box_out_about_link(tr::now)), Ui::Text::WithEntities), - st::creditsBoxAboutDivider))); + st::creditsBoxAboutDivider), + st::boxRowPadding, + style::al_top); Ui::AddSkip(content); const auto button = box->addButton(tr::lng_box_ok(), [=] { @@ -1391,8 +1392,7 @@ void GenericCreditsEntryBox( Ui::AddSkip(content); Ui::AddSkip(content); - box->addRow(object_ptr>( - box, + box->addRow( object_ptr( box, rpl::single(!s.title.isEmpty() @@ -1434,7 +1434,9 @@ void GenericCreditsEntryBox( : (peer && !e.reaction) ? peer->name() : Ui::GenerateEntryName(e).text), - st::creditsBoxAboutTitle))); + st::creditsBoxAboutTitle), + st::boxRowPadding, + style::al_top); Ui::AddSkip(content); } @@ -1607,68 +1609,69 @@ void GenericCreditsEntryBox( if (!isStarGift && !e.description.empty()) { Ui::AddSkip(content); - box->addRow(object_ptr>( - box, + box->addRow( object_ptr( box, rpl::single(e.description), - st::creditsBoxAbout))); + st::creditsBoxAbout), + st::boxRowPadding, + style::al_top); } const auto arrow = Ui::Text::IconEmoji(&st::textMoreIconEmoji); if (!uniqueGift && (starGiftCanManage || e.converted)) { Ui::AddSkip(content); const auto about = box->addRow( - object_ptr>( + object_ptr( box, - object_ptr( - box, - (e.giftRefunded - ? tr::lng_action_gift_refunded( - Ui::Text::RichLangValue) - : e.starsUpgradedBySender - ? tr::lng_action_gift_got_upgradable_text( - Ui::Text::RichLangValue) - : (e.starsToUpgrade - && giftToSelf - && !e.giftTransferred) - ? tr::lng_action_gift_self_about_unique( - Ui::Text::WithEntities) - : (e.starsToUpgrade - && giftToChannelCanManage - && !e.giftTransferred) - ? tr::lng_action_gift_channel_about_unique( - Ui::Text::WithEntities) - : ((canConvert || e.converted) - ? rpl::combine( - (canConvert - ? (giftToSelf - ? tr::lng_action_gift_self_about - : giftToChannelCanTransfer - ? tr::lng_action_gift_channel_about - : tr::lng_action_gift_got_stars_text) - : (giftToChannel - ? tr::lng_gift_channel_got - : tr::lng_gift_got_stars))( - lt_count, - rpl::single(e.starsConverted * 1.), - Ui::Text::RichLangValue), - tr::lng_paid_about_link() - ) | rpl::map([]( - TextWithEntities text, - QString link) { - return text.append(' ').append( - Ui::Text::Link(link)); - }) - : (e.savedToProfile - ? (giftToChannel - ? tr::lng_action_gift_can_remove_channel - : tr::lng_action_gift_can_remove_text) + (e.giftRefunded + ? tr::lng_action_gift_refunded( + Ui::Text::RichLangValue) + : e.starsUpgradedBySender + ? tr::lng_action_gift_got_upgradable_text( + Ui::Text::RichLangValue) + : (e.starsToUpgrade + && giftToSelf + && !e.giftTransferred) + ? tr::lng_action_gift_self_about_unique( + Ui::Text::WithEntities) + : (e.starsToUpgrade + && giftToChannelCanManage + && !e.giftTransferred) + ? tr::lng_action_gift_channel_about_unique( + Ui::Text::WithEntities) + : ((canConvert || e.converted) + ? rpl::combine( + (canConvert + ? (giftToSelf + ? tr::lng_action_gift_self_about + : giftToChannelCanTransfer + ? tr::lng_action_gift_channel_about + : tr::lng_action_gift_got_stars_text) : (giftToChannel - ? tr::lng_action_gift_got_gift_channel - : tr::lng_action_gift_got_gift_text))( - Ui::Text::WithEntities))), - st::creditsBoxAbout)))->entity(); + ? tr::lng_gift_channel_got + : tr::lng_gift_got_stars))( + lt_count, + rpl::single(e.starsConverted * 1.), + Ui::Text::RichLangValue), + tr::lng_paid_about_link() + ) | rpl::map([]( + TextWithEntities text, + QString link) { + return text.append(' ').append( + Ui::Text::Link(link)); + }) + : (e.savedToProfile + ? (giftToChannel + ? tr::lng_action_gift_can_remove_channel + : tr::lng_action_gift_can_remove_text) + : (giftToChannel + ? tr::lng_action_gift_got_gift_channel + : tr::lng_action_gift_got_gift_text))( + Ui::Text::WithEntities))), + st::creditsBoxAbout), + st::boxRowPadding, + style::al_top); about->setClickHandlerFilter([=](const auto &...) { Core::App().iv().openWithIvPreferred( session, @@ -1690,8 +1693,7 @@ void GenericCreditsEntryBox( std::move(text), u"internal:stars_examples"_q); }); - box->addRow(object_ptr>( - box, + box->addRow( Ui::CreateLabelWithCustomEmoji( box, (!e.in && peer) @@ -1706,7 +1708,9 @@ void GenericCreditsEntryBox( std::move(link), Ui::Text::RichLangValue), Core::TextContext({ .session = session }), - st::creditsBoxAbout))); + st::creditsBoxAbout), + st::boxRowPadding, + style::al_top); } else if (e.paidMessagesCommission && e.barePeerId) { Ui::AddSkip(content); auto link = tr::lng_credits_paid_messages_fee_about_link( @@ -1719,8 +1723,7 @@ void GenericCreditsEntryBox( u"internal:edit_paid_messages_fee/"_q + QString::number(id)); }); const auto percent = 100. - (e.paidMessagesCommission / 10.); - box->addRow(object_ptr>( - box, + box->addRow( Ui::CreateLabelWithCustomEmoji( box, tr::lng_credits_paid_messages_fee_about( @@ -1731,7 +1734,9 @@ void GenericCreditsEntryBox( std::move(link), Ui::Text::RichLangValue), Core::TextContext({ .session = session }), - st::creditsBoxAbout))); + st::creditsBoxAbout), + st::boxRowPadding, + style::al_top); } Ui::AddSkip(content); @@ -1864,8 +1869,7 @@ void GenericCreditsEntryBox( Ui::AddSkip(content); if (!isStarGift && e.credits.stars()) { - box->addRow(object_ptr>( - box, + box->addRow( object_ptr( box, tr::lng_credits_box_out_about( @@ -1874,7 +1878,9 @@ void GenericCreditsEntryBox( ) | Ui::Text::ToLink( tr::lng_credits_box_out_about_link(tr::now)), Ui::Text::WithEntities), - st::creditsBoxAboutDivider))); + st::creditsBoxAboutDivider), + st::boxRowPadding, + style::al_top); } else if (starGiftCanManage) { const auto hiddenPhrase = giftToChannelCanManage ? tr::lng_gift_hidden_hint_channel @@ -1925,7 +1931,9 @@ void GenericCreditsEntryBox( object_ptr( box, std::move(text), - st::creditsBoxAboutDivider)); + st::creditsBoxAboutDivider), + st::boxRowPadding, + style::al_top); label->setClickHandlerFilter([=](const auto &...) { toggleVisibility(!e.savedToProfile); return false; @@ -1942,7 +1950,9 @@ void GenericCreditsEntryBox( Ui::Text::WithEntities ) | Ui::Text::ToLink(), Ui::Text::WithEntities), - st::creditsBoxAboutDivider)); + st::creditsBoxAboutDivider), + st::boxRowPadding, + style::al_top); label->setClickHandlerFilter([=](const auto &...) { UrlClickHandler::Open( TonAddressUrl(session, uniqueGift->ownerAddress)); @@ -1994,8 +2004,7 @@ void GenericCreditsEntryBox( } else if (s.cancelled || s.cancelledByBot) { label->setTextColorOverride(st::menuIconAttentionColor->c); } - box->addRow( - object_ptr>(box, std::move(label))); + box->addRow(std::move(label), st::boxRowPadding, style::al_top); } Ui::AddSkip(content); diff --git a/Telegram/SourceFiles/settings/settings_folders.cpp b/Telegram/SourceFiles/settings/settings_folders.cpp index 1c5129e2f2..c8ac855a84 100644 --- a/Telegram/SourceFiles/settings/settings_folders.cpp +++ b/Telegram/SourceFiles/settings/settings_folders.cpp @@ -862,13 +862,12 @@ void SetupTopContent( verticalLayout->add(std::move(icon.widget)); verticalLayout->add( - object_ptr>( + object_ptr( verticalLayout, - object_ptr( - verticalLayout, - tr::lng_filters_about(), - st::settingsFilterDividerLabel)), - st::settingsFilterDividerLabelPadding); + tr::lng_filters_about(), + st::settingsFilterDividerLabel), + st::settingsFilterDividerLabelPadding, + style::al_top)->setTryMakeSimilarLines(true); verticalLayout->geometryValue( ) | rpl::start_with_next([=](const QRect &r) { diff --git a/Telegram/SourceFiles/ui/boxes/boost_box.cpp b/Telegram/SourceFiles/ui/boxes/boost_box.cpp index e72896a771..6dab099149 100644 --- a/Telegram/SourceFiles/ui/boxes/boost_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/boost_box.cpp @@ -752,14 +752,16 @@ void AskBoostBox( box, std::move(title), st::boostCenteredTitle), - st::boxRowPadding + QMargins(0, st::boostTitleSkip, 0, 0)); + st::boxRowPadding + QMargins(0, st::boostTitleSkip, 0, 0), + style::al_top); box->addRow( object_ptr( box, std::move(text), st::boostText), (st::boxRowPadding - + QMargins(0, st::boostTextSkip, 0, st::boostBottomSkip))); + + QMargins(0, st::boostTextSkip, 0, st::boostBottomSkip)), + style::al_top); auto stats = object_ptr(box, st::boostLinkStatsButton); stats->setClickedCallback(openStatistics); diff --git a/Telegram/SourceFiles/ui/boxes/collectible_info_box.cpp b/Telegram/SourceFiles/ui/boxes/collectible_info_box.cpp index 5dc0aced6d..f9c24efb5e 100644 --- a/Telegram/SourceFiles/ui/boxes/collectible_info_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/collectible_info_box.cpp @@ -201,7 +201,8 @@ void CollectibleInfoBox( box, rpl::single(header), st::collectibleHeader), - st::collectibleHeaderPadding + st::collectibleHeaderPadding, + style::al_top )->setClickHandlerFilter([copyCallback](const auto &...) { copyCallback(false); return false; @@ -220,7 +221,8 @@ void CollectibleInfoBox( Ui::Text::RichLangValue); const auto label = box->addRow( object_ptr(box, st::collectibleInfo), - st::collectibleInfoPadding); + st::collectibleInfoPadding, + style::al_top); label->setAttribute(Qt::WA_TransparentForMouseEvents); label->setMarkedText(text); diff --git a/Telegram/SourceFiles/ui/boxes/show_or_premium_box.cpp b/Telegram/SourceFiles/ui/boxes/show_or_premium_box.cpp index 426ddce42e..00cfa4b789 100644 --- a/Telegram/SourceFiles/ui/boxes/show_or_premium_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/show_or_premium_box.cpp @@ -57,10 +57,12 @@ constexpr auto kShowOrLineOpacity = 0.3; object_ptr MakeShowOrLabel( not_null parent, rpl::producer text) { - auto result = object_ptr( + auto result = object_ptr>( parent, - std::move(text), - st::showOrLabel); + object_ptr( + parent, + std::move(text), + st::showOrLabel)); const auto raw = result.data(); raw->paintRequest( @@ -69,7 +71,8 @@ object_ptr MakeShowOrLabel( const auto full = st::showOrLineWidth; const auto left = (raw->width() - full) / 2; - const auto text = raw->textMaxWidth() + 2 * st::showOrLabelSkip; + const auto text = raw->entity()->naturalWidth() + + 2 * st::showOrLabelSkip; const auto fill = (full - text) / 2; const auto stroke = st::lineWidth; const auto top = st::showOrLineTop; @@ -152,13 +155,15 @@ void ShowOrPremiumBox( box, std::move(skin.showTitle), st::boostCenteredTitle), - st::showOrTitlePadding + buttonPadding); + st::showOrTitlePadding + buttonPadding, + style::al_top); box->addRow( object_ptr( box, std::move(skin.showAbout), st::boostText), - st::showOrAboutPadding + buttonPadding); + st::showOrAboutPadding + buttonPadding, + style::al_top); const auto show = box->addRow( object_ptr( box, @@ -168,19 +173,22 @@ void ShowOrPremiumBox( show->setTextTransform(RoundButton::TextTransform::NoTransform); box->addRow( MakeShowOrLabel(box, std::move(skin.orPremium)), - st::showOrLabelPadding + buttonPadding); + st::showOrLabelPadding + buttonPadding, + style::al_top); box->addRow( object_ptr( box, std::move(skin.premiumTitle), st::boostCenteredTitle), - st::showOrTitlePadding + buttonPadding); + st::showOrTitlePadding + buttonPadding, + style::al_top); box->addRow( object_ptr( box, std::move(skin.premiumAbout), st::boostText), - st::showOrPremiumAboutPadding + buttonPadding); + st::showOrPremiumAboutPadding + buttonPadding, + style::al_top); const auto premium = CreateChild( box.get(), diff --git a/Telegram/SourceFiles/ui/controls/stars_rating.cpp b/Telegram/SourceFiles/ui/controls/stars_rating.cpp index e39dec86af..f5c9dce7d8 100644 --- a/Telegram/SourceFiles/ui/controls/stars_rating.cpp +++ b/Telegram/SourceFiles/ui/controls/stars_rating.cpp @@ -288,19 +288,21 @@ void AboutRatingBox( lt_name, rpl::single(TextWithEntities{ name }), Ui::Text::RichLangValue); - const auto aboutNegative = box->addRow( + box->addRow( object_ptr( box, std::move(text), st::boostTextNegative), (st::boxRowPadding - + QMargins(0, st::boostTextSkip, 0, st::boostBottomSkip))); - aboutNegative->setTryMakeSimilarLines(true); + + QMargins(0, st::boostTextSkip, 0, st::boostBottomSkip)), + style::al_top + )->setTryMakeSimilarLines(true); } box->addRow( object_ptr(box, std::move(title), st::infoStarsTitle), - st::boxRowPadding + QMargins(0, st::boostTitleSkip / 2, 0, 0)); + st::boxRowPadding + QMargins(0, st::boostTitleSkip / 2, 0, 0), + style::al_top); if (pending) { const auto now = base::unixtime::now(); @@ -331,7 +333,8 @@ void AboutRatingBox( std::move(text), st::boostTextPending), (st::boxRowPadding - + QMargins(0, st::boostTextSkip, 0, st::boostBottomSkip))); + + QMargins(0, st::boostTextSkip, 0, st::boostBottomSkip)), + style::al_top); aboutPending->setTryMakeSimilarLines(true); aboutPending->setClickHandlerFilter([=](const auto &...) { state->pending = !state->pending.current(); @@ -343,14 +346,15 @@ void AboutRatingBox( }); } - const auto aboutLabel = box->addRow( + box->addRow( object_ptr( box, std::move(text), st::boostText), (st::boxRowPadding - + QMargins(0, st::boostTextSkip, 0, st::boostBottomSkip))); - aboutLabel->setTryMakeSimilarLines(true); + + QMargins(0, st::boostTextSkip, 0, st::boostBottomSkip)), + style::al_top + )->setTryMakeSimilarLines(true); auto helper = Ui::Text::CustomEmojiHelper(); const auto makeBadge = [&]( diff --git a/Telegram/SourceFiles/ui/effects/premium.style b/Telegram/SourceFiles/ui/effects/premium.style index a510a70963..584b5509e0 100644 --- a/Telegram/SourceFiles/ui/effects/premium.style +++ b/Telegram/SourceFiles/ui/effects/premium.style @@ -224,18 +224,6 @@ premiumGiftOption: PremiumOption { badgeMargins: margins(5px, 1px, 5px, 0px); } -premiumGiftUserpicPadding: margins(10px, 27px, 18px, 13px); -premiumGiftTitlePadding: margins(18px, 0px, 18px, 0px); -premiumGiftAboutPadding: margins(18px, 5px, 18px, 23px); -premiumGiftTermsPadding: margins(18px, 27px, 18px, 0px); -premiumGiftTerms: FlatLabel(defaultFlatLabel) { - minWidth: 256px; - align: align(top); - textFg: windowSubTextFg; - style: TextStyle(defaultTextStyle) { - font: font(11px); - } -} premiumGiftBox: Box(premiumPreviewBox) { buttonPadding: margins(12px, 12px, 12px, 12px); } @@ -245,10 +233,6 @@ premiumGiftsUserpicButton: UserpicButton(defaultUserpicButton) { photoSize: 66px; photoPosition: point(-1px, -1px); } -premiumGiftsUserpicBadgeSize: size(26px, 26px); -premiumGiftsUserpicBadgeInner: 2px; -premiumGiftsUserpicBadgeFont: font(14px bold); -premiumGiftsBoostIcon: icon{{ "stories/boost_mini", windowBgActive }}; boostSkipTop: 37px; boostLimits: PremiumLimits(defaultPremiumLimits) { diff --git a/Telegram/SourceFiles/ui/widgets/slider_natural_width.h b/Telegram/SourceFiles/ui/widgets/slider_natural_width.h index f2c52aa0a9..b912f5261d 100644 --- a/Telegram/SourceFiles/ui/widgets/slider_natural_width.h +++ b/Telegram/SourceFiles/ui/widgets/slider_natural_width.h @@ -14,15 +14,7 @@ namespace Ui { class CustomWidthSlider final : public SettingsSlider { public: using Ui::SettingsSlider::SettingsSlider; - void setNaturalWidth(int w) { - _naturalWidth = w; - } - int naturalWidth() const override { - return _naturalWidth; - } - -private: - int _naturalWidth = 0; + using SettingsSlider::setNaturalWidth; }; diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 7a21118ca0..3201934f69 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 7a21118ca0964dc66673df7a2241f846ec094860 +Subproject commit 3201934f69e03d1461d8b5670ff6babbd6ca3789