mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Moved out child centering within widget to single function.
This commit is contained in:
parent
431549c81a
commit
8bcb784f12
4 changed files with 18 additions and 14 deletions
|
@ -647,13 +647,7 @@ void GiftsBox(
|
|||
const auto loadingAnimation = InfiniteRadialAnimationWidget(
|
||||
raw,
|
||||
raw->height() / 2);
|
||||
raw->sizeValue(
|
||||
) | rpl::start_with_next([=](const QSize &s) {
|
||||
const auto size = loadingAnimation->size();
|
||||
loadingAnimation->moveToLeft(
|
||||
(s.width() - size.width()) / 2,
|
||||
(s.height() - size.height()) / 2);
|
||||
}, loadingAnimation->lifetime());
|
||||
AddChildToWidgetCenter(raw, loadingAnimation);
|
||||
loadingAnimation->showOn(state->confirmButtonBusy.value());
|
||||
}
|
||||
auto button = object_ptr<Ui::GradientButton>::fromRaw(raw);
|
||||
|
|
|
@ -958,13 +958,7 @@ void CreateGiveawayBox(
|
|||
const auto loadingAnimation = InfiniteRadialAnimationWidget(
|
||||
button,
|
||||
st::giveawayGiftCodeStartButton.height / 2);
|
||||
button->sizeValue(
|
||||
) | rpl::start_with_next([=](const QSize &s) {
|
||||
const auto size = loadingAnimation->size();
|
||||
loadingAnimation->moveToLeft(
|
||||
(s.width() - size.width()) / 2,
|
||||
(s.height() - size.height()) / 2);
|
||||
}, loadingAnimation->lifetime());
|
||||
AddChildToWidgetCenter(button.data(), loadingAnimation);
|
||||
loadingAnimation->showOn(state->confirmButtonBusy.value());
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,18 @@ not_null<Ui::RpWidget*> InfiniteRadialAnimationWidget(
|
|||
return Ui::CreateChild<Widget>(parent.get(), size);
|
||||
}
|
||||
|
||||
void AddChildToWidgetCenter(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<Ui::RpWidget*> child) {
|
||||
parent->sizeValue(
|
||||
) | rpl::start_with_next([=](const QSize &s) {
|
||||
const auto size = child->size();
|
||||
child->moveToLeft(
|
||||
(s.width() - size.width()) / 2,
|
||||
(s.height() - size.height()) / 2);
|
||||
}, child->lifetime());
|
||||
}
|
||||
|
||||
QImage CreateBadge(
|
||||
const style::TextStyle &textStyle,
|
||||
const QString &text,
|
||||
|
|
|
@ -32,6 +32,10 @@ namespace Info::Statistics {
|
|||
not_null<Ui::RpWidget*> parent,
|
||||
int size);
|
||||
|
||||
void AddChildToWidgetCenter(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<Ui::RpWidget*> child);
|
||||
|
||||
void AddLabelWithBadgeToButton(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
rpl::producer<QString> text,
|
||||
|
|
Loading…
Add table
Reference in a new issue