mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +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*> parent,
|
||||
int size) {
|
||||
int size,
|
||||
const style::InfiniteRadialAnimation *st) {
|
||||
class Widget final : public Ui::RpWidget {
|
||||
public:
|
||||
Widget(not_null<Ui::RpWidget*> p, int size)
|
||||
Widget(
|
||||
not_null<Ui::RpWidget*> p,
|
||||
int size,
|
||||
const style::InfiniteRadialAnimation *st)
|
||||
: Ui::RpWidget(p)
|
||||
, _animation([=] { update(); }, st::startGiveawayButtonLoading) {
|
||||
, _st(st ? st : &st::startGiveawayButtonLoading)
|
||||
, _animation([=] { update(); }, *_st) {
|
||||
resize(size, size);
|
||||
shownValue() | rpl::start_with_next([=](bool v) {
|
||||
return v
|
||||
|
@ -39,17 +44,17 @@ not_null<Ui::RpWidget*> InfiniteRadialAnimationWidget(
|
|||
auto p = QPainter(this);
|
||||
p.setPen(st::activeButtonFg);
|
||||
p.setBrush(st::activeButtonFg);
|
||||
const auto r = rect()
|
||||
- Margins(st::startGiveawayButtonLoading.thickness);
|
||||
const auto r = rect() - Margins(_st->thickness);
|
||||
_animation.draw(p, r.topLeft(), r.size(), width());
|
||||
}
|
||||
|
||||
private:
|
||||
const style::InfiniteRadialAnimation *_st;
|
||||
Ui::InfiniteRadialAnimation _animation;
|
||||
|
||||
};
|
||||
|
||||
return Ui::CreateChild<Widget>(parent.get(), size);
|
||||
return Ui::CreateChild<Widget>(parent.get(), size, st);
|
||||
}
|
||||
|
||||
void AddChildToWidgetCenter(
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#pragma once
|
||||
|
||||
namespace style {
|
||||
struct InfiniteRadialAnimation;
|
||||
struct TextStyle;
|
||||
} // namespace style
|
||||
|
||||
|
@ -30,7 +31,8 @@ namespace Info::Statistics {
|
|||
|
||||
[[nodiscard]] not_null<Ui::RpWidget*> InfiniteRadialAnimationWidget(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
int size);
|
||||
int size,
|
||||
const style::InfiniteRadialAnimation *st = nullptr);
|
||||
|
||||
void AddChildToWidgetCenter(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
|
|
Loading…
Add table
Reference in a new issue