From 9dc71ad9fa8c1ca28945af18e53bf432575a9775 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 4 Feb 2026 21:39:17 +0400 Subject: [PATCH] Add crafting lottie to the process. --- .../Resources/animations/craft_progress.tgs | Bin 0 -> 2739 bytes .../Resources/qrc/telegram/animations.qrc | 1 + .../boxes/star_gift_craft_animation.cpp | 81 ++++++++++++++++-- Telegram/SourceFiles/ui/effects/credits.style | 2 + 4 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 Telegram/Resources/animations/craft_progress.tgs diff --git a/Telegram/Resources/animations/craft_progress.tgs b/Telegram/Resources/animations/craft_progress.tgs new file mode 100644 index 0000000000000000000000000000000000000000..7bcdbda3b276bcefd4f27873a21295e47b26163a GIT binary patch literal 2739 zcmV;k3QYAMiwFP!000021MON%Zyd=D{wqeGYZ}EW)=Rg&B)fnR1W0l+bWkjLtynM2 zjJ+`g{r7xiRgb!RX7qvr%UZ**q^|BRlEv3YvTwTe@2l>BO!u`r=t3WQ*O~6)vO9>@ zbZ6Jy0e)TK7bnyG(H#VGru)=>UtZvyU%y;joG#z}_TlOhZ=Rf-=qtyo)#(}=zdthF z`SG{YrTl%fxqWtdqD0r14QN8k0CqePJS`(SIWTRA*#GYky4EoGhJx(6c}PkN#5KG}8ZAFRwnI?jgRG z6WV12#JzWJ$NAf;mDP-4YYqO(o#mF1?Gj=2dF!#&@z#Ii8AkH>$Z3hZ@zQ?{TD9rZoT=!VS`4;JsVsPUkZgdzo zf*p-8_|{Q@%fh-BWTrf#0wO8aJC#PWikNyP;8Nny+Z-i&b?d9@w)Ns{b1{|%M@Nm2 z&t*c$uC^`6rR8LeV}tl$!pV@dpUQC<;QK@cZ$E5=x17dSOb8 zGmTG=awFvH@#XTw(@TMNh{QfO`jneUZlJ_H6u3aTjo~RGg&kxljAik(IW(0eK3SF> zB>aRzlL19qHMRic`v?+Z`Ml3gZ+GMx@2WnCY+s09q}JQvWZC<{OuXMOc01RG6_D>! zK^4$TP;WTF^^S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?I^99mJ+Fam%Td0+(OU|l3>{0oW(4ggRxu?++S1OP4p`0nn7ZHb8IrR_#8 zx39255y+IeHhbj*#=g{gOIpIX7bZsnd;{QwpA`3Vzb&53l(bJR$WN+**v3;<4~uK* z?s{qXQ9nUfO(!Fal5B%G@>cOlznUgRuOZ494g_&( zr8U(H@U7IOtn--M6VR;oqU1goo!10_SMAvbpgtT~ggt2Itz84-Ml~RoF%3}Rz$Rp= zAFGU38lRhYHY*X&)czg(67X8-7Cls{WK;1*20M`lw5DCq!4Nmw)MjItEVWY_VY=4} z=p1Sk)DIqIi~rMpWxd0#?;@A<$Fq776So$3wmJvslhqOe5MIWAQeBT*+%ZLQ2HuP8dY{U09XNCQ../../animations/swipe_action/unpin.tgs ../../animations/swipe_action/read.tgs ../../animations/swipe_action/unread.tgs + ../../animations/craft_progress.tgs diff --git a/Telegram/SourceFiles/boxes/star_gift_craft_animation.cpp b/Telegram/SourceFiles/boxes/star_gift_craft_animation.cpp index 7a75148296..110fe2f216 100644 --- a/Telegram/SourceFiles/boxes/star_gift_craft_animation.cpp +++ b/Telegram/SourceFiles/boxes/star_gift_craft_animation.cpp @@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/peer_gifts/info_peer_gifts_common.h" #include "lang/lang_keys.h" #include "lottie/lottie_common.h" +#include "lottie/lottie_icon.h" #include "main/main_session.h" #include "settings/settings_credits_graphics.h" #include "ui/boxes/boost_box.h" @@ -1354,6 +1355,76 @@ CraftState::EmptySide CraftState::prepareEmptySide(int index) const { return { .bg = bg, .frame = result }; } +void SetupCraftProgressTitle( + not_null container, + not_null*> opacity) { + const auto row = container->add( + object_ptr(container), + st::boxRowPadding + st::craftProgressTitleMargin, + style::al_top); + + const auto label = CreateChild( + row, + tr::lng_gift_craft_progress(), + st::uniqueGiftTitle); + label->setTextColorOverride(st::white->c); + + const auto iconSize = st::craftProgressIconSize; + const auto iconWidget = CreateChild(row); + iconWidget->resize(iconSize); + + auto owned = Lottie::MakeIcon({ + .name = u"craft_progress"_q, + .sizeOverride = iconSize, + .limitFps = true, + }); + const auto icon = owned.get(); + iconWidget->lifetime().add([kept = std::move(owned)] {}); + + const auto startAnimation = [=] { + icon->animate( + [=] { iconWidget->update(); }, + 0, + icon->framesCount() - 1); + }; + startAnimation(); + + iconWidget->paintRequest( + ) | rpl::on_next([=] { + auto p = QPainter(iconWidget); + p.setOpacity(opacity->current()); + icon->paint(p, 0, 0); + if (!icon->animating() && icon->frameIndex() > 0) { + startAnimation(); + } + }, iconWidget->lifetime()); + + rpl::combine( + label->sizeValue(), + row->sizeValue() + ) | rpl::on_next([=](QSize labelSize, QSize rowSize) { + const auto skip = st::craftProgressIconSkip; + const auto totalWidth = iconSize.width() + skip + labelSize.width(); + const auto rowHeight = std::max(iconSize.height(), labelSize.height()); + if (rowSize.height() != rowHeight) { + row->resize(rowSize.width(), rowHeight); + return; + } + const auto left = (rowSize.width() - totalWidth) / 2; + iconWidget->move(left, (rowHeight - iconSize.height()) / 2); + label->move( + left + iconSize.width() + skip, + (rowHeight - labelSize.height()) / 2); + }, row->lifetime()); + + opacity->value( + ) | rpl::on_next([=](float64 value) { + label->setOpacity(value); + iconWidget->update(); + }, row->lifetime()); + +} + void SetupProgressControls( not_null state, not_null canvas) { @@ -1367,15 +1438,7 @@ void SetupProgressControls( controls->resizeToWidth(canvas->width()); controls->move(0, state->shared->craftingBottom); - const auto title = controls->add( - object_ptr( - controls, - tr::lng_gift_craft_progress(), - st::uniqueGiftTitle), - st::boxRowPadding + st::craftProgressTitleMargin, - style::al_top); - add(title); - title->setTextColorOverride(st::white->c); + SetupCraftProgressTitle(controls, &state->progressOpacity); const auto subColor = QColor(255, 255, 255, 178); const auto about = controls->add( diff --git a/Telegram/SourceFiles/ui/effects/credits.style b/Telegram/SourceFiles/ui/effects/credits.style index 74613058f8..597b8e1645 100644 --- a/Telegram/SourceFiles/ui/effects/credits.style +++ b/Telegram/SourceFiles/ui/effects/credits.style @@ -633,6 +633,8 @@ craftProgressTitleMargin: margins(0px, 12px, 0px, 16px); craftProgressAboutMargin: margins(0px, 4px, 0px, 16px); craftProgressWarningMargin: margins(0px, 4px, 0px, 16px); craftProgressChanceMargin: margins(0px, 40px, 0px, 16px); +craftProgressIconSize: size(24px, 24px); +craftProgressIconSkip: 4px; craftFailureThumbsTop: 36px; craftFailureTitleMargin: margins(0px, 88px, 0px, 12px); craftFailureAboutMargin: margins(0px, 0px, 0px, 16px);