/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once #include "base/object_ptr.h" #include "base/unique_qptr.h" #include "data/data_star_gift.h" #include "ui/effects/animations.h" #include "ui/effects/radial_animation.h" #include "ui/text/text_custom_emoji.h" namespace ChatHelpers { class Show; } // namespace ChatHelpers namespace Main { class Session; } // namespace Main namespace HistoryView { class StickerPlayer; } // namespace HistoryView namespace Info::PeerGifts { class GiftButton; } // namespace Info::PeerGifts namespace Ui { class GenericBox; class VerticalLayout; class UniqueGiftCoverWidget; using CraftResultCallback = Fn)>; struct BackdropView { Data::UniqueGiftBackdrop colors; QImage gradient; }; struct PatternView { std::unique_ptr emoji; base::flat_map> emojis; }; struct CraftState { struct Cover { BackdropView backdrop; PatternView pattern; QColor button1; QColor button2; Animations::Simple shownAnimation; bool shown = false; }; std::array covers; rpl::variable edgeColor; QColor button1; QColor button2; bool coversAnimate = false; bool craftingStarted = false; QImage craftBg; QImage topPart; QRect topPartRect; QImage bottomPart; int bottomPartY = 0; struct CornerSnapshot { base::unique_qptr giftButton; mutable QImage giftFrame; QImage percentBadge; QImage removeButton; QImage addButton; QRect originalRect; mutable bool giftFrameFinal = false; [[nodiscard]] QImage gift(float64 progress) const; }; std::array corners; QRect forgeRect; QColor forgeBgOverlay; QColor forgeBg1; QColor forgeBg2; QImage forgePercent; struct EmptySide { QColor bg; QImage frame; }; std::array forgeSides; EmptySide finalSide; Main::Session *session = nullptr; int containerHeight = 0; int craftingTop = 0; int craftingBottom = 0; int craftingAreaCenterY = 0; int craftingOffsetY = 0; void paint( QPainter &p, QSize size, int craftingHeight, float64 slideProgress = 0.); void updateForGiftCount(int count, Fn repaint); [[nodiscard]] EmptySide prepareEmptySide(int index) const; }; struct FacePlacement { int face = -1; int rotation = 0; }; struct CraftDoneAnimation { object_ptr owned; UniqueGiftCoverWidget *widget = nullptr; Animations::Simple shownAnimation; Animations::Simple heightAnimation; QImage frame; int coverHeight = 0; int coverShift = 0; float64 expanded = 0.; bool finished = false; bool hiding = false; }; struct CraftFailAnimation { std::unique_ptr player; QImage frame; DocumentData *document = nullptr; Animations::Simple scaleAnimation; bool scaleStarted = false; bool playerStarted = false; bool playerFinished = false; rpl::lifetime lifetime; }; struct CraftAnimationState { std::shared_ptr shared; Animations::Simple slideOutAnimation; Animations::Basic continuousAnimation; float64 rotationX = 0.; float64 rotationY = 0.; int currentlyFlying = -1; int giftsLanded = 0; int totalGifts = 0; bool allGiftsLanded = false; bool currentPhaseFinished = false; std::array giftToSide; Animations::Simple flightAnimation; int currentPhaseIndex = -1; crl::time animationStartTime = 0; crl::time animationDuration = 0; float64 initialRotationX = 0.; float64 initialRotationY = 0.; int nextFaceIndex = 0; int nextFaceRotation = 0; bool nextFaceRevealed = false; std::optional> flightTargetCorners; std::optional> craftResult; std::unique_ptr loadingAnimation; Animations::Simple loadingShownAnimation; crl::time loadingStartedTime = 0; bool loadingFadingOut = false; std::unique_ptr successAnimation; std::unique_ptr failureAnimation; }; void StartCraftAnimation( not_null box, std::shared_ptr show, std::shared_ptr state, Fn startRequest, Fn closeParent); } // namespace Ui