Remove CenterWrap layout.

This commit is contained in:
John Preston
2025-08-18 17:23:54 +04:00
parent a39c018359
commit 313ae0f86c
63 changed files with 456 additions and 535 deletions
+7 -11
View File
@@ -142,13 +142,12 @@ void ConfirmSubscriptionBox(
const auto content = box->verticalLayout(); const auto content = box->verticalLayout();
Ui::AddSkip(content, st::confirmInvitePhotoTop); Ui::AddSkip(content, st::confirmInvitePhotoTop);
const auto userpicWrap = content->add( const auto userpic = content->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::RpWidget>(content),
content, style::al_top);
object_ptr<Ui::RpWidget>(content)));
const auto userpic = userpicWrap->entity();
const auto photoSize = st::confirmInvitePhotoSize; const auto photoSize = st::confirmInvitePhotoSize;
userpic->resize(Size(photoSize)); userpic->resize(Size(photoSize));
userpic->setNaturalWidth(photoSize);
const auto creditsIconSize = photoSize / 3; const auto creditsIconSize = photoSize / 3;
const auto creditsIconCallback = const auto creditsIconCallback =
Ui::PaintOutlinedColoredCreditsIconCallback( Ui::PaintOutlinedColoredCreditsIconCallback(
@@ -188,8 +187,8 @@ void ConfirmSubscriptionBox(
} }
auto p = QPainter(userpic); auto p = QPainter(userpic);
p.drawImage(0, 0, state->frame); p.drawImage(0, 0, state->frame);
}, userpicWrap->lifetime()); }, userpic->lifetime());
userpicWrap->setAttribute(Qt::WA_TransparentForMouseEvents); userpic->setAttribute(Qt::WA_TransparentForMouseEvents);
if (photo) { if (photo) {
state->photoMedia = photo->createMediaView(); state->photoMedia = photo->createMediaView();
state->photoMedia->wanted(Data::PhotoSize::Small, Data::FileOrigin()); state->photoMedia->wanted(Data::PhotoSize::Small, Data::FileOrigin());
@@ -197,7 +196,7 @@ void ConfirmSubscriptionBox(
session->downloaderTaskFinished( session->downloaderTaskFinished(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
userpic->update(); userpic->update();
}, userpicWrap->entity()->lifetime()); }, userpic->lifetime());
} }
} else { } else {
state->photoEmpty = std::make_unique<Ui::EmptyUserpic>( state->photoEmpty = std::make_unique<Ui::EmptyUserpic>(
@@ -219,7 +218,6 @@ void ConfirmSubscriptionBox(
box, box,
tr::lng_channel_invite_subscription_title(), tr::lng_channel_invite_subscription_title(),
st::inviteLinkSubscribeBoxTitle), st::inviteLinkSubscribeBoxTitle),
st::boxRowPadding,
style::al_top); style::al_top);
box->addRow( box->addRow(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
@@ -234,7 +232,6 @@ void ConfirmSubscriptionBox(
Ui::Text::Bold), Ui::Text::Bold),
Ui::Text::WithEntities), Ui::Text::WithEntities),
st::inviteLinkSubscribeBoxAbout), st::inviteLinkSubscribeBoxAbout),
st::boxRowPadding,
style::al_top); style::al_top);
Ui::AddSkip(content); Ui::AddSkip(content);
box->addRow( box->addRow(
@@ -250,7 +247,6 @@ void ConfirmSubscriptionBox(
}), }),
Ui::Text::RichLangValue), Ui::Text::RichLangValue),
st::inviteLinkSubscribeBoxTerms), st::inviteLinkSubscribeBoxTerms),
st::boxRowPadding,
style::al_top); style::al_top);
{ {
+5 -7
View File
@@ -183,10 +183,8 @@ void ArchiveHintBox(
const auto rect = Rect(icon.size() * 2); const auto rect = Rect(icon.size() * 2);
auto owned = object_ptr<Ui::RpWidget>(content); auto owned = object_ptr<Ui::RpWidget>(content);
owned->resize(rect.size()); owned->resize(rect.size());
const auto widget = box->addRow( owned->setNaturalWidth(rect.width());
object_ptr<Ui::CenterWrap<>>( const auto widget = box->addRow(std::move(owned), style::al_top);
content,
std::move(owned)))->entity();
widget->paintRequest( widget->paintRequest(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
auto p = Painter(widget); auto p = Painter(widget);
@@ -199,12 +197,12 @@ void ArchiveHintBox(
} }
Ui::AddSkip(content); Ui::AddSkip(content);
Ui::AddSkip(content); Ui::AddSkip(content);
box->addRow(object_ptr<Ui::CenterWrap<>>( box->addRow(
content,
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
content, content,
tr::lng_archive_hint_title(), tr::lng_archive_hint_title(),
st::boxTitle))); st::boxTitle),
style::al_top);
Ui::AddSkip(content); Ui::AddSkip(content);
Ui::AddSkip(content); Ui::AddSkip(content);
{ {
@@ -1293,7 +1293,7 @@ void EditDirectMessagesPriceBox(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>( object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
box, box,
object_ptr<Ui::VerticalLayout>(box)), object_ptr<Ui::VerticalLayout>(box)),
{}); style::margins());
wrap->toggle(savedValue.has_value(), anim::type::instant); wrap->toggle(savedValue.has_value(), anim::type::instant);
wrap->toggleOn(toggle->toggledChanges()); wrap->toggleOn(toggle->toggledChanges());
@@ -52,9 +52,8 @@ void GiftCreditsBox(
Ui::AddSkip(content); Ui::AddSkip(content);
const auto &stUser = st::premiumGiftsUserpicButton; const auto &stUser = st::premiumGiftsUserpicButton;
const auto userpicWrap = content->add( const auto userpicWrap = content->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::UserpicButton>(content, peer, stUser),
content, style::al_top);
object_ptr<Ui::UserpicButton>(content, peer, stUser)));
userpicWrap->setAttribute(Qt::WA_TransparentForMouseEvents); userpicWrap->setAttribute(Qt::WA_TransparentForMouseEvents);
Ui::AddSkip(content); Ui::AddSkip(content);
Ui::AddSkip(content); Ui::AddSkip(content);
@@ -990,12 +990,11 @@ void GiveawayInfoBox(
label->setTextColorOverride(st::windowActiveTextFg->c); label->setTextColorOverride(st::windowActiveTextFg->c);
} }
const auto result = box->addRow( const auto result = box->addRow(
object_ptr<Ui::PaddingWrap<Ui::CenterWrap<Ui::FlatLabel>>>( object_ptr<Ui::PaddingWrap<Ui::FlatLabel>>(
box.get(), box.get(),
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( std::move(label),
box.get(), QMargins(0, skip, 0, skip)),
std::move(label)), style::al_justify);
QMargins(0, skip, 0, skip)));
result->paintRequest() | rpl::start_with_next([=] { result->paintRequest() | rpl::start_with_next([=] {
auto p = QPainter(result); auto p = QPainter(result);
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
@@ -513,7 +513,7 @@ void InviteForbiddenController::setComplexCover() {
container->add( container->add(
MakeShowOrLabel(container, tr::lng_invite_upgrade_or()), MakeShowOrLabel(container, tr::lng_invite_upgrade_or()),
st::inviteForbiddenOrLabelPadding, st::inviteForbiddenOrLabelPadding,
style::al_top); style::al_justify);
} }
container->add( container->add(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
@@ -1200,7 +1200,7 @@ void EditPeerColorBox(
peer, peer,
state->index.value(), state->index.value(),
state->emojiId.value() state->emojiId.value()
), {}); ), style::margins());
auto indices = peer->session().api().peerColors().suggestedValue(); auto indices = peer->session().api().peerColors().suggestedValue();
const auto margin = st::settingsColorRadioMargin; const auto margin = st::settingsColorRadioMargin;
@@ -969,9 +969,9 @@ void Controller::rowClicked(not_null<PeerListRow*> row) {
const auto photoSize = st::boostReplaceUserpic.photoSize; const auto photoSize = st::boostReplaceUserpic.photoSize;
const auto session = &row->peer()->session(); const auto session = &row->peer()->session();
content->add(object_ptr<Ui::CenterWrap<>>( content->add(
content, Settings::SubscriptionUserpic(content, channel, photoSize),
Settings::SubscriptionUserpic(content, channel, photoSize))); style::al_top);
Ui::AddSkip(content); Ui::AddSkip(content);
Ui::AddSkip(content); Ui::AddSkip(content);
@@ -981,7 +981,6 @@ void Controller::rowClicked(not_null<PeerListRow*> row) {
box, box,
tr::lng_credits_box_subscription_title(), tr::lng_credits_box_subscription_title(),
st::creditsBoxAboutTitle), st::creditsBoxAboutTitle),
st::boxRowPadding,
style::al_top); style::al_top);
Ui::AddSkip(content); Ui::AddSkip(content);
@@ -990,7 +989,6 @@ void Controller::rowClicked(not_null<PeerListRow*> row) {
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
box, box,
st::creditsTopupPrice), st::creditsTopupPrice),
st::boxRowPadding,
style::al_top); style::al_top);
subtitle1->setMarkedText( subtitle1->setMarkedText(
tr::lng_credits_subscription_subtitle( tr::lng_credits_subscription_subtitle(
@@ -1002,11 +1000,10 @@ void Controller::rowClicked(not_null<PeerListRow*> row) {
Ui::Text::WithEntities), Ui::Text::WithEntities),
_emojiHelper.context()); _emojiHelper.context());
const auto subtitle2 = box->addRow( const auto subtitle2 = box->addRow(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
box, box,
object_ptr<Ui::FlatLabel>( st::creditsTopupPrice),
box, style::al_top);
st::creditsTopupPrice)))->entity();
session->credits().rateValue( session->credits().rateValue(
channel channel
) | rpl::start_with_next([=, currency = u"USD"_q](float64 rate) { ) | rpl::start_with_next([=, currency = u"USD"_q](float64 rate) {
@@ -1038,7 +1035,6 @@ void Controller::rowClicked(not_null<PeerListRow*> row) {
tr::lng_credits_box_out_about_link(tr::now)), tr::lng_credits_box_out_about_link(tr::now)),
Ui::Text::WithEntities), Ui::Text::WithEntities),
st::creditsBoxAboutDivider), st::creditsBoxAboutDivider),
st::boxRowPadding,
style::al_top); style::al_top);
const auto button = box->addButton(tr::lng_box_ok(), [=] { const auto button = box->addButton(tr::lng_box_ok(), [=] {
@@ -585,14 +585,14 @@ void ChannelsLimitBox(
const auto content = box->addRow( const auto content = box->addRow(
object_ptr<PeerListContent>(box, controller), object_ptr<PeerListContent>(box, controller),
{}); style::margins());
delegate->setContent(content); delegate->setContent(content);
controller->setDelegate(delegate); controller->setDelegate(delegate);
const auto count = 100; const auto count = 100;
const auto placeholder = box->addRow( const auto placeholder = box->addRow(
object_ptr<PeerListDummy>(box, count, st::defaultPeerList), object_ptr<PeerListDummy>(box, count, st::defaultPeerList),
{}); style::margins());
using namespace rpl::mappers; using namespace rpl::mappers;
controller->countValue( controller->countValue(
@@ -676,14 +676,14 @@ void PublicLinksLimitBox(
const auto content = box->addRow( const auto content = box->addRow(
object_ptr<PeerListContent>(box, controller), object_ptr<PeerListContent>(box, controller),
{}); style::margins());
delegate->setContent(content); delegate->setContent(content);
controller->setDelegate(delegate); controller->setDelegate(delegate);
const auto count = defaultLimit; const auto count = defaultLimit;
const auto placeholder = box->addRow( const auto placeholder = box->addRow(
object_ptr<PeerListDummy>(box, count, st::defaultPeerList), object_ptr<PeerListDummy>(box, count, st::defaultPeerList),
{}); style::margins());
using namespace rpl::mappers; using namespace rpl::mappers;
controller->countValue( controller->countValue(
@@ -902,7 +902,7 @@ void PreviewBox(
const auto outer = box->addRow( const auto outer = box->addRow(
ChatBackPreview(box, size.height(), back), ChatBackPreview(box, size.height(), back),
{}); style::margins());
struct Hiding { struct Hiding {
not_null<Ui::RpWidget*> widget; not_null<Ui::RpWidget*> widget;
@@ -348,9 +348,9 @@ void SendCreditsBox(
}, ministarsContainer->lifetime()); }, ministarsContainer->lifetime());
} }
const auto thumb = box->addRow(object_ptr<Ui::CenterWrap<>>( const auto thumb = box->addRow(
content, SendCreditsThumbnail(content, session, form.get(), photoSize),
SendCreditsThumbnail(content, session, form.get(), photoSize))); style::al_top);
thumb->setAttribute(Qt::WA_TransparentForMouseEvents); thumb->setAttribute(Qt::WA_TransparentForMouseEvents);
if (form->invoice.subscriptionPeriod) { if (form->invoice.subscriptionPeriod) {
const auto badge = SendCreditsBadge(content, form->invoice.amount); const auto badge = SendCreditsBadge(content, form->invoice.amount);
@@ -371,16 +371,14 @@ void SendCreditsBox(
? rpl::single(form->title) ? rpl::single(form->title)
: tr::lng_credits_box_out_title(), : tr::lng_credits_box_out_title(),
st::settingsPremiumUserTitle), st::settingsPremiumUserTitle),
st::boxRowPadding,
style::al_top); style::al_top);
if (form->invoice.subscriptionPeriod && form->botId && form->photo) { if (form->invoice.subscriptionPeriod && form->botId && form->photo) {
Ui::AddSkip(content); Ui::AddSkip(content);
Ui::AddSkip(content); Ui::AddSkip(content);
const auto bot = session->data().user(form->botId); const auto bot = session->data().user(form->botId);
box->addRow( box->addRow(
object_ptr<Ui::CenterWrap<>>( Ui::CreatePeerBubble(box, bot),
box, style::al_top);
Ui::CreatePeerBubble(box, bot)));
Ui::AddSkip(content); Ui::AddSkip(content);
} }
Ui::AddSkip(content); Ui::AddSkip(content);
@@ -389,7 +387,6 @@ void SendCreditsBox(
box, box,
SendCreditsConfirmText(session, form.get()), SendCreditsConfirmText(session, form.get()),
st::creditsBoxAbout), st::creditsBoxAbout),
st::boxRowPadding,
style::al_top); style::al_top);
Ui::AddSkip(content); Ui::AddSkip(content);
Ui::AddSkip(content); Ui::AddSkip(content);
+14 -16
View File
@@ -3151,10 +3151,9 @@ void GiftBox(
&& uniqueDisallowed; && uniqueDisallowed;
content->add( content->add(
object_ptr<CenterWrap<UserpicButton>>( object_ptr<UserpicButton>(content, peer, stUser),
content, style::al_top
object_ptr<UserpicButton>(content, peer, stUser)) )->setClickedCallback([=] { window->showPeerInfo(peer); });
)->entity()->setClickedCallback([=] { window->showPeerInfo(peer); });
AddSkip(content); AddSkip(content);
AddSkip(content); AddSkip(content);
@@ -4919,19 +4918,18 @@ void UpgradeBox(
object_ptr<PlainShadow>(container), object_ptr<PlainShadow>(container),
st::boxRowPadding + QMargins(0, skip, 0, skip)); st::boxRowPadding + QMargins(0, skip, 0, skip));
const auto checkbox = container->add( const auto checkbox = container->add(
object_ptr<CenterWrap<Checkbox>>( object_ptr<Checkbox>(
container, container,
object_ptr<Checkbox>( (args.canAddComment
container, ? tr::lng_gift_upgrade_add_comment(tr::now)
(args.canAddComment : args.canAddSender
? tr::lng_gift_upgrade_add_comment(tr::now) ? tr::lng_gift_upgrade_add_sender(tr::now)
: args.canAddSender : args.canAddMyComment
? tr::lng_gift_upgrade_add_sender(tr::now) ? tr::lng_gift_upgrade_add_my_comment(tr::now)
: args.canAddMyComment : tr::lng_gift_upgrade_add_my(tr::now)),
? tr::lng_gift_upgrade_add_my_comment(tr::now) args.addDetailsDefault),
: tr::lng_gift_upgrade_add_my(tr::now)), st::defaultCheckbox.margin,
args.addDetailsDefault)), style::al_top);
st::defaultCheckbox.margin)->entity();
checkbox->checkedChanges() | rpl::start_with_next([=](bool checked) { checkbox->checkedChanges() | rpl::start_with_next([=](bool checked) {
state->preserveDetails = checked; state->preserveDetails = checked;
}, checkbox->lifetime()); }, checkbox->lifetime());
+2 -2
View File
@@ -324,7 +324,7 @@ void UsernamesBox(
const auto editor = box->addRow( const auto editor = box->addRow(
object_ptr<UsernameEditor>(box, peer), object_ptr<UsernameEditor>(box, peer),
{}); style::margins());
editor->setEnabled(!isBot); editor->setEnabled(!isBot);
box->setFocusCallback([=] { editor->setInnerFocus(); }); box->setFocusCallback([=] { editor->setInnerFocus(); });
@@ -366,7 +366,7 @@ void UsernamesBox(
!isBot !isBot
? [=] { box->scrollToY(0); editor->setInnerFocus(); } ? [=] { box->scrollToY(0); editor->setInnerFocus(); }
: Fn<void()>(nullptr)), : Fn<void()>(nullptr)),
{}); style::margins());
const auto finish = [=] { const auto finish = [=] {
list->save( list->save(
@@ -825,7 +825,7 @@ void ShowCallsBox(not_null<::Window::SessionController*> window) {
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>( object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
box, box,
object_ptr<Ui::VerticalLayout>(box)), object_ptr<Ui::VerticalLayout>(box)),
{}); style::margins());
groupCalls->hide(anim::type::instant); groupCalls->hide(anim::type::instant);
groupCalls->toggleOn(state->groupCallsController.shownValue()); groupCalls->toggleOn(state->groupCallsController.shownValue());
@@ -833,8 +833,7 @@ void ShowCallsBox(not_null<::Window::SessionController*> window) {
groupCalls->entity(), groupCalls->entity(),
tr::lng_call_box_groupcalls_subtitle()); tr::lng_call_box_groupcalls_subtitle());
state->groupCallsDelegate.setContent(groupCalls->entity()->add( state->groupCallsDelegate.setContent(groupCalls->entity()->add(
object_ptr<PeerListContent>(box, &state->groupCallsController), object_ptr<PeerListContent>(box, &state->groupCallsController)));
{}));
state->groupCallsController.setDelegate(&state->groupCallsDelegate); state->groupCallsController.setDelegate(&state->groupCallsDelegate);
Ui::AddSkip(groupCalls->entity()); Ui::AddSkip(groupCalls->entity());
Ui::AddDivider(groupCalls->entity()); Ui::AddDivider(groupCalls->entity());
@@ -853,7 +852,7 @@ void ShowCallsBox(not_null<::Window::SessionController*> window) {
const auto content = box->addRow( const auto content = box->addRow(
object_ptr<PeerListContent>(box, &state->callsController), object_ptr<PeerListContent>(box, &state->callsController),
{}); style::margins());
state->callsDelegate.setContent(content); state->callsDelegate.setContent(content);
state->callsController.setDelegate(&state->callsDelegate); state->callsController.setDelegate(&state->callsDelegate);
@@ -116,13 +116,12 @@ void ConferenceCallJoinConfirm(
st::boxRowPadding + st::confcallLinkHeaderIconPadding); st::boxRowPadding + st::confcallLinkHeaderIconPadding);
box->addRow( box->addRow(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
box, box,
object_ptr<Ui::FlatLabel>( tr::lng_confcall_join_title(),
box, st::boxTitle),
tr::lng_confcall_join_title(), st::boxRowPadding + st::confcallLinkTitlePadding,
st::boxTitle)), style::al_top);
st::boxRowPadding + st::confcallLinkTitlePadding);
const auto wrapName = [&](not_null<PeerData*> peer) { const auto wrapName = [&](not_null<PeerData*> peer) {
return rpl::single(Ui::Text::Bold(peer->shortName())); return rpl::single(Ui::Text::Bold(peer->shortName()));
}; };
@@ -323,13 +322,12 @@ void ShowConferenceCallLinkBox(
Info::BotStarRef::CreateLinkHeaderIcon(box, &call->session()), Info::BotStarRef::CreateLinkHeaderIcon(box, &call->session()),
st::boxRowPadding + st::confcallLinkHeaderIconPadding); st::boxRowPadding + st::confcallLinkHeaderIconPadding);
box->addRow( box->addRow(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
box, box,
object_ptr<Ui::FlatLabel>( tr::lng_confcall_link_title(),
box, st.box ? st.box->title : st::boxTitle),
tr::lng_confcall_link_title(), st::boxRowPadding + st::confcallLinkTitlePadding,
st.box ? st.box->title : st::boxTitle)), style::al_top);
st::boxRowPadding + st::confcallLinkTitlePadding);
box->addRow( box->addRow(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
box, box,
@@ -1042,13 +1042,12 @@ not_null<Ui::RpWidget*> CreateReActivateHeader(not_null<QWidget*> parent) {
st::boxRowPadding + st::confcallLinkHeaderIconPadding); st::boxRowPadding + st::confcallLinkHeaderIconPadding);
result->add( result->add(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
result, result,
object_ptr<Ui::FlatLabel>( tr::lng_confcall_inactive_title(),
result, st::boxTitle),
tr::lng_confcall_inactive_title(), st::boxRowPadding + st::confcallLinkTitlePadding,
st::boxTitle)), style::al_top);
st::boxRowPadding + st::confcallLinkTitlePadding);
result->add( result->add(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
result, result,
@@ -4151,14 +4151,13 @@ void InnerWidget::refreshEmpty() {
.name = u"no_chats"_q, .name = u"no_chats"_q,
.sizeOverride = Size(st::changePhoneIconSize), .sizeOverride = Size(st::changePhoneIconSize),
}); });
_emptyList->add(std::move(icon.widget), {}, style::al_top); _emptyList->add(std::move(icon.widget), style::al_top);
Ui::AddSkip(_emptyList); Ui::AddSkip(_emptyList);
_emptyList->add( _emptyList->add(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
_emptyList, _emptyList,
tr::lng_no_conversations(), tr::lng_no_conversations(),
st::dialogEmptyButtonLabel), st::dialogEmptyButtonLabel),
{},
style::al_top); style::al_top);
if (_state == WidgetState::Default) { if (_state == WidgetState::Default) {
icon.animate(anim::repeat::once); icon.animate(anim::repeat::once);
@@ -186,7 +186,6 @@ void PostsSearchIntro::setup() {
_content.get(), _content.get(),
rpl::single(QString()), rpl::single(QString()),
st::postsSearchIntroButton), st::postsSearchIntroButton),
{},
style::al_top); style::al_top);
_button->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); _button->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
_footer = _content->add( _footer = _content->add(
@@ -1075,7 +1075,7 @@ void DraftOptionsBox(
state->wrap = box->addRow( state->wrap = box->addRow(
object_ptr<PreviewWrap>(box, args.history), object_ptr<PreviewWrap>(box, args.history),
{}); style::margins());
state->wrap->draggingScrollDelta( state->wrap->draggingScrollDelta(
) | rpl::start_with_next([=](int delta) { ) | rpl::start_with_next([=](int delta) {
box->scrollByDraggingDelta(delta); box->scrollByDraggingDelta(delta);
@@ -394,7 +394,6 @@ void ChooseSuggestPriceBox(
box, box,
std::move(title), std::move(title),
st::settingsPremiumUserTitle), st::settingsPremiumUserTitle),
st::boxRowPadding,
style::al_top); style::al_top);
} }
@@ -446,13 +446,12 @@ object_ptr<Ui::BoxContent> StarRefLinkBox(
CreateLinkIcon(box, &bot->session(), row.state.users), CreateLinkIcon(box, &bot->session(), row.state.users),
st::boxRowPadding + st::starrefJoinUserpicsPadding); st::boxRowPadding + st::starrefJoinUserpicsPadding);
box->addRow( box->addRow(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
box, box,
object_ptr<Ui::FlatLabel>( tr::lng_star_ref_link_title(),
box, st::boxTitle),
tr::lng_star_ref_link_title(), st::boxRowPadding + st::starrefJoinTitlePadding,
st::boxTitle)), style::al_top);
st::boxRowPadding + st::starrefJoinTitlePadding);
box->addRow( box->addRow(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
box, box,
@@ -470,7 +469,6 @@ object_ptr<Ui::BoxContent> StarRefLinkBox(
FormatForProgramDuration(program.durationMonths), FormatForProgramDuration(program.durationMonths),
Ui::Text::WithEntities), Ui::Text::WithEntities),
st::starrefCenteredText), st::starrefCenteredText),
st::boxRowPadding,
style::al_top); style::al_top);
Ui::AddSkip(box->verticalLayout(), st::defaultVerticalListSkip * 3); Ui::AddSkip(box->verticalLayout(), st::defaultVerticalListSkip * 3);
@@ -480,7 +478,6 @@ object_ptr<Ui::BoxContent> StarRefLinkBox(
box, box,
tr::lng_star_ref_link_recipient(), tr::lng_star_ref_link_recipient(),
st::starrefCenteredText), st::starrefCenteredText),
st::boxRowPadding,
style::al_top); style::al_top);
Ui::AddSkip(box->verticalLayout()); Ui::AddSkip(box->verticalLayout());
box->addRow(object_ptr<Ui::AbstractButton>::fromRaw( box->addRow(object_ptr<Ui::AbstractButton>::fromRaw(
@@ -579,13 +576,12 @@ object_ptr<Ui::BoxContent> JoinStarRefBox(
}, box->lifetime()); }, box->lifetime());
box->addRow( box->addRow(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
box, box,
object_ptr<Ui::FlatLabel>( tr::lng_star_ref_title(),
box, st::boxTitle),
tr::lng_star_ref_title(), st::boxRowPadding + st::starrefJoinTitlePadding,
st::boxTitle)), style::al_top);
st::boxRowPadding + st::starrefJoinTitlePadding);
box->addRow( box->addRow(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
box, box,
@@ -599,7 +595,6 @@ object_ptr<Ui::BoxContent> JoinStarRefBox(
FormatForProgramDuration(program.durationMonths), FormatForProgramDuration(program.durationMonths),
Ui::Text::WithEntities), Ui::Text::WithEntities),
st::starrefCenteredText), st::starrefCenteredText),
st::boxRowPadding,
style::al_top); style::al_top);
Ui::AddSkip(box->verticalLayout(), st::defaultVerticalListSkip * 3); Ui::AddSkip(box->verticalLayout(), st::defaultVerticalListSkip * 3);
@@ -641,7 +636,6 @@ object_ptr<Ui::BoxContent> JoinStarRefBox(
box, box,
tr::lng_star_ref_link_recipient(), tr::lng_star_ref_link_recipient(),
st::starrefCenteredText), st::starrefCenteredText),
st::boxRowPadding,
style::al_top); style::al_top);
Ui::AddSkip(box->verticalLayout()); Ui::AddSkip(box->verticalLayout());
const auto recipientWrap = box->addRow( const auto recipientWrap = box->addRow(
@@ -215,7 +215,7 @@ void AddPremiumTopBarWithDefaultTitleBar(
+ st::defaultVerticalListSkip, + st::defaultVerticalListSkip,
st::boxDividerBg, st::boxDividerBg,
RectPart::Bottom), RectPart::Bottom),
{}); style::margins());
bar->setPaused(true); bar->setPaused(true);
bar->setRoundEdges(false); bar->setRoundEdges(false);
bar->setMaximumHeight(st::giveawayGiftCodeTopHeight); bar->setMaximumHeight(st::giveawayGiftCodeTopHeight);
@@ -348,12 +348,11 @@ void CreateGiveawayBox(
Ui::AddSkip(container); Ui::AddSkip(container);
Ui::AddSkip(container); Ui::AddSkip(container);
container->add( container->add(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
box, box,
object_ptr<Ui::FlatLabel>( tr::lng_contacts_loading(),
box, st::giveawayLoadingLabel),
tr::lng_contacts_loading(), style::al_top);
st::giveawayLoadingLabel)));
Ui::AddSkip(container); Ui::AddSkip(container);
Ui::AddSkip(container); Ui::AddSkip(container);
} }
@@ -177,12 +177,11 @@ void SelectCountriesBox(
Ui::AddSkip(container); Ui::AddSkip(container);
Ui::AddSkip(container); Ui::AddSkip(container);
container->add( container->add(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
container, container,
object_ptr<Ui::FlatLabel>( tr::lng_search_messages_none(),
container, st::membersAbout),
tr::lng_search_messages_none(), style::al_top);
st::membersAbout)));
Ui::AddSkip(container); Ui::AddSkip(container);
Ui::AddSkip(container); Ui::AddSkip(container);
} }
@@ -140,14 +140,12 @@ void AddHeader(
} }
void AddRecipient(not_null<Ui::GenericBox*> box, const TextWithEntities &t) { void AddRecipient(not_null<Ui::GenericBox*> box, const TextWithEntities &t) {
const auto wrap = box->addRow( const auto container = box->addRow(
object_ptr<Ui::CenterWrap<Ui::RoundButton>>( object_ptr<Ui::RoundButton>(
box, box,
object_ptr<Ui::RoundButton>( rpl::single(QString()),
box, st::channelEarnHistoryRecipientButton),
rpl::single(QString()), style::al_top);
st::channelEarnHistoryRecipientButton)));
const auto container = wrap->entity();
const auto label = Ui::CreateChild<Ui::FlatLabel>( const auto label = Ui::CreateChild<Ui::FlatLabel>(
container, container,
rpl::single(t), rpl::single(t),
@@ -449,10 +447,10 @@ void InnerWidget::fill() {
const auto rect = Rect(icon.size() * 1.4); const auto rect = Rect(icon.size() * 1.4);
auto owned = object_ptr<Ui::RpWidget>(content); auto owned = object_ptr<Ui::RpWidget>(content);
owned->resize(rect.size()); owned->resize(rect.size());
owned->setNaturalWidth(rect.width());
const auto widget = box->addRow( const auto widget = box->addRow(
object_ptr<Ui::CenterWrap<>>( std::move(owned),
content, style::al_top);
std::move(owned)))->entity();
widget->paintRequest( widget->paintRequest(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
auto p = Painter(widget); auto p = Painter(widget);
@@ -465,14 +463,13 @@ void InnerWidget::fill() {
} }
Ui::AddSkip(content); Ui::AddSkip(content);
Ui::AddSkip(content); Ui::AddSkip(content);
box->addRow(object_ptr<Ui::CenterWrap<>>( box->addRow(object_ptr<Ui::FlatLabel>(
content, content,
object_ptr<Ui::FlatLabel>( bot
content, ? tr::lng_channel_earn_bot_learn_title()
bot : tr::lng_channel_earn_learn_title(),
? tr::lng_channel_earn_bot_learn_title() st::boxTitle),
: tr::lng_channel_earn_learn_title(), style::al_top);
st::boxTitle)));
Ui::AddSkip(content); Ui::AddSkip(content);
Ui::AddSkip(content); Ui::AddSkip(content);
Ui::AddSkip(content); Ui::AddSkip(content);
@@ -540,17 +537,17 @@ void InnerWidget::fill() {
Ui::AddSkip(content); Ui::AddSkip(content);
{ {
const auto l = box->addRow( const auto l = box->addRow(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
content, content,
object_ptr<Ui::FlatLabel>( tr::lng_channel_earn_learn_coin_title(
content, lt_emoji,
tr::lng_channel_earn_learn_coin_title( rpl::single(
lt_emoji, Ui::Text::Link(bigCurrencyIcon, 1)),
rpl::single( Ui::Text::RichLangValue),
Ui::Text::Link(bigCurrencyIcon, 1)), st::boxTitle,
Ui::Text::RichLangValue st::defaultPopupMenu,
), emojiHelper.context()),
st::boxTitle)))->entity(); style::al_top);
const auto diamonds = l->lifetime().make_state<int>(0); const auto diamonds = l->lifetime().make_state<int>(0);
l->setLink(1, std::make_shared<LambdaClickHandler>([=] { l->setLink(1, std::make_shared<LambdaClickHandler>([=] {
const auto count = (*diamonds); const auto count = (*diamonds);
@@ -837,9 +834,8 @@ void InnerWidget::fill() {
Ui::AddSkip(container); Ui::AddSkip(container);
const auto labels = container->add( const auto labels = container->add(
object_ptr<Ui::CenterWrap<Ui::RpWidget>>( object_ptr<Ui::RpWidget>(container),
container, style::al_top);
object_ptr<Ui::RpWidget>(container)))->entity();
const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>( const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>(
labels, labels,
@@ -864,6 +860,8 @@ void InnerWidget::fill() {
labels->resize( labels->resize(
majorSize.width() + minorSize.width(), majorSize.width() + minorSize.width(),
majorSize.height()); majorSize.height());
labels->setNaturalWidth(
majorSize.width() + minorSize.width());
majorLabel->moveToLeft(0, 0); majorLabel->moveToLeft(0, 0);
minorLabel->moveToRight( minorLabel->moveToRight(
0, 0,
@@ -873,12 +871,11 @@ void InnerWidget::fill() {
Ui::AddSkip(container); Ui::AddSkip(container);
container->add( container->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(
container, container,
object_ptr<Ui::FlatLabel>( ToUsd(value, multiplier, 0),
container, st::channelEarnOverviewSubMinorLabel),
ToUsd(value, multiplier, 0), style::al_top);
st::channelEarnOverviewSubMinorLabel)));
Ui::AddSkip(container); Ui::AddSkip(container);
@@ -888,7 +885,8 @@ void InnerWidget::fill() {
container, container,
rpl::never<QString>(), rpl::never<QString>(),
stButton), stButton),
st::boxRowPadding); st::boxRowPadding,
style::al_justify);
const auto label = Ui::CreateChild<Ui::FlatLabel>( const auto label = Ui::CreateChild<Ui::FlatLabel>(
button, button,
@@ -1156,9 +1154,8 @@ void InnerWidget::fill() {
Ui::AddSkip(box->verticalLayout()); Ui::AddSkip(box->verticalLayout());
Ui::AddSkip(box->verticalLayout()); Ui::AddSkip(box->verticalLayout());
const auto labels = box->addRow( const auto labels = box->addRow(
object_ptr<Ui::CenterWrap<Ui::RpWidget>>( object_ptr<Ui::RpWidget>(box),
box, style::al_top);
object_ptr<Ui::RpWidget>(box)))->entity();
const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>( const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>(
labels, labels,
@@ -1187,6 +1184,8 @@ void InnerWidget::fill() {
labels->resize( labels->resize(
majorSize.width() + minorSize.width(), majorSize.width() + minorSize.width(),
majorSize.height()); majorSize.height());
labels->setNaturalWidth(
majorSize.width() + minorSize.width());
majorLabel->moveToLeft(0, 0); majorLabel->moveToLeft(0, 0);
minorLabel->moveToRight( minorLabel->moveToRight(
0, 0,
@@ -1194,12 +1193,12 @@ void InnerWidget::fill() {
}, box->lifetime()); }, box->lifetime());
Ui::AddSkip(box->verticalLayout()); Ui::AddSkip(box->verticalLayout());
box->addRow(object_ptr<Ui::CenterWrap<>>( box->addRow(
box,
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
box, box,
dateText, dateText,
st::channelEarnHistorySubLabel))); st::channelEarnHistorySubLabel),
style::al_top);
Ui::AddSkip(box->verticalLayout()); Ui::AddSkip(box->verticalLayout());
Ui::AddSkip(box->verticalLayout()); Ui::AddSkip(box->verticalLayout());
AddChannelEarnTable( AddChannelEarnTable(
@@ -1208,14 +1207,14 @@ void InnerWidget::fill() {
entry); entry);
Ui::AddSkip(box->verticalLayout()); Ui::AddSkip(box->verticalLayout());
Ui::AddSkip(box->verticalLayout()); Ui::AddSkip(box->verticalLayout());
box->addRow(object_ptr<Ui::CenterWrap<>>( box->addRow(
box,
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
box, box,
isIn isIn
? tr::lng_channel_earn_history_in_about() ? tr::lng_channel_earn_history_in_about()
: tr::lng_channel_earn_history_out(), : tr::lng_channel_earn_history_out(),
st::channelEarnHistoryDescriptionLabel))); st::channelEarnHistoryDescriptionLabel),
style::al_top);
Ui::AddSkip(box->verticalLayout()); Ui::AddSkip(box->verticalLayout());
if (isIn) { if (isIn) {
Ui::AddSkip(box->verticalLayout()); Ui::AddSkip(box->verticalLayout());
@@ -1226,9 +1225,8 @@ void InnerWidget::fill() {
} }
if (isIn) { if (isIn) {
box->addRow( box->addRow(
object_ptr<Ui::CenterWrap<>>( Ui::CreatePeerBubble(box, peer),
box, style::al_top);
Ui::CreatePeerBubble(box, peer)));
} }
const auto closeBox = [=] { box->closeBox(); }; const auto closeBox = [=] { box->closeBox(); };
{ {
@@ -979,30 +979,27 @@ void InnerWidget::refreshAbout() {
} else if (collectionCanAdd) { } else if (collectionCanAdd) {
auto about = std::make_unique<Ui::VerticalLayout>(this); auto about = std::make_unique<Ui::VerticalLayout>(this);
about->add( about->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(
about.get(), about.get(),
object_ptr<Ui::FlatLabel>( tr::lng_gift_collection_empty_title(),
about.get(), st::collectionEmptyTitle),
tr::lng_gift_collection_empty_title(), st::collectionEmptyTitleMargin,
st::collectionEmptyTitle)), style::al_top);
st::collectionEmptyTitleMargin);
about->add( about->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(
about.get(), about.get(),
object_ptr<Ui::FlatLabel>( tr::lng_gift_collection_empty_text(),
about.get(), st::collectionEmptyText),
tr::lng_gift_collection_empty_text(), st::collectionEmptyTextMargin,
st::collectionEmptyText)), style::al_top);
st::collectionEmptyTextMargin);
const auto button = about->add( const auto button = about->add(
object_ptr<Ui::CenterWrap<Ui::RoundButton>>( object_ptr<Ui::RoundButton>(
about.get(), about.get(),
object_ptr<Ui::RoundButton>( rpl::single(QString()),
about.get(), st::collectionEmptyButton),
rpl::single(QString()), st::collectionEmptyAddMargin,
st::collectionEmptyButton)), style::al_top);
st::collectionEmptyAddMargin)->entity();
button->setText(tr::lng_gift_collection_add_button( button->setText(tr::lng_gift_collection_add_button(
) | rpl::map([](const QString &text) { ) | rpl::map([](const QString &text) {
return Ui::Text::IconEmoji(&st::collectionAddIcon).append(text); return Ui::Text::IconEmoji(&st::collectionAddIcon).append(text);
@@ -1081,7 +1078,7 @@ void InnerWidget::editCollectionGifts(int id) {
state->descriptor.value(), state->descriptor.value(),
id, id,
(_all.filter == Filter()) ? _all : Entries()), (_all.filter == Filter()) ? _all : Entries()),
{}); style::margins());
state->changes = content->changes(); state->changes = content->changes();
content->descriptorChanges( content->descriptorChanges(
@@ -1505,6 +1502,7 @@ Widget::Widget(QWidget *parent, not_null<Controller*> controller)
controller->parentController(), controller->parentController(),
controller->giftsPeer(), controller->giftsPeer(),
_descriptor.value())); _descriptor.value()));
_emptyCollectionShown = _inner->collectionEmptyValue();
_inner->notifyEnabled( _inner->notifyEnabled(
) | rpl::take(1) | rpl::start_with_next([=](bool enabled) { ) | rpl::take(1) | rpl::start_with_next([=](bool enabled) {
_notifyEnabled = enabled; _notifyEnabled = enabled;
@@ -1518,7 +1516,10 @@ Widget::Widget(QWidget *parent, not_null<Controller*> controller)
scrollTo({ 0, 0 }); scrollTo({ 0, 0 });
}, _inner->lifetime()); }, _inner->lifetime());
_descriptor.value() | rpl::start_with_next([=] { rpl::combine(
_descriptor.value(),
_emptyCollectionShown.value()
) | rpl::start_with_next([=] {
refreshBottom(); refreshBottom();
}, _inner->lifetime()); }, _inner->lifetime());
} }
@@ -1527,22 +1528,22 @@ void Widget::refreshBottom() {
const auto notify = _notifyEnabled.has_value(); const auto notify = _notifyEnabled.has_value();
const auto descriptor = _descriptor.current(); const auto descriptor = _descriptor.current();
const auto shownId = descriptor.collectionId; const auto shownId = descriptor.collectionId;
const auto withButton = shownId && peer()->canManageGifts(); const auto withButton = shownId
&& peer()->canManageGifts()
&& !_emptyCollectionShown.current();
const auto wasBottom = _pinnedToBottom ? _pinnedToBottom->height() : 0; const auto wasBottom = _pinnedToBottom ? _pinnedToBottom->height() : 0;
delete _pinnedToBottom.data(); delete _pinnedToBottom.data();
if (!notify && !withButton) { if (!notify && !withButton) {
setScrollBottomSkip(0); setScrollBottomSkip(0);
_hasPinnedToBottom = false; _hasPinnedToBottom = false;
} else if (withButton) { } else if (withButton) {
setupBottomButton(wasBottom, _inner->collectionEmptyValue()); setupBottomButton(wasBottom);
} else { } else {
setupNotifyCheckbox(wasBottom, *_notifyEnabled); setupNotifyCheckbox(wasBottom, *_notifyEnabled);
} }
} }
void Widget::setupBottomButton( void Widget::setupBottomButton(int wasBottomHeight) {
int wasBottomHeight,
rpl::producer<bool> hidden) {
_pinnedToBottom = Ui::CreateChild<Ui::SlideWrap<Ui::RpWidget>>( _pinnedToBottom = Ui::CreateChild<Ui::SlideWrap<Ui::RpWidget>>(
this, this,
object_ptr<Ui::RpWidget>(this)); object_ptr<Ui::RpWidget>(this));
@@ -1561,10 +1562,8 @@ void Widget::setupBottomButton(
) | rpl::map([](const QString &text) { ) | rpl::map([](const QString &text) {
return Ui::Text::IconEmoji(&st::collectionAddIcon).append(text); return Ui::Text::IconEmoji(&st::collectionAddIcon).append(text);
})); }));
std::move(hidden) | rpl::start_with_next([=](bool hidden) { button->show();
button->setVisible(!hidden); _hasPinnedToBottom = true;
_hasPinnedToBottom = !hidden;
}, button->lifetime());
button->setClickedCallback([=] { button->setClickedCallback([=] {
if (const auto id = _descriptor.current().collectionId) { if (const auto id = _descriptor.current().collectionId) {
@@ -105,12 +105,13 @@ private:
std::shared_ptr<ContentMemento> doCreateMemento() override; std::shared_ptr<ContentMemento> doCreateMemento() override;
void setupNotifyCheckbox(int wasBottomHeight, bool enabled); void setupNotifyCheckbox(int wasBottomHeight, bool enabled);
void setupBottomButton(int wasBottomHeight, rpl::producer<bool> hidden); void setupBottomButton(int wasBottomHeight);
void refreshBottom(); void refreshBottom();
InnerWidget *_inner = nullptr; InnerWidget *_inner = nullptr;
QPointer<Ui::SlideWrap<Ui::RpWidget>> _pinnedToBottom; QPointer<Ui::SlideWrap<Ui::RpWidget>> _pinnedToBottom;
rpl::variable<bool> _hasPinnedToBottom; rpl::variable<bool> _hasPinnedToBottom;
rpl::variable<bool> _emptyCollectionShown;
rpl::variable<Descriptor> _descriptor; rpl::variable<Descriptor> _descriptor;
std::optional<bool> _notifyEnabled; std::optional<bool> _notifyEnabled;
bool _shown = false; bool _shown = false;
@@ -1985,7 +1985,8 @@ void DetailsFiller::setupMainApp() {
_wrap, _wrap,
tr::lng_profile_open_app(), tr::lng_profile_open_app(),
st::infoOpenApp), st::infoOpenApp),
st::infoOpenAppMargin); st::infoOpenAppMargin,
style::al_justify);
button->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); button->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
const auto user = _peer->asUser(); const auto user = _peer->asUser();
@@ -590,30 +590,29 @@ void FillLoading(
content->add(std::move(icon.widget)); content->add(std::move(icon.widget));
content->add( content->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(
content, content,
object_ptr<Ui::FlatLabel>( (type == LoadingType::Boosts)
content, ? tr::lng_stats_boosts_loading()
(type == LoadingType::Boosts) : (type == LoadingType::Earn)
? tr::lng_stats_boosts_loading() ? tr::lng_stats_earn_loading()
: (type == LoadingType::Earn) : tr::lng_stats_loading(),
? tr::lng_stats_earn_loading() st::changePhoneTitle),
: tr::lng_stats_loading(), st::changePhoneTitlePadding + st::boxRowPadding,
st::changePhoneTitle)), style::al_top);
st::changePhoneTitlePadding + st::boxRowPadding);
content->add( content->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(
content, content,
object_ptr<Ui::FlatLabel>( (type == LoadingType::Boosts)
content, ? tr::lng_stats_boosts_loading_subtext()
(type == LoadingType::Boosts) : (type == LoadingType::Earn)
? tr::lng_stats_boosts_loading_subtext() ? tr::lng_stats_earn_loading_subtext()
: (type == LoadingType::Earn) : tr::lng_stats_loading_subtext(),
? tr::lng_stats_earn_loading_subtext() st::statisticsLoadingSubtext),
: tr::lng_stats_loading_subtext(), st::changePhoneDescriptionPadding + st::boxRowPadding,
st::statisticsLoadingSubtext)), style::al_top
st::changePhoneDescriptionPadding + st::boxRowPadding); )->setTryMakeSimilarLines(true);
Ui::AddSkip(content, st::settingsBlockedListIconPadding.top()); Ui::AddSkip(content, st::settingsBlockedListIconPadding.top());
} }
@@ -586,30 +586,27 @@ void InnerWidget::refreshEmpty() {
if (albumCanAdd) { if (albumCanAdd) {
auto empty = object_ptr<Ui::VerticalLayout>(this); auto empty = object_ptr<Ui::VerticalLayout>(this);
empty->add( empty->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(
empty.get(), empty.get(),
object_ptr<Ui::FlatLabel>( tr::lng_stories_album_empty_title(),
empty.get(), st::collectionEmptyTitle),
tr::lng_stories_album_empty_title(), st::collectionEmptyTitleMargin,
st::collectionEmptyTitle)), style::al_top);
st::collectionEmptyTitleMargin);
empty->add( empty->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(
empty.get(), empty.get(),
object_ptr<Ui::FlatLabel>( tr::lng_stories_album_empty_text(),
empty.get(), st::collectionEmptyText),
tr::lng_stories_album_empty_text(), st::collectionEmptyTextMargin,
st::collectionEmptyText)), style::al_top);
st::collectionEmptyTextMargin);
const auto button = empty->add( const auto button = empty->add(
object_ptr<Ui::CenterWrap<Ui::RoundButton>>( object_ptr<Ui::RoundButton>(
empty.get(), empty.get(),
object_ptr<Ui::RoundButton>( rpl::single(QString()),
empty.get(), st::collectionEmptyButton),
rpl::single(QString()), st::collectionEmptyAddMargin,
st::collectionEmptyButton)), style::al_top);
st::collectionEmptyAddMargin)->entity();
button->setText(tr::lng_stories_album_add_button( button->setText(tr::lng_stories_album_add_button(
) | rpl::map([](const QString &text) { ) | rpl::map([](const QString &text) {
return Ui::Text::IconEmoji(&st::collectionAddIcon).append(text); return Ui::Text::IconEmoji(&st::collectionAddIcon).append(text);
@@ -65,6 +65,7 @@ Widget::Widget(
controller, controller,
_albumId.value(), _albumId.value(),
controller->key().storiesAddToAlbumId())); controller->key().storiesAddToAlbumId()));
_emptyAlbumShown = _inner->albumEmptyValue();
_inner->albumIdChanges() | rpl::start_with_next([=](int id) { _inner->albumIdChanges() | rpl::start_with_next([=](int id) {
controller->showSection( controller->showSection(
Make(controller->storiesPeer(), id), Make(controller->storiesPeer(), id),
@@ -76,7 +77,10 @@ Widget::Widget(
scrollTo(request); scrollTo(request);
}, _inner->lifetime()); }, _inner->lifetime());
_albumId.value() | rpl::start_with_next([=] { rpl::combine(
_albumId.value(),
_emptyAlbumShown.value()
) | rpl::start_with_next([=] {
refreshBottom(); refreshBottom();
}, _inner->lifetime()); }, _inner->lifetime());
} }
@@ -133,20 +137,19 @@ void Widget::refreshBottom() {
const auto albumId = _albumId.current(); const auto albumId = _albumId.current();
const auto withButton = (albumId != Data::kStoriesAlbumIdSaved) const auto withButton = (albumId != Data::kStoriesAlbumIdSaved)
&& (albumId != Data::kStoriesAlbumIdArchive) && (albumId != Data::kStoriesAlbumIdArchive)
&& controller()->storiesPeer()->canEditStories(); && controller()->storiesPeer()->canEditStories()
&& !_emptyAlbumShown.current();
const auto wasBottom = _pinnedToBottom ? _pinnedToBottom->height() : 0; const auto wasBottom = _pinnedToBottom ? _pinnedToBottom->height() : 0;
delete _pinnedToBottom.data(); delete _pinnedToBottom.data();
if (!withButton) { if (!withButton) {
setScrollBottomSkip(0); setScrollBottomSkip(0);
_hasPinnedToBottom = false; _hasPinnedToBottom = false;
} else { } else {
setupBottomButton(wasBottom, _inner->albumEmptyValue()); setupBottomButton(wasBottom);
} }
} }
void Widget::setupBottomButton( void Widget::setupBottomButton(int wasBottomHeight) {
int wasBottomHeight,
rpl::producer<bool> hidden) {
_pinnedToBottom = Ui::CreateChild<Ui::SlideWrap<Ui::RpWidget>>( _pinnedToBottom = Ui::CreateChild<Ui::SlideWrap<Ui::RpWidget>>(
this, this,
object_ptr<Ui::RpWidget>(this)); object_ptr<Ui::RpWidget>(this));
@@ -166,10 +169,7 @@ void Widget::setupBottomButton(
return Ui::Text::IconEmoji(&st::collectionAddIcon).append(text); return Ui::Text::IconEmoji(&st::collectionAddIcon).append(text);
})); }));
button->show(); button->show();
std::move(hidden) | rpl::start_with_next([=](bool hidden) { _hasPinnedToBottom = true;
button->setVisible(!hidden);
_hasPinnedToBottom = !hidden;
}, button->lifetime());
button->setClickedCallback([=] { button->setClickedCallback([=] {
if (const auto id = _albumId.current()) { if (const auto id = _albumId.current()) {
@@ -72,7 +72,7 @@ private:
void saveState(not_null<Memento*> memento); void saveState(not_null<Memento*> memento);
void restoreState(not_null<Memento*> memento); void restoreState(not_null<Memento*> memento);
void setupBottomButton(int wasBottomHeight, rpl::producer<bool> hidden); void setupBottomButton(int wasBottomHeight);
void refreshBottom(); void refreshBottom();
std::shared_ptr<ContentMemento> doCreateMemento() override; std::shared_ptr<ContentMemento> doCreateMemento() override;
@@ -81,6 +81,7 @@ private:
InnerWidget *_inner = nullptr; InnerWidget *_inner = nullptr;
QPointer<Ui::SlideWrap<Ui::RpWidget>> _pinnedToBottom; QPointer<Ui::SlideWrap<Ui::RpWidget>> _pinnedToBottom;
rpl::variable<bool> _hasPinnedToBottom; rpl::variable<bool> _hasPinnedToBottom;
rpl::variable<bool> _emptyAlbumShown;
bool _shown = false; bool _shown = false;
}; };
@@ -52,10 +52,11 @@ QRect BubbleWrapInnerRect(const QRect &r) {
not_null<Ui::RpWidget*> AddBubbleWrap( not_null<Ui::RpWidget*> AddBubbleWrap(
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
const QSize &size) { const QSize &size) {
const auto bubble = container->add(object_ptr<Ui::CenterWrap<RpWidget>>( const auto bubble = container->add(
container, object_ptr<Ui::RpWidget>(container),
object_ptr<Ui::RpWidget>(container)))->entity(); style::al_top);
bubble->resize(size); bubble->resize(size);
bubble->setNaturalWidth(size.width());
auto cached = QImage( auto cached = QImage(
size * style::DevicePixelRatio(), size * style::DevicePixelRatio(),
@@ -245,12 +245,11 @@ object_ptr<Ui::RpWidget> CreateGradientEditor(
std::vector<QColor> colors; std::vector<QColor> colors;
}; };
const auto preview = container->add( const auto preview = container->add(
object_ptr<Ui::CenterWrap<EmojiUserpic>>( object_ptr<EmojiUserpic>(
container, container,
object_ptr<EmojiUserpic>( Size(st::defaultUserpicButton.photoSize),
container, false),
Size(st::defaultUserpicButton.photoSize), style::al_top);
false)))->entity();
preview->setDuration(0); preview->setDuration(0);
if (document) { if (document) {
preview->setDocument(document); preview->setDocument(document);
@@ -166,6 +166,7 @@ EmojiUserpic::EmojiUserpic(
, _painter(size.width()) , _painter(size.width())
, _duration(st::slideWrapDuration) { , _duration(st::slideWrapDuration) {
resize(size); resize(size);
setNaturalWidth(size.width());
} }
void EmojiUserpic::setDocument(not_null<DocumentData*> document) { void EmojiUserpic::setDocument(not_null<DocumentData*> document) {
@@ -178,7 +178,7 @@ void ShowGradientEditor(
}, },
}); });
box->setWidth(content->width()); box->setWidth(content->width());
box->addRow(std::move(content), {}); box->addRow(std::move(content), style::margins());
})); }));
} }
@@ -408,13 +408,12 @@ not_null<Ui::VerticalLayout*> CreateUserpicBuilder(
const auto state = container->lifetime().make_state<State>(); const auto state = container->lifetime().make_state<State>();
const auto preview = container->add( const auto preview = container->add(
object_ptr<Ui::CenterWrap<EmojiUserpic>>( object_ptr<EmojiUserpic>(
container, container,
object_ptr<EmojiUserpic>( Size(st::settingsInfoPhotoSize),
container, data.isForum),
Size(st::settingsInfoPhotoSize), st::userpicBuilderEmojiPreviewPadding,
data.isForum)), style::al_top);
st::userpicBuilderEmojiPreviewPadding)->entity();
if (const auto id = data.documentId) { if (const auto id = data.documentId) {
const auto document = controller->session().data().document(id); const auto document = controller->session().data().document(id);
if (document && document->sticker()) { if (document && document->sticker()) {
@@ -423,13 +422,12 @@ not_null<Ui::VerticalLayout*> CreateUserpicBuilder(
} }
container->add( container->add(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
container, container,
object_ptr<Ui::FlatLabel>( tr::lng_userpic_builder_color_subtitle(),
container, st::userpicBuilderEmojiSubtitle),
tr::lng_userpic_builder_color_subtitle(), st::userpicBuilderEmojiSubtitlePadding,
st::userpicBuilderEmojiSubtitle)), style::al_top);
st::userpicBuilderEmojiSubtitlePadding);
const auto paletteBg = Ui::AddBubbleWrap( const auto paletteBg = Ui::AddBubbleWrap(
container, container,
@@ -515,13 +513,12 @@ not_null<Ui::VerticalLayout*> CreateUserpicBuilder(
}, palette->lifetime()); }, palette->lifetime());
container->add( container->add(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
container, container,
object_ptr<Ui::FlatLabel>( tr::lng_userpic_builder_emoji_subtitle(),
container, st::userpicBuilderEmojiSubtitle),
tr::lng_userpic_builder_emoji_subtitle(), st::userpicBuilderEmojiSubtitlePadding,
st::userpicBuilderEmojiSubtitle)), style::al_top);
st::userpicBuilderEmojiSubtitlePadding);
const auto selectorBg = Ui::AddBubbleWrap( const auto selectorBg = Ui::AddBubbleWrap(
container, container,
@@ -519,7 +519,6 @@ void ConfirmEmojiStatusAccessBox(
rpl::single(name), rpl::single(name),
Ui::Text::RichLangValue), Ui::Text::RichLangValue),
st::botEmojiStatusText), st::botEmojiStatusText),
st::boxRowPadding,
style::al_top); style::al_top);
box->addButton(tr::lng_bot_emoji_status_access_allow(), [=] { box->addButton(tr::lng_bot_emoji_status_access_allow(), [=] {
@@ -563,7 +562,6 @@ void ConfirmEmojiStatusBox(
box, box,
tr::lng_bot_emoji_status_title(), tr::lng_bot_emoji_status_title(),
st::botEmojiStatusTitle), st::botEmojiStatusTitle),
st::boxRowPadding,
style::al_top); style::al_top);
AddSkip(box->verticalLayout()); AddSkip(box->verticalLayout());
@@ -575,7 +573,6 @@ void ConfirmEmojiStatusBox(
rpl::single(Ui::Text::Bold(bot->name())), rpl::single(Ui::Text::Bold(bot->name())),
Ui::Text::RichLangValue), Ui::Text::RichLangValue),
st::botEmojiStatusText), st::botEmojiStatusText),
st::boxRowPadding,
style::al_top); style::al_top);
AddSkip(box->verticalLayout(), 2 * st::defaultVerticalListSkip); AddSkip(box->verticalLayout(), 2 * st::defaultVerticalListSkip);
@@ -177,6 +177,7 @@ void CodeInput::setDigitsCountMax(int digitsCount) {
+ st::introCodeDigitSkip * (digitsCount - 1) + st::introCodeDigitSkip * (digitsCount - 1)
+ padding.right(), + padding.right(),
st::introCodeDigitHeight); st::introCodeDigitHeight);
setNaturalWidth(width());
for (auto i = 0; i < digitsCount; i++) { for (auto i = 0; i < digitsCount; i++) {
const auto widget = Ui::CreateChild<CodeDigit>(this); const auto widget = Ui::CreateChild<CodeDigit>(this);
+1 -2
View File
@@ -69,11 +69,10 @@ EmailWidget::EmailWidget(
}, lifetime()); }, lifetime());
} }
const auto wrap = Settings::CloudPassword::AddWrappedField( const auto newInput = Settings::CloudPassword::AddWrappedField(
content, content,
tr::lng_settings_cloud_login_email_placeholder(), tr::lng_settings_cloud_login_email_placeholder(),
QString()); QString());
const auto newInput = wrap->entity();
Ui::AddSkip(content); Ui::AddSkip(content);
const auto error = Settings::CloudPassword::AddError(content, nullptr); const auto error = Settings::CloudPassword::AddError(content, nullptr);
newInput->changes() | rpl::start_with_next([=] { newInput->changes() | rpl::start_with_next([=] {
@@ -327,11 +327,8 @@ struct Feature {
box->setWidth(st::boxWideWidth); box->setWidth(st::boxWideWidth);
box->setStyle(st::storiesStealthBox); box->setStyle(st::storiesStealthBox);
box->addRow(MakeLogo(box)); box->addRow(MakeLogo(box));
box->addRow(MakeTitle(box), st::boxRowPadding, style::al_top); box->addRow(MakeTitle(box), style::al_top);
box->addRow( box->addRow(MakeAbout(box, data->state.value()), style::al_top);
MakeAbout(box, data->state.value()),
st::boxRowPadding,
style::al_top);
box->addRow(MakeFeature(box, FeaturePast())); box->addRow(MakeFeature(box, FeaturePast()));
box->addRow( box->addRow(
MakeFeature(box, FeatureNext()), MakeFeature(box, FeatureNext()),
+16 -15
View File
@@ -56,6 +56,7 @@ void AboutBox(
constexpr auto kUrl = "https://promote.telegram.org"_cs; constexpr auto kUrl = "https://promote.telegram.org"_cs;
box->setWidth(st::boxWideWidth); box->setWidth(st::boxWideWidth);
box->setNoContentMargin(true);
const auto isChannel = (phrases == SponsoredPhrases::Channel); const auto isChannel = (phrases == SponsoredPhrases::Channel);
const auto isSearch = (phrases == SponsoredPhrases::Search); const auto isSearch = (phrases == SponsoredPhrases::Search);
@@ -73,9 +74,8 @@ void AboutBox(
const auto rect = Rect(icon.size() * 1.4); const auto rect = Rect(icon.size() * 1.4);
auto owned = object_ptr<Ui::RpWidget>(content); auto owned = object_ptr<Ui::RpWidget>(content);
owned->resize(rect.size()); owned->resize(rect.size());
const auto widget = box->addRow(object_ptr<Ui::CenterWrap<>>( owned->setNaturalWidth(rect.width());
content, const auto widget = box->addRow(std::move(owned), style::al_top);
std::move(owned)))->entity();
widget->paintRequest( widget->paintRequest(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
auto p = Painter(widget); auto p = Painter(widget);
@@ -88,17 +88,19 @@ void AboutBox(
} }
Ui::AddSkip(content); Ui::AddSkip(content);
Ui::AddSkip(content); Ui::AddSkip(content);
box->addRow(object_ptr<Ui::CenterWrap<>>( box->addRow(
content,
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
content, content,
tr::lng_sponsored_menu_revenued_about(), tr::lng_sponsored_menu_revenued_about(),
st::boxTitle))); st::boxTitle),
style::al_top);
Ui::AddSkip(content); Ui::AddSkip(content);
box->addRow(object_ptr<Ui::FlatLabel>( box->addRow(
content, object_ptr<Ui::FlatLabel>(
tr::lng_sponsored_revenued_subtitle(), content,
st::channelEarnLearnDescription)); tr::lng_sponsored_revenued_subtitle(),
st::channelEarnLearnDescription),
style::al_top);
Ui::AddSkip(content); Ui::AddSkip(content);
Ui::AddSkip(content); Ui::AddSkip(content);
{ {
@@ -208,12 +210,11 @@ void AboutBox(
Ui::AddSkip(content); Ui::AddSkip(content);
{ {
box->addRow( box->addRow(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
content, content,
object_ptr<Ui::FlatLabel>( tr::lng_sponsored_revenued_footer_title(),
content, st::boxTitle),
tr::lng_sponsored_revenued_footer_title(), style::al_top);
st::boxTitle)));
} }
Ui::AddSkip(content); Ui::AddSkip(content);
{ {
@@ -190,14 +190,13 @@ void PanelNoPassword::setupContent() {
style::al_top); style::al_top);
const auto iconWrap = _inner->add( const auto iconWrap = _inner->add(
object_ptr<Ui::CenterWrap<Ui::FixedHeightWidget>>( object_ptr<Ui::FixedHeightWidget>(
_inner, _inner,
object_ptr<Ui::FixedHeightWidget>( st::passportPasswordIconHeight),
_inner, style::al_top);
st::passportPasswordIconHeight))); iconWrap->setNaturalWidth(st::passportPasswordIcon.width());
iconWrap->entity()->resizeToWidth(st::passportPasswordIcon.width());
Ui::CreateChild<Info::Profile::FloatingIcon>( Ui::CreateChild<Info::Profile::FloatingIcon>(
iconWrap->entity(), iconWrap,
st::passportPasswordIcon, st::passportPasswordIcon,
QPoint(0, 0)); QPoint(0, 0));
@@ -225,13 +224,12 @@ void PanelNoPassword::refreshBottom() {
style::al_top)); style::al_top));
if (pattern.isEmpty()) { if (pattern.isEmpty()) {
const auto button = _inner->add( const auto button = _inner->add(
object_ptr<Ui::CenterWrap<Ui::RoundButton>>( object_ptr<Ui::RoundButton>(
_inner, _inner,
object_ptr<Ui::RoundButton>( tr::lng_passport_password_create(),
_inner, st::defaultBoxButton),
tr::lng_passport_password_create(), style::al_top);
st::defaultBoxButton))); button->addClickHandler([=] {
button->entity()->addClickHandler([=] {
_controller->setupPassword(); _controller->setupPassword();
}); });
} else { } else {
@@ -124,7 +124,6 @@ bool FormSummary::showCriticalError(const TextWithEntities &text) {
_layout.get(), _layout.get(),
rpl::single(text), rpl::single(text),
st::paymentsCriticalError), st::paymentsCriticalError),
{},
style::al_top); style::al_top);
return true; return true;
} }
@@ -518,13 +518,13 @@ void PaidReactionsBox(
state->shownPeer = state->savedShownPeer = barePeerId; state->shownPeer = state->savedShownPeer = barePeerId;
}); });
const auto named = box->addRow(object_ptr<CenterWrap<Checkbox>>( const auto named = box->addRow(
box,
object_ptr<Checkbox>( object_ptr<Checkbox>(
box, box,
tr::lng_paid_react_show_in_top(tr::now), tr::lng_paid_react_show_in_top(tr::now),
state->shownPeer.current() != 0))); state->shownPeer.current() != 0),
named->entity()->checkedValue( style::al_top);
named->checkedValue(
) | rpl::start_with_next([=](bool show) { ) | rpl::start_with_next([=](bool show) {
state->shownPeer = show ? state->savedShownPeer : 0; state->shownPeer = show ? state->savedShownPeer : 0;
}, named->lifetime()); }, named->lifetime());
@@ -560,7 +560,7 @@ void ChatIntro::setupContent(
content, content,
session, session,
IntroWithRandomSticker(session, _intro.value())), IntroWithRandomSticker(session, _intro.value())),
{}); style::margins());
const auto title = AddPartInput( const auto title = AddPartInput(
content, content,
@@ -126,29 +126,25 @@ void SetupHeader(
Ui::AddSkip(content); Ui::AddSkip(content);
content->add( content->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(
content, content,
object_ptr<Ui::FlatLabel>( std::move(subtitle),
content, st::changePhoneTitle),
std::move(subtitle), st::changePhoneTitlePadding,
st::changePhoneTitle)), style::al_top);
st::changePhoneTitlePadding);
{ {
const auto &st = st::settingLocalPasscodeDescription; const auto &st = st::settingLocalPasscodeDescription;
const auto wrap = content->add( const auto description = content->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(
content, content,
object_ptr<Ui::FlatLabel>( v::text::take_marked(std::move(about)),
content, st,
v::text::take_marked(std::move(about)), st::defaultPopupMenu),
st, st::changePhoneDescriptionPadding,
st::defaultPopupMenu)), style::al_top);
st::changePhoneDescriptionPadding); description->setTryMakeSimilarLines(true);
wrap->setAttribute(Qt::WA_TransparentForMouseEvents); description->setAttribute(Qt::WA_TransparentForMouseEvents);
wrap->resize(
wrap->width(),
st::settingLocalPasscodeDescriptionHeight);
} }
} }
@@ -174,24 +170,24 @@ not_null<Ui::PasswordInput*> AddPasswordField(
return field; return field;
} }
not_null<Ui::CenterWrap<Ui::InputField>*> AddWrappedField( not_null<Ui::InputField*> AddWrappedField(
not_null<Ui::VerticalLayout*> content, not_null<Ui::VerticalLayout*> content,
rpl::producer<QString> &&placeholder, rpl::producer<QString> &&placeholder,
const QString &text) { const QString &text) {
return content->add(object_ptr<Ui::CenterWrap<Ui::InputField>>( return content->add(
content,
object_ptr<Ui::InputField>( object_ptr<Ui::InputField>(
content, content,
st::settingLocalPasscodeInputField, st::settingLocalPasscodeInputField,
std::move(placeholder), std::move(placeholder),
text))); text),
style::al_top);
} }
not_null<Ui::LinkButton*> AddLinkButton( not_null<Ui::LinkButton*> AddLinkButton(
not_null<Ui::CenterWrap<Ui::InputField>*> wrap, not_null<Ui::InputField*> input,
rpl::producer<QString> &&text) { rpl::producer<QString> &&text) {
const auto button = Ui::CreateChild<Ui::LinkButton>( const auto button = Ui::CreateChild<Ui::LinkButton>(
wrap->parentWidget(), input->parentWidget(),
QString()); QString());
std::move( std::move(
text text
@@ -199,9 +195,8 @@ not_null<Ui::LinkButton*> AddLinkButton(
button->setText(text); button->setText(text);
}, button->lifetime()); }, button->lifetime());
wrap->geometryValue( input->geometryValue(
) | rpl::start_with_next([=](QRect r) { ) | rpl::start_with_next([=](QRect r) {
r.translate(wrap->entity()->pos().x(), 0);
button->moveToLeft(r.x(), r.y() + r.height() + st::passcodeTextLine); button->moveToLeft(r.x(), r.y() + r.height() + st::passcodeTextLine);
}, button->lifetime()); }, button->lifetime());
return button; return button;
@@ -230,13 +225,12 @@ not_null<Ui::RoundButton*> AddDoneButton(
not_null<Ui::VerticalLayout*> content, not_null<Ui::VerticalLayout*> content,
rpl::producer<QString> &&text) { rpl::producer<QString> &&text) {
const auto button = content->add( const auto button = content->add(
object_ptr<Ui::CenterWrap<Ui::RoundButton>>( object_ptr<Ui::RoundButton>(
content, content,
object_ptr<Ui::RoundButton>( std::move(text),
content, st::changePhoneButton),
std::move(text), st::settingLocalPasscodeButtonPadding,
st::changePhoneButton)), style::al_top);
st::settingLocalPasscodeButtonPadding)->entity();
button->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); button->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
return button; return button;
} }
@@ -11,8 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/box_content_divider.h" #include "ui/widgets/box_content_divider.h"
namespace Ui { namespace Ui {
template <typename Widget>
class CenterWrap;
class FlatLabel; class FlatLabel;
class InputField; class InputField;
class LinkButton; class LinkButton;
@@ -61,7 +59,7 @@ void SetupHeader(
rpl::producer<QString> &&placeholder, rpl::producer<QString> &&placeholder,
const QString &text); const QString &text);
[[nodiscard]] not_null<Ui::CenterWrap<Ui::InputField>*> AddWrappedField( [[nodiscard]] not_null<Ui::InputField*> AddWrappedField(
not_null<Ui::VerticalLayout*> content, not_null<Ui::VerticalLayout*> content,
rpl::producer<QString> &&placeholder, rpl::producer<QString> &&placeholder,
const QString &text); const QString &text);
@@ -75,7 +73,7 @@ void SetupHeader(
rpl::producer<QString> &&text); rpl::producer<QString> &&text);
[[nodiscard]] not_null<Ui::LinkButton*> AddLinkButton( [[nodiscard]] not_null<Ui::LinkButton*> AddLinkButton(
not_null<Ui::CenterWrap<Ui::InputField>*> wrap, not_null<Ui::InputField*> input,
rpl::producer<QString> &&text); rpl::producer<QString> &&text);
void AddSkipInsteadOfField(not_null<Ui::VerticalLayout*> content); void AddSkipInsteadOfField(not_null<Ui::VerticalLayout*> content);
@@ -84,11 +84,10 @@ void Email::setupContent() {
Ui::AddSkip(content, st::settingLocalPasscodeDescriptionBottomSkip); Ui::AddSkip(content, st::settingLocalPasscodeDescriptionBottomSkip);
const auto wrap = AddWrappedField( const auto newInput = AddWrappedField(
content, content,
tr::lng_cloud_password_email(), tr::lng_cloud_password_email(),
currentStepDataEmail); currentStepDataEmail);
const auto newInput = wrap->entity();
const auto error = AddError(content, nullptr); const auto error = AddError(content, nullptr);
newInput->changes( newInput->changes(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
@@ -169,7 +168,7 @@ void Email::setupContent() {
}; };
const auto skip = AddLinkButton( const auto skip = AddLinkButton(
wrap, newInput,
tr::lng_cloud_password_skip_email()); tr::lng_cloud_password_skip_email());
skip->setClickedCallback([=] { skip->setClickedCallback([=] {
confirm(QString()); confirm(QString());
@@ -155,11 +155,9 @@ void EmailConfirm::setupContent() {
content, content,
st::settingLocalPasscodeInputField, st::settingLocalPasscodeInputField,
tr::lng_change_phone_code_title()); tr::lng_change_phone_code_title());
const auto newInput = objectInput.data(); const auto newInput = content->add(
const auto wrap = content->add( std::move(objectInput),
object_ptr<Ui::CenterWrap<Ui::InputField>>( style::al_top);
content,
std::move(objectInput)));
const auto error = AddError(content, nullptr); const auto error = AddError(content, nullptr);
newInput->changes( newInput->changes(
@@ -184,7 +182,9 @@ void EmailConfirm::setupContent() {
} }
}, resendInfo->lifetime()); }, resendInfo->lifetime());
const auto resend = AddLinkButton(wrap, tr::lng_cloud_password_resend()); const auto resend = AddLinkButton(
newInput,
tr::lng_cloud_password_resend());
resend->setClickedCallback([=] { resend->setClickedCallback([=] {
if (_requestLifetime) { if (_requestLifetime) {
return; return;
@@ -75,11 +75,10 @@ void Hint::setupContent() {
Ui::AddSkip(content, st::settingLocalPasscodeDescriptionBottomSkip); Ui::AddSkip(content, st::settingLocalPasscodeDescriptionBottomSkip);
const auto wrap = AddWrappedField( const auto newInput = AddWrappedField(
content, content,
tr::lng_cloud_password_hint(), tr::lng_cloud_password_hint(),
currentStepDataHint); currentStepDataHint);
const auto newInput = wrap->entity();
const auto error = AddError(content, nullptr); const auto error = AddError(content, nullptr);
newInput->changes( newInput->changes(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
@@ -122,7 +121,7 @@ void Hint::setupContent() {
}; };
AddLinkButton( AddLinkButton(
wrap, newInput,
tr::lng_settings_cloud_password_skip_hint() tr::lng_settings_cloud_password_skip_hint()
)->setClickedCallback([=] { )->setClickedCallback([=] {
save(QString()); save(QString());
@@ -170,11 +170,8 @@ void Input::setupValidateGood() {
} }
if (auto owned = CreateValidateGoodIcon(&controller()->session())) { if (auto owned = CreateValidateGoodIcon(&controller()->session())) {
owned->setParent(content);
content->add( content->add(
object_ptr<Ui::CenterWrap<>>( std::move(owned),
content,
std::move(owned)),
QMargins(0, st::lineWidth * 75, 0, 0)); QMargins(0, st::lineWidth * 75, 0, 0));
} }
@@ -254,10 +251,10 @@ void Input::setupContent() {
const auto newInput = AddPasswordField( const auto newInput = AddPasswordField(
content, content,
isCheck (isCheck
? tr::lng_cloud_password_enter_old() ? tr::lng_cloud_password_enter_old()
: tr::lng_cloud_password_enter_new(), : tr::lng_cloud_password_enter_new()),
currentStepDataPassword); currentStepDataPassword);
const auto reenterInput = isCheck const auto reenterInput = isCheck
? (Ui::PasswordInput*)(nullptr) ? (Ui::PasswordInput*)(nullptr)
: AddPasswordField( : AddPasswordField(
@@ -280,9 +277,12 @@ void Input::setupContent() {
tr::lng_signin_hint(tr::now, lt_password_hint, hint), tr::lng_signin_hint(tr::now, lt_password_hint, hint),
st::defaultFlatLabel); st::defaultFlatLabel);
hintInfo->setVisible(!hint.isEmpty()); hintInfo->setVisible(!hint.isEmpty());
error->geometryValue( rpl::combine(
) | rpl::start_with_next([=](const QRect &r) { error->geometryValue(),
hintInfo->setGeometry(r); newInput->geometryValue()
) | rpl::start_with_next([=](QRect r, QRect input) {
hintInfo->setGeometry(
{ input.x(), r.y(), input.width(), r.height() });
}, hintInfo->lifetime()); }, hintInfo->lifetime());
error->shownValue( error->shownValue(
) | rpl::start_with_next([=](bool shown) { ) | rpl::start_with_next([=](bool shown) {
@@ -63,11 +63,10 @@ void LoginEmail::setupContent() {
Ui::AddSkip(content, st::settingLocalPasscodeDescriptionBottomSkip); Ui::AddSkip(content, st::settingLocalPasscodeDescriptionBottomSkip);
const auto wrap = AddWrappedField( const auto newInput = AddWrappedField(
content, content,
tr::lng_settings_cloud_login_email_placeholder(), tr::lng_settings_cloud_login_email_placeholder(),
QString()); QString());
const auto newInput = wrap->entity();
const auto error = AddError(content, nullptr); const auto error = AddError(content, nullptr);
newInput->changes() | rpl::start_with_next([=] { newInput->changes() | rpl::start_with_next([=] {
error->hide(); error->hide();
@@ -106,11 +106,9 @@ void LoginEmailConfirm::setupContent() {
Ui::AddSkip(content, st::settingLocalPasscodeDescriptionBottomSkip); Ui::AddSkip(content, st::settingLocalPasscodeDescriptionBottomSkip);
const auto wrap = content->add( const auto newInput = content->add(
object_ptr<Ui::CenterWrap<Ui::CodeInput>>( object_ptr<Ui::CodeInput>(content),
content, style::al_top);
object_ptr<Ui::CodeInput>(content)));
const auto newInput = wrap->entity();
newInput->setDigitsCountMax(currentStepDataCodeLength); newInput->setDigitsCountMax(currentStepDataCodeLength);
Ui::AddSkip(content); Ui::AddSkip(content);
@@ -67,6 +67,7 @@ object_ptr<Ui::RpWidget> CreateValidateGoodIcon(
}, widget->lifetime()); }, widget->lifetime());
const auto padding = st::settingLocalPasscodeIconPadding; const auto padding = st::settingLocalPasscodeIconPadding;
widget->resize((Rect(Size(size)) + padding).size()); widget->resize((Rect(Size(size)) + padding).size());
widget->setNaturalWidth(padding.left() + size + padding.right());
return owned; return owned;
} }
@@ -40,15 +40,13 @@ Blocked::Blocked(
{ {
auto padding = st::changePhoneIconPadding; auto padding = st::changePhoneIconPadding;
padding.setBottom(padding.top()); padding.setBottom(padding.top());
_loading = base::make_unique_q<Ui::CenterWrap<>>( _loading = base::make_unique_q<Ui::PaddingWrap<>>(
this, this,
object_ptr<Ui::PaddingWrap<>>( object_ptr<Ui::FlatLabel>(
this, this,
object_ptr<Ui::FlatLabel>( tr::lng_contacts_loading(),
this, st::changePhoneDescription),
tr::lng_contacts_loading(), std::move(padding));
st::changePhoneDescription),
std::move(padding)));
Ui::ResizeFitChild( Ui::ResizeFitChild(
this, this,
_loading.get(), _loading.get(),
@@ -424,13 +424,12 @@ void Credits::setupContent() {
{ {
const auto button = content->add( const auto button = content->add(
object_ptr<Ui::CenterWrap<Ui::RoundButton>>( object_ptr<Ui::RoundButton>(
content, content,
object_ptr<Ui::RoundButton>( nullptr,
content, st::creditsSettingsBigBalanceButton),
nullptr, st::boxRowPadding,
st::creditsSettingsBigBalanceButton)), style::al_top);
st::boxRowPadding)->entity();
button->setContext([&]() -> Ui::Text::MarkedContext { button->setContext([&]() -> Ui::Text::MarkedContext {
auto customEmojiFactory = [=](const auto &...) { auto customEmojiFactory = [=](const auto &...) {
const auto &icon = st::settingsIconAdd; const auto &icon = st::settingsIconAdd;
@@ -507,39 +506,37 @@ void Credits::setupContent() {
return { .customEmojiFactory = std::move(customEmojiFactory) }; return { .customEmojiFactory = std::move(customEmojiFactory) };
}(); }();
content->add( content->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(
content, content,
object_ptr<Ui::FlatLabel>( tr::lng_credits_balance_me_count(
content, lt_emoji,
tr::lng_credits_balance_me_count( rpl::single(Ui::MakeCreditsIconEntity()),
lt_emoji, lt_amount,
rpl::single(Ui::MakeCreditsIconEntity()), (isCurrency
lt_amount, ? _controller->session().credits().tonBalanceValue()
(isCurrency : _controller->session().credits().balanceValue()
? _controller->session().credits().tonBalanceValue() ) | rpl::map(
: _controller->session().credits().balanceValue() Lang::FormatCreditsAmountDecimal
) | rpl::map( ) | rpl::map(Ui::Text::Bold),
Lang::FormatCreditsAmountDecimal Ui::Text::WithEntities),
) | rpl::map(Ui::Text::Bold), textSt,
Ui::Text::WithEntities), st::defaultPopupMenu,
textSt, std::move(context)),
st::defaultPopupMenu, style::al_top);
std::move(context))));
if (isCurrency) { if (isCurrency) {
const auto rate = _controller->session().credits().usdRate(); const auto rate = _controller->session().credits().usdRate();
const auto wrap = content->add( const auto wrap = content->add(
object_ptr<Ui::SlideWrap<>>( object_ptr<Ui::SlideWrap<>>(
content, content,
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(
content, content,
object_ptr<Ui::FlatLabel>( _controller->session().credits().tonBalanceValue(
content, ) | rpl::map([=](CreditsAmount value) {
_controller->session().credits().tonBalanceValue( using namespace Info::ChannelEarn;
) | rpl::map([=](CreditsAmount value) { return value ? ToUsd(value, rate, 3) : QString();
using namespace Info::ChannelEarn; }),
return value ? ToUsd(value, rate, 3) : QString(); st::channelEarnOverviewSubMinorLabel)),
}), style::al_top);
st::channelEarnOverviewSubMinorLabel))));
wrap->toggleOn(_controller->session().credits().tonBalanceValue( wrap->toggleOn(_controller->session().credits().tonBalanceValue(
) | rpl::map(rpl::mappers::_1 > CreditsAmount(0))); ) | rpl::map(rpl::mappers::_1 > CreditsAmount(0)));
wrap->finishAnimating(); wrap->finishAnimating();
@@ -615,9 +612,8 @@ void Credits::setupContent() {
Ui::AddSkip(container); Ui::AddSkip(container);
const auto labels = container->add( const auto labels = container->add(
object_ptr<Ui::CenterWrap<Ui::RpWidget>>( object_ptr<Ui::RpWidget>(container),
container, style::al_top);
object_ptr<Ui::RpWidget>(container)))->entity();
const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>( const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>(
labels, labels,
@@ -642,6 +638,8 @@ void Credits::setupContent() {
labels->resize( labels->resize(
majorSize.width() + minorSize.width(), majorSize.width() + minorSize.width(),
majorSize.height()); majorSize.height());
labels->setNaturalWidth(
majorSize.width() + minorSize.width());
majorLabel->moveToLeft(0, 0); majorLabel->moveToLeft(0, 0);
minorLabel->moveToRight( minorLabel->moveToRight(
0, 0,
@@ -651,12 +649,11 @@ void Credits::setupContent() {
Ui::AddSkip(container); Ui::AddSkip(container);
container->add( container->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(
container, container,
object_ptr<Ui::FlatLabel>( ToUsd(value, multiplier, 0),
container, st::channelEarnOverviewSubMinorLabel),
ToUsd(value, multiplier, 0), style::al_top);
st::channelEarnOverviewSubMinorLabel)));
Ui::AddSkip(container); Ui::AddSkip(container);
@@ -791,14 +791,13 @@ void BoostCreditsBox(
}, widget->lifetime()); }, widget->lifetime());
} }
content->add( content->add(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
content, content,
object_ptr<Ui::FlatLabel>( tr::lng_gift_stars_title(
content, lt_count,
tr::lng_gift_stars_title( rpl::single(float64(b.credits))),
lt_count, st::boxTitle),
rpl::single(float64(b.credits))), style::al_top);
st::boxTitle)));
Ui::AddSkip(content); Ui::AddSkip(content);
if (b.multiplier) { if (b.multiplier) {
const auto &st = st::statisticsDetailsBottomCaptionStyle; const auto &st = st::statisticsDetailsBottomCaptionStyle;
@@ -862,7 +861,6 @@ void BoostCreditsBox(
tr::lng_credits_box_out_about_link(tr::now)), tr::lng_credits_box_out_about_link(tr::now)),
Ui::Text::WithEntities), Ui::Text::WithEntities),
st::creditsBoxAboutDivider), st::creditsBoxAboutDivider),
st::boxRowPadding,
style::al_top); style::al_top);
Ui::AddSkip(content); Ui::AddSkip(content);
@@ -1263,10 +1261,10 @@ void GenericCreditsEntryBox(
Ui::PreloadUniqueGiftResellPrices(session); Ui::PreloadUniqueGiftResellPrices(session);
} }
} else if (const auto callback = Ui::PaintPreviewCallback(session, e)) { } else if (const auto callback = Ui::PaintPreviewCallback(session, e)) {
const auto thumb = content->add(object_ptr<Ui::CenterWrap<>>( const auto thumb = content->add(
content, GenericEntryPhoto(content, callback, stUser.photoSize),
GenericEntryPhoto(content, callback, stUser.photoSize))); style::al_top);
AddViewMediaHandler(thumb->entity(), show, e); AddViewMediaHandler(thumb, show, e);
} else if (s.photoId || (e.photoId && !e.subscriptionUntil.isNull())) { } else if (s.photoId || (e.photoId && !e.subscriptionUntil.isNull())) {
if (!(s.cancelled || s.expired || s.cancelledByBot)) { if (!(s.cancelled || s.expired || s.cancelledByBot)) {
const auto widget = Ui::CreateChild<Ui::RpWidget>(content); const auto widget = Ui::CreateChild<Ui::RpWidget>(content);
@@ -1279,21 +1277,21 @@ void GenericCreditsEntryBox(
owner->photo(photoId), owner->photo(photoId),
std::move(update)); std::move(update));
}; };
content->add(object_ptr<Ui::CenterWrap<>>( content->add(
content, GenericEntryPhoto(content, callback, stUser.photoSize),
GenericEntryPhoto(content, callback, stUser.photoSize))); style::al_top);
} else if (peer } else if (peer
&& !e.gift && !e.gift
&& !e.premiumMonthsForStars && !e.premiumMonthsForStars
&& !e.postsSearch) { && !e.postsSearch) {
if (e.subscriptionUntil.isNull() && s.until.isNull()) { if (e.subscriptionUntil.isNull() && s.until.isNull()) {
content->add(object_ptr<Ui::CenterWrap<>>( content->add(
content, object_ptr<Ui::UserpicButton>(content, peer, stUser),
object_ptr<Ui::UserpicButton>(content, peer, stUser))); style::al_top);
} else { } else {
content->add(object_ptr<Ui::CenterWrap<>>( content->add(
content, SubscriptionUserpic(content, peer, stUser.photoSize),
SubscriptionUserpic(content, peer, stUser.photoSize))); style::al_top);
} }
} else if (e.gift || isPrize || e.premiumMonthsForStars) { } else if (e.gift || isPrize || e.premiumMonthsForStars) {
struct State final { struct State final {
@@ -1373,13 +1371,13 @@ void GenericCreditsEntryBox(
}, icon->lifetime()); }, icon->lifetime());
} else if (!e.postsSearch) { } else if (!e.postsSearch) {
const auto widget = content->add( const auto widget = content->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::RpWidget>(content),
content, style::al_top);
object_ptr<Ui::RpWidget>(content)))->entity();
using Draw = Fn<void(Painter &, int, int, int, int)>; using Draw = Fn<void(Painter &, int, int, int, int)>;
const auto draw = widget->lifetime().make_state<Draw>( const auto draw = widget->lifetime().make_state<Draw>(
Ui::GenerateCreditsPaintUserpicCallback(e)); Ui::GenerateCreditsPaintUserpicCallback(e));
widget->resize(Size(stUser.photoSize)); widget->resize(Size(stUser.photoSize));
widget->setNaturalWidth(stUser.photoSize);
widget->paintRequest( widget->paintRequest(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
auto p = Painter(widget); auto p = Painter(widget);
@@ -1434,7 +1432,6 @@ void GenericCreditsEntryBox(
? peer->name() ? peer->name()
: Ui::GenerateEntryName(e).text), : Ui::GenerateEntryName(e).text),
st::creditsBoxAboutTitle), st::creditsBoxAboutTitle),
st::boxRowPadding,
style::al_top); style::al_top);
Ui::AddSkip(content); Ui::AddSkip(content);
@@ -1442,16 +1439,15 @@ void GenericCreditsEntryBox(
if (e.bareGiftReleasedById && !e.uniqueGift) { if (e.bareGiftReleasedById && !e.uniqueGift) {
const auto peer = owner->peer(PeerId(e.bareGiftReleasedById)); const auto peer = owner->peer(PeerId(e.bareGiftReleasedById));
const auto released = content->add( const auto released = content->add(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
box, content,
object_ptr<Ui::FlatLabel>( tr::lng_credits_box_history_entry_gift_released(
content, lt_name,
tr::lng_credits_box_history_entry_gift_released( rpl::single(Ui::Text::Link('@' + peer->username())),
lt_name, Ui::Text::WithEntities),
rpl::single(Ui::Text::Link('@' + peer->username())), st::creditsReleasedByLabel),
Ui::Text::WithEntities), style::al_top);
st::creditsReleasedByLabel))); released->setClickHandlerFilter([=](const auto &...) {
released->entity()->setClickHandlerFilter([=](const auto &...) {
Ui::GiftReleasedByHandler(peer); Ui::GiftReleasedByHandler(peer);
return false; return false;
}); });
@@ -1613,7 +1609,6 @@ void GenericCreditsEntryBox(
box, box,
rpl::single(e.description), rpl::single(e.description),
st::creditsBoxAbout), st::creditsBoxAbout),
st::boxRowPadding,
style::al_top); style::al_top);
} }
@@ -1669,7 +1664,6 @@ void GenericCreditsEntryBox(
: tr::lng_action_gift_got_gift_text))( : tr::lng_action_gift_got_gift_text))(
Ui::Text::WithEntities))), Ui::Text::WithEntities))),
st::creditsBoxAbout), st::creditsBoxAbout),
st::boxRowPadding,
style::al_top); style::al_top);
about->setClickHandlerFilter([=](const auto &...) { about->setClickHandlerFilter([=](const auto &...) {
Core::App().iv().openWithIvPreferred( Core::App().iv().openWithIvPreferred(
@@ -1707,7 +1701,6 @@ void GenericCreditsEntryBox(
std::move(link), std::move(link),
Ui::Text::RichLangValue), Ui::Text::RichLangValue),
st::creditsBoxAbout), st::creditsBoxAbout),
st::boxRowPadding,
style::al_top); style::al_top);
} else if (e.paidMessagesCommission && e.barePeerId) { } else if (e.paidMessagesCommission && e.barePeerId) {
Ui::AddSkip(content); Ui::AddSkip(content);
@@ -1732,7 +1725,6 @@ void GenericCreditsEntryBox(
std::move(link), std::move(link),
Ui::Text::RichLangValue), Ui::Text::RichLangValue),
st::creditsBoxAbout), st::creditsBoxAbout),
st::boxRowPadding,
style::al_top); style::al_top);
} }
@@ -1876,7 +1868,6 @@ void GenericCreditsEntryBox(
tr::lng_credits_box_out_about_link(tr::now)), tr::lng_credits_box_out_about_link(tr::now)),
Ui::Text::WithEntities), Ui::Text::WithEntities),
st::creditsBoxAboutDivider), st::creditsBoxAboutDivider),
st::boxRowPadding,
style::al_top); style::al_top);
} else if (starGiftCanManage) { } else if (starGiftCanManage) {
const auto hiddenPhrase = giftToChannelCanManage const auto hiddenPhrase = giftToChannelCanManage
@@ -1929,7 +1920,6 @@ void GenericCreditsEntryBox(
box, box,
std::move(text), std::move(text),
st::creditsBoxAboutDivider), st::creditsBoxAboutDivider),
st::boxRowPadding,
style::al_top); style::al_top);
label->setClickHandlerFilter([=](const auto &...) { label->setClickHandlerFilter([=](const auto &...) {
toggleVisibility(!e.savedToProfile); toggleVisibility(!e.savedToProfile);
@@ -1948,7 +1938,6 @@ void GenericCreditsEntryBox(
) | Ui::Text::ToLink(), ) | Ui::Text::ToLink(),
Ui::Text::WithEntities), Ui::Text::WithEntities),
st::creditsBoxAboutDivider), st::creditsBoxAboutDivider),
st::boxRowPadding,
style::al_top); style::al_top);
label->setClickHandlerFilter([=](const auto &...) { label->setClickHandlerFilter([=](const auto &...) {
UrlClickHandler::Open( UrlClickHandler::Open(
@@ -2001,7 +1990,7 @@ void GenericCreditsEntryBox(
} else if (s.cancelled || s.cancelledByBot) { } else if (s.cancelled || s.cancelledByBot) {
label->setTextColorOverride(st::menuIconAttentionColor->c); label->setTextColorOverride(st::menuIconAttentionColor->c);
} }
box->addRow(std::move(label), st::boxRowPadding, style::al_top); box->addRow(std::move(label), style::al_top);
} }
Ui::AddSkip(content); Ui::AddSkip(content);
@@ -2404,6 +2393,7 @@ object_ptr<Ui::RpWidget> GenericEntryPhoto(
auto owned = object_ptr<Ui::RpWidget>(parent); auto owned = object_ptr<Ui::RpWidget>(parent);
const auto widget = owned.data(); const auto widget = owned.data();
widget->resize(Size(photoSize)); widget->resize(Size(photoSize));
widget->setNaturalWidth(photoSize);
const auto draw = callback( const auto draw = callback(
crl::guard(widget, [=] { widget->update(); })); crl::guard(widget, [=] { widget->update(); }));
@@ -2453,6 +2443,7 @@ object_ptr<Ui::RpWidget> SubscriptionUserpic(
auto widget = object_ptr<Ui::RpWidget>(parent); auto widget = object_ptr<Ui::RpWidget>(parent);
const auto raw = widget.data(); const auto raw = widget.data();
widget->resize(photoSize, photoSize); widget->resize(photoSize, photoSize);
widget->setNaturalWidth(photoSize);
const auto userpicMedia = Ui::MakeUserpicThumbnail(peer, false); const auto userpicMedia = Ui::MakeUserpicThumbnail(peer, false);
userpicMedia->subscribeToUpdates([=] { raw->update(); }); userpicMedia->subscribeToUpdates([=] { raw->update(); });
const auto creditsIconSize = photoSize / 3; const auto creditsIconSize = photoSize / 3;
@@ -2642,9 +2633,8 @@ void AddWithdrawalWidget(
Ui::AddSkip(container); Ui::AddSkip(container);
const auto labels = container->add( const auto labels = container->add(
object_ptr<Ui::CenterWrap<Ui::RpWidget>>( object_ptr<Ui::RpWidget>(container),
container, style::al_top);
object_ptr<Ui::RpWidget>(container)))->entity();
const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>( const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>(
labels, labels,
@@ -2664,18 +2654,18 @@ void AddWithdrawalWidget(
labels->resize( labels->resize(
majorSize.width() + icon->width() + skip, majorSize.width() + icon->width() + skip,
majorSize.height()); majorSize.height());
labels->setNaturalWidth(majorSize.width() + icon->width() + skip);
majorLabel->moveToLeft(icon->width() + skip, 0); majorLabel->moveToLeft(icon->width() + skip, 0);
}, labels->lifetime()); }, labels->lifetime());
Ui::ToggleChildrenVisibility(labels, true); Ui::ToggleChildrenVisibility(labels, true);
Ui::AddSkip(container); Ui::AddSkip(container);
container->add( container->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(
container, container,
object_ptr<Ui::FlatLabel>( std::move(usdValue),
container, st::channelEarnOverviewSubMinorLabel),
std::move(usdValue), style::al_top);
st::channelEarnOverviewSubMinorLabel)));
Ui::AddSkip(container); Ui::AddSkip(container);
@@ -136,25 +136,24 @@ void LocalPasscodeEnter::setupContent() {
Ui::AddSkip(content); Ui::AddSkip(content);
content->add( content->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(
content, content,
object_ptr<Ui::FlatLabel>( isCreate
content, ? tr::lng_passcode_create_title()
isCreate : isCheck
? tr::lng_passcode_create_title() ? tr::lng_passcode_check_title()
: isCheck : tr::lng_passcode_change_title(),
? tr::lng_passcode_check_title() st::changePhoneTitle),
: tr::lng_passcode_change_title(), st::changePhoneTitlePadding,
st::changePhoneTitle)), style::al_top);
st::changePhoneTitlePadding);
const auto addDescription = [&](rpl::producer<QString> &&text) { const auto addDescription = [&](rpl::producer<QString> &&text) {
const auto &st = st::settingLocalPasscodeDescription; const auto &st = st::settingLocalPasscodeDescription;
content->add( content->add(
object_ptr<Ui::CenterWrap<>>( object_ptr<Ui::FlatLabel>(content, std::move(text), st),
content, st::changePhoneDescriptionPadding,
object_ptr<Ui::FlatLabel>(content, std::move(text), st)), style::al_top
st::changePhoneDescriptionPadding); )->setTryMakeSimilarLines(true);
}; };
addDescription(tr::lng_passcode_about1()); addDescription(tr::lng_passcode_about1());
@@ -183,14 +182,13 @@ void LocalPasscodeEnter::setupContent() {
const auto addError = [&](not_null<Ui::PasswordInput*> input) { const auto addError = [&](not_null<Ui::PasswordInput*> input) {
const auto error = content->add( const auto error = content->add(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>( object_ptr<Ui::FlatLabel>(
content, content,
object_ptr<Ui::FlatLabel>( // Set any text to resize.
content, tr::lng_language_name(tr::now),
// Set any text to resize. st::settingLocalPasscodeError),
tr::lng_language_name(tr::now), st::changePhoneDescriptionPadding,
st::settingLocalPasscodeError)), style::al_top);
st::changePhoneDescriptionPadding)->entity();
error->hide(); error->hide();
QObject::connect(input.get(), &Ui::MaskedInputField::changed, [=] { QObject::connect(input.get(), &Ui::MaskedInputField::changed, [=] {
error->hide(); error->hide();
@@ -208,17 +206,16 @@ void LocalPasscodeEnter::setupContent() {
const auto error = addError(isCheck ? newPasscode : reenterPasscode); const auto error = addError(isCheck ? newPasscode : reenterPasscode);
const auto button = content->add( const auto button = content->add(
object_ptr<Ui::CenterWrap<Ui::RoundButton>>( object_ptr<Ui::RoundButton>(
content, content,
object_ptr<Ui::RoundButton>( (isCreate
content, ? tr::lng_passcode_create_button()
(isCreate : isCheck
? tr::lng_passcode_create_button() ? tr::lng_passcode_check_button()
: isCheck : tr::lng_passcode_change_button()),
? tr::lng_passcode_check_button() st::changePhoneButton),
: tr::lng_passcode_change_button()), st::settingLocalPasscodeButtonPadding,
st::changePhoneButton)), style::al_top);
st::settingLocalPasscodeButtonPadding)->entity();
button->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); button->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
button->setClickedCallback([=] { button->setClickedCallback([=] {
const auto newText = newPasscode->text(); const auto newText = newPasscode->text();
@@ -59,7 +59,7 @@ void PowerSavingBox(not_null<Ui::GenericBox*> box) {
state->forceDisabledMessage.value()); state->forceDisabledMessage.value());
const auto controlsRaw = checkboxes.data(); const auto controlsRaw = checkboxes.data();
box->addRow(std::move(checkboxes), {}); box->addRow(std::move(checkboxes), style::margins());
auto automatic = (Ui::SettingsButton*)nullptr; auto automatic = (Ui::SettingsButton*)nullptr;
if (batterySaving.has_value()) { if (batterySaving.has_value()) {
@@ -112,13 +112,12 @@ void InfoBox(
}); });
const auto userpic = box->addRow( const auto userpic = box->addRow(
object_ptr<Ui::CenterWrap<Ui::UserpicButton>>( object_ptr<Ui::UserpicButton>(
box, box,
object_ptr<Ui::UserpicButton>( data.bot,
box, st::websiteBigUserpic),
data.bot, st::sessionBigCoverPadding,
st::websiteBigUserpic)), style::al_top);
st::sessionBigCoverPadding)->entity();
userpic->overrideShape(Ui::PeerUserpicShape::Forum); userpic->overrideShape(Ui::PeerUserpicShape::Forum);
userpic->setAttribute(Qt::WA_TransparentForMouseEvents); userpic->setAttribute(Qt::WA_TransparentForMouseEvents);
@@ -57,12 +57,10 @@ constexpr auto kShowOrLineOpacity = 0.3;
object_ptr<RpWidget> MakeShowOrLabel( object_ptr<RpWidget> MakeShowOrLabel(
not_null<RpWidget*> parent, not_null<RpWidget*> parent,
rpl::producer<QString> text) { rpl::producer<QString> text) {
auto result = object_ptr<CenterWrap<>>( auto result = object_ptr<FlatLabel>(
parent, parent,
object_ptr<FlatLabel>( std::move(text),
parent, st::showOrLabel);
std::move(text),
st::showOrLabel));
const auto raw = result.data(); const auto raw = result.data();
raw->paintRequest( raw->paintRequest(
@@ -71,8 +69,7 @@ object_ptr<RpWidget> MakeShowOrLabel(
const auto full = st::showOrLineWidth; const auto full = st::showOrLineWidth;
const auto left = (raw->width() - full) / 2; const auto left = (raw->width() - full) / 2;
const auto text = raw->entity()->naturalWidth() const auto text = raw->naturalWidth() + 2 * st::showOrLabelSkip;
+ 2 * st::showOrLabelSkip;
const auto fill = (full - text) / 2; const auto fill = (full - text) / 2;
const auto stroke = st::lineWidth; const auto stroke = st::lineWidth;
const auto top = st::showOrLineTop; const auto top = st::showOrLineTop;
@@ -174,7 +171,7 @@ void ShowOrPremiumBox(
box->addRow( box->addRow(
MakeShowOrLabel(box, std::move(skin.orPremium)), MakeShowOrLabel(box, std::move(skin.orPremium)),
st::showOrLabelPadding + buttonPadding, st::showOrLabelPadding + buttonPadding,
style::al_top); style::al_justify);
box->addRow( box->addRow(
object_ptr<FlatLabel>( object_ptr<FlatLabel>(
box, box,
@@ -221,6 +221,7 @@ UserpicButton::~UserpicButton() = default;
void UserpicButton::prepare() { void UserpicButton::prepare() {
resize(_st.size); resize(_st.size);
setNaturalWidth(_st.size.width());
_notShownYet = _waiting; _notShownYet = _waiting;
if (!_waiting) { if (!_waiting) {
prepareUserpicPixmap(); prepareUserpicPixmap();
@@ -42,9 +42,9 @@ object_ptr<Ui::RpWidget> CreatePeerBubble(
) | rpl::start_with_next([=]( ) | rpl::start_with_next([=](
const QSize &leftSize, const QSize &leftSize,
const QSize &rightSize) { const QSize &rightSize) {
peerBubble->resize( peerBubble->setNaturalWidth(
leftSize.width() + rightSize.width() + rect::m::sum::h(padding), leftSize.width() + rightSize.width() + rect::m::sum::h(padding));
leftSize.height()); peerBubble->resize(peerBubble->naturalWidth(), leftSize.height());
left->moveToLeft(0, 0); left->moveToLeft(0, 0);
right->moveToRight(padding.right() + st::lineWidth, padding.top()); right->moveToRight(padding.right() + st::lineWidth, padding.top());
const auto maxRightSize = parent->width() const auto maxRightSize = parent->width()