diff --git a/Telegram/SourceFiles/api/api_chat_invite.cpp b/Telegram/SourceFiles/api/api_chat_invite.cpp index 134e3a005..18cab335e 100644 --- a/Telegram/SourceFiles/api/api_chat_invite.cpp +++ b/Telegram/SourceFiles/api/api_chat_invite.cpp @@ -207,32 +207,12 @@ void ConfirmSubscriptionBox( Ui::AddSkip(content); Ui::AddSkip(content); - { - const auto widget = Ui::CreateChild(content); - using ColoredMiniStars = Ui::Premium::ColoredMiniStars; - const auto stars = widget->lifetime().make_state( - widget, - false, - Ui::Premium::MiniStars::Type::BiStars); - stars->setColorOverride(Ui::Premium::CreditsIconGradientStops()); - widget->resize( - st::boxWideWidth - photoSize, - photoSize * 2); - content->sizeValue( - ) | rpl::start_with_next([=](const QSize &size) { - widget->moveToLeft(photoSize / 2, 0); - const auto starsRect = Rect(widget->size()); - stars->setPosition(starsRect.topLeft()); - stars->setSize(starsRect.size()); - widget->lower(); - }, widget->lifetime()); - widget->paintRequest( - ) | rpl::start_with_next([=](const QRect &r) { - auto p = QPainter(widget); - p.fillRect(r, Qt::transparent); - stars->paint(p); - }, widget->lifetime()); - } + Settings::AddMiniStars( + content, + Ui::CreateChild(content), + photoSize, + box->width(), + 2.); box->addRow( object_ptr>( diff --git a/Telegram/SourceFiles/boxes/gift_credits_box.cpp b/Telegram/SourceFiles/boxes/gift_credits_box.cpp index 4dfcbd173..80e859eb1 100644 --- a/Telegram/SourceFiles/boxes/gift_credits_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_credits_box.cpp @@ -47,6 +47,7 @@ void GiftCreditsBox( const auto content = box->setPinnedToTopContent( object_ptr(box)); + Ui::AddSkip(content); Ui::AddSkip(content); Ui::AddSkip(content); const auto &stUser = st::premiumGiftsUserpicButton; @@ -58,32 +59,12 @@ void GiftCreditsBox( Ui::AddSkip(content); Ui::AddSkip(content); - { - const auto widget = Ui::CreateChild(content); - using ColoredMiniStars = Ui::Premium::ColoredMiniStars; - const auto stars = widget->lifetime().make_state( - widget, - false, - Ui::Premium::MiniStars::Type::BiStars); - stars->setColorOverride(Ui::Premium::CreditsIconGradientStops()); - widget->resize( - st::boxWidth - stUser.photoSize, - stUser.photoSize * 2); - content->sizeValue( - ) | rpl::start_with_next([=](const QSize &size) { - widget->moveToLeft(stUser.photoSize / 2, 0); - const auto starsRect = Rect(widget->size()); - stars->setPosition(starsRect.topLeft()); - stars->setSize(starsRect.size()); - widget->lower(); - }, widget->lifetime()); - widget->paintRequest( - ) | rpl::start_with_next([=](const QRect &r) { - auto p = QPainter(widget); - p.fillRect(r, Qt::transparent); - stars->paint(p); - }, widget->lifetime()); - } + Settings::AddMiniStars( + content, + Ui::CreateChild(content), + stUser.photoSize, + box->width(), + 2.); { Ui::AddSkip(content); const auto arrow = Ui::Text::SingleCustomEmoji( diff --git a/Telegram/SourceFiles/boxes/star_gift_box.cpp b/Telegram/SourceFiles/boxes/star_gift_box.cpp index e7b0a968c..f7918320c 100644 --- a/Telegram/SourceFiles/boxes/star_gift_box.cpp +++ b/Telegram/SourceFiles/boxes/star_gift_box.cpp @@ -1325,32 +1325,12 @@ void GiftBox( AddSkip(content); AddSkip(content); - { - const auto widget = CreateChild(content); - using ColoredMiniStars = Premium::ColoredMiniStars; - const auto stars = widget->lifetime().make_state( - widget, - false, - Premium::MiniStars::Type::BiStars); - stars->setColorOverride(Premium::CreditsIconGradientStops()); - widget->resize( - st::boxWidth - stUser.photoSize, - stUser.photoSize * 2); - content->sizeValue( - ) | rpl::start_with_next([=](const QSize &size) { - widget->moveToLeft((size.width() - widget->width()) / 2, 0); - const auto starsRect = Rect(widget->size()); - stars->setPosition(starsRect.topLeft()); - stars->setSize(starsRect.size()); - widget->lower(); - }, widget->lifetime()); - widget->paintRequest( - ) | rpl::start_with_next([=](const QRect &r) { - auto p = QPainter(widget); - p.fillRect(r, Qt::transparent); - stars->paint(p); - }, widget->lifetime()); - } + Settings::AddMiniStars( + content, + Ui::CreateChild(content), + stUser.photoSize, + box->width(), + 2.); AddSkip(content); AddSkip(box->verticalLayout()); diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index a53c63954..a26dc1fcd 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -348,10 +348,12 @@ void AddViewMediaHandler( }, thumb->lifetime()); } +} // namespace + void AddMiniStars( not_null content, not_null widget, - const style::UserpicButton &stUser, + int photoSize, int boxWidth, float64 heightRatio) { using ColoredMiniStars = Ui::Premium::ColoredMiniStars; @@ -360,12 +362,10 @@ void AddMiniStars( false, Ui::Premium::MiniStars::Type::BiStars); stars->setColorOverride(Ui::Premium::CreditsIconGradientStops()); - widget->resize( - boxWidth - stUser.photoSize, - stUser.photoSize * heightRatio); + widget->resize(boxWidth - photoSize, photoSize * heightRatio); content->sizeValue( ) | rpl::start_with_next([=](const QSize &size) { - widget->moveToLeft(stUser.photoSize / 2, 0); + widget->moveToLeft(photoSize / 2, 0); const auto starsRect = Rect(widget->size()); stars->setPosition(starsRect.topLeft()); stars->setSize(starsRect.size()); @@ -379,8 +379,6 @@ void AddMiniStars( }, widget->lifetime()); } -} // namespace - SubscriptionRightLabel PaintSubscriptionRightLabelCallback( not_null session, const style::PeerListItem &st, @@ -699,7 +697,7 @@ void BoostCreditsBox( { const auto &stUser = st::premiumGiftsUserpicButton; const auto widget = content->add(object_ptr(content)); - AddMiniStars(content, widget, stUser, st::boxWidth, 1.3); + AddMiniStars(content, widget, stUser.photoSize, st::boxWidth, 1.3); const auto svg = std::make_shared( Ui::Premium::ColorizedSvg( Ui::Premium::CreditsIconGradientStops())); @@ -893,7 +891,8 @@ void ReceiptCreditsBox( } else if (s.photoId || (e.photoId && !e.subscriptionUntil.isNull())) { if (!(s.cancelled || s.expired || s.cancelledByBot)) { const auto widget = Ui::CreateChild(content); - AddMiniStars(content, widget, stUser, st::boxWideWidth, 1.5); + const auto photoSize = stUser.photoSize; + AddMiniStars(content, widget, photoSize, st::boxWideWidth, 1.5); } const auto photoId = s.photoId ? s.photoId : e.photoId; const auto callback = [=](Fn update) { @@ -1427,7 +1426,7 @@ void ReceiptCreditsBox( if (e.peerType == Data::CreditsHistoryEntry::PeerType::PremiumBot) { const auto widget = Ui::CreateChild(content); - AddMiniStars(content, widget, stUser, st::boxWideWidth, 2); + AddMiniStars(content, widget, stUser.photoSize, st::boxWideWidth, 2); } const auto rejoinByApi = base::unixtime::serialize(s.until) diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.h b/Telegram/SourceFiles/settings/settings_credits_graphics.h index 9a40d0aca..6fc03c4a5 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.h +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.h @@ -179,5 +179,11 @@ void MaybeRequestBalanceIncrease( SmallBalanceSource source, Fn done); -} // namespace Settings +void AddMiniStars( + not_null content, + not_null widget, + int photoSize, + int boxWidth, + float64 heightRatio); +} // namespace Settings