diff --git a/Telegram/SourceFiles/boxes/change_phone_box.cpp b/Telegram/SourceFiles/boxes/change_phone_box.cpp index bb2d840d86..dead1d2c39 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/change_phone_box.cpp @@ -510,7 +510,7 @@ void ChangePhone::setupContent() { } void ChangePhone::showFinished() { - _animate(); + _animate(anim::repeat::loop); } } // namespace Settings diff --git a/Telegram/SourceFiles/boxes/change_phone_box.h b/Telegram/SourceFiles/boxes/change_phone_box.h index ecaf197fe9..b837079e99 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.h +++ b/Telegram/SourceFiles/boxes/change_phone_box.h @@ -36,7 +36,7 @@ private: void setupContent(); const not_null _controller; - Fn _animate; + Fn _animate; }; diff --git a/Telegram/SourceFiles/settings/settings_blocked_peers.cpp b/Telegram/SourceFiles/settings/settings_blocked_peers.cpp index 64b01477b2..7ea81f1073 100644 --- a/Telegram/SourceFiles/settings/settings_blocked_peers.cpp +++ b/Telegram/SourceFiles/settings/settings_blocked_peers.cpp @@ -171,13 +171,12 @@ void Blocked::setupContent() { st::changePhoneIconSize, }, }, - st::blockedUsersListIconPadding, - true); + st::blockedUsersListIconPadding); content->add(std::move(icon.widget)); _showFinished.events( ) | rpl::start_with_next([animate = std::move(icon.animate)] { - animate(); + animate(anim::repeat::once); }, content->lifetime()); content->add( diff --git a/Telegram/SourceFiles/settings/settings_common.cpp b/Telegram/SourceFiles/settings/settings_common.cpp index c4d7650733..220bf526a3 100644 --- a/Telegram/SourceFiles/settings/settings_common.cpp +++ b/Telegram/SourceFiles/settings/settings_common.cpp @@ -249,8 +249,7 @@ not_null AddSubsectionTitle( LottieIcon CreateLottieIcon( not_null parent, Lottie::IconDescriptor &&descriptor, - style::margins padding, - bool playOnce) { + style::margins padding) { auto object = object_ptr(parent); const auto raw = object.data(); @@ -263,23 +262,22 @@ LottieIcon CreateLottieIcon( const auto icon = owned.get(); raw->lifetime().add([kept = std::move(owned)]{}); - const auto animationRequired = raw->lifetime().make_state(true); + const auto looped = raw->lifetime().make_state(true); - const auto animate = [=] { - if (playOnce) { - if (!base::take(*animationRequired)) { - return; - } - } + const auto start = [=] { icon->animate([=] { raw->update(); }, 0, icon->framesCount() - 1); }; + const auto animate = [=](anim::repeat repeat) { + *looped = (repeat == anim::repeat::loop); + start(); + }; raw->paintRequest( ) | rpl::start_with_next([=] { auto p = QPainter(raw); const auto left = (raw->width() - width) / 2; icon->paint(p, left, padding.top()); - if (!icon->animating() && icon->frameIndex() > 0) { - animate(); + if (!icon->animating() && icon->frameIndex() > 0 && *looped) { + start(); } }, raw->lifetime()); diff --git a/Telegram/SourceFiles/settings/settings_common.h b/Telegram/SourceFiles/settings/settings_common.h index 5bf9e064be..fcf46a0cf2 100644 --- a/Telegram/SourceFiles/settings/settings_common.h +++ b/Telegram/SourceFiles/settings/settings_common.h @@ -13,6 +13,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/object_ptr.h" #include "settings/settings_type.h" +namespace anim { +enum class repeat : uchar; +} // namespace anim + namespace Main { class Session; } // namespace Main @@ -180,13 +184,12 @@ not_null AddSubsectionTitle( struct LottieIcon { object_ptr widget; - Fn animate; + Fn animate; }; [[nodiscard]] LottieIcon CreateLottieIcon( not_null parent, Lottie::IconDescriptor &&descriptor, - style::margins padding = {}, - bool playOnce = false); + style::margins padding = {}); void FillMenu( not_null controller, diff --git a/Telegram/SourceFiles/settings/settings_folders.cpp b/Telegram/SourceFiles/settings/settings_folders.cpp index efeb5032db..ce3f4e51d1 100644 --- a/Telegram/SourceFiles/settings/settings_folders.cpp +++ b/Telegram/SourceFiles/settings/settings_folders.cpp @@ -613,11 +613,10 @@ QPointer Folders::createPinnedToTop(not_null parent) { st::settingsFilterIconSize, }, }, - st::settingsFilterIconPadding, - true); + st::settingsFilterIconPadding); _showFinished.events( ) | rpl::start_with_next([animate = std::move(icon.animate)] { - animate(); + animate(anim::repeat::once); }, verticalLayout->lifetime()); verticalLayout->add(std::move(icon.widget)); diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 9d07d6a476..9b6e11db62 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 9d07d6a476f057c55af9392804c3e8b6246c637c +Subproject commit 9b6e11db62810626a56431cdc8eeb771817f6560