mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to provide custom style to widget with infinite animation.
This commit is contained in:
parent
f55584b160
commit
e9650385ad
2 changed files with 14 additions and 7 deletions
|
@ -20,12 +20,17 @@ namespace Info::Statistics {
|
||||||
|
|
||||||
not_null<Ui::RpWidget*> InfiniteRadialAnimationWidget(
|
not_null<Ui::RpWidget*> InfiniteRadialAnimationWidget(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
int size) {
|
int size,
|
||||||
|
const style::InfiniteRadialAnimation *st) {
|
||||||
class Widget final : public Ui::RpWidget {
|
class Widget final : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
Widget(not_null<Ui::RpWidget*> p, int size)
|
Widget(
|
||||||
|
not_null<Ui::RpWidget*> p,
|
||||||
|
int size,
|
||||||
|
const style::InfiniteRadialAnimation *st)
|
||||||
: Ui::RpWidget(p)
|
: Ui::RpWidget(p)
|
||||||
, _animation([=] { update(); }, st::startGiveawayButtonLoading) {
|
, _st(st ? st : &st::startGiveawayButtonLoading)
|
||||||
|
, _animation([=] { update(); }, *_st) {
|
||||||
resize(size, size);
|
resize(size, size);
|
||||||
shownValue() | rpl::start_with_next([=](bool v) {
|
shownValue() | rpl::start_with_next([=](bool v) {
|
||||||
return v
|
return v
|
||||||
|
@ -39,17 +44,17 @@ not_null<Ui::RpWidget*> InfiniteRadialAnimationWidget(
|
||||||
auto p = QPainter(this);
|
auto p = QPainter(this);
|
||||||
p.setPen(st::activeButtonFg);
|
p.setPen(st::activeButtonFg);
|
||||||
p.setBrush(st::activeButtonFg);
|
p.setBrush(st::activeButtonFg);
|
||||||
const auto r = rect()
|
const auto r = rect() - Margins(_st->thickness);
|
||||||
- Margins(st::startGiveawayButtonLoading.thickness);
|
|
||||||
_animation.draw(p, r.topLeft(), r.size(), width());
|
_animation.draw(p, r.topLeft(), r.size(), width());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const style::InfiniteRadialAnimation *_st;
|
||||||
Ui::InfiniteRadialAnimation _animation;
|
Ui::InfiniteRadialAnimation _animation;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return Ui::CreateChild<Widget>(parent.get(), size);
|
return Ui::CreateChild<Widget>(parent.get(), size, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddChildToWidgetCenter(
|
void AddChildToWidgetCenter(
|
||||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace style {
|
namespace style {
|
||||||
|
struct InfiniteRadialAnimation;
|
||||||
struct TextStyle;
|
struct TextStyle;
|
||||||
} // namespace style
|
} // namespace style
|
||||||
|
|
||||||
|
@ -30,7 +31,8 @@ namespace Info::Statistics {
|
||||||
|
|
||||||
[[nodiscard]] not_null<Ui::RpWidget*> InfiniteRadialAnimationWidget(
|
[[nodiscard]] not_null<Ui::RpWidget*> InfiniteRadialAnimationWidget(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
int size);
|
int size,
|
||||||
|
const style::InfiniteRadialAnimation *st = nullptr);
|
||||||
|
|
||||||
void AddChildToWidgetCenter(
|
void AddChildToWidgetCenter(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
|
Loading…
Add table
Reference in a new issue