From d6776a1a927ae897a02072f31130a58426d904a5 Mon Sep 17 00:00:00 2001 From: Maximilian Seidler Date: Fri, 28 Nov 2025 08:35:37 +0100 Subject: [PATCH] introduce create2 to avoid breaking the API --- include/hyprutils/animation/AnimatedVariable.hpp | 16 ++++++++++++++-- src/animation/AnimatedVariable.cpp | 11 ++++++++++- tests/animation/Animation.cpp | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/hyprutils/animation/AnimatedVariable.hpp b/include/hyprutils/animation/AnimatedVariable.hpp index 653d96a..668661b 100644 --- a/include/hyprutils/animation/AnimatedVariable.hpp +++ b/include/hyprutils/animation/AnimatedVariable.hpp @@ -21,7 +21,8 @@ namespace Hyprutils { ; // m_bDummy = true; }; - void create(CAnimationManager*, int, Memory::CWeakPointer); + void create(CAnimationManager*, int, Memory::CSharedPointer); + void create2(CAnimationManager*, int, Memory::CWeakPointer); void connectToActive(); void disconnectFromActive(); @@ -136,7 +137,8 @@ namespace Hyprutils { public: CGenericAnimatedVariable() = default; - void create(const int typeInfo, CAnimationManager* pAnimationManager, Memory::CWeakPointer> pSelf, + /* Deprecated: use create2 */ + void create(const int typeInfo, CAnimationManager* pAnimationManager, Memory::CSharedPointer> pSelf, const VarType& initialValue) { m_Begun = initialValue; m_Value = initialValue; @@ -145,6 +147,16 @@ namespace Hyprutils { CBaseAnimatedVariable::create(pAnimationManager, typeInfo, pSelf); } + /* Equivalent to create, except that it allows animated variables to be UP's */ + void create2(const int typeInfo, CAnimationManager* pAnimationManager, Memory::CWeakPointer> pSelf, + const VarType& initialValue) { + m_Begun = initialValue; + m_Value = initialValue; + m_Goal = initialValue; + + CBaseAnimatedVariable::create2(pAnimationManager, typeInfo, pSelf); + } + CGenericAnimatedVariable(const CGenericAnimatedVariable&) = delete; CGenericAnimatedVariable(CGenericAnimatedVariable&&) = delete; CGenericAnimatedVariable& operator=(const CGenericAnimatedVariable&) = delete; diff --git a/src/animation/AnimatedVariable.cpp b/src/animation/AnimatedVariable.cpp index 1a60ec4..81da415 100644 --- a/src/animation/AnimatedVariable.cpp +++ b/src/animation/AnimatedVariable.cpp @@ -11,7 +11,16 @@ static const std::string DEFAULTSTYLE = ""; #define SP CSharedPointer #define WP CWeakPointer -void CBaseAnimatedVariable::create(CAnimationManager* pManager, int typeInfo, WP pSelf) { +void CBaseAnimatedVariable::create(CAnimationManager* pManager, int typeInfo, SP pSelf) { + m_Type = typeInfo; + m_pSelf = std::move(pSelf); + + m_pAnimationManager = pManager; + m_pSignals = pManager->getSignals(); + m_bDummy = false; +} + +void CBaseAnimatedVariable::create2(CAnimationManager* pManager, int typeInfo, WP pSelf) { m_Type = typeInfo; m_pSelf = std::move(pSelf); diff --git a/tests/animation/Animation.cpp b/tests/animation/Animation.cpp index 380fb12..7a2b639 100644 --- a/tests/animation/Animation.cpp +++ b/tests/animation/Animation.cpp @@ -94,7 +94,7 @@ class CMyAnimationManager : public CAnimationManager { constexpr const eAVTypes EAVTYPE = std::is_same_v ? eAVTypes::INT : eAVTypes::TEST; av = makeUnique>(); - av->create(EAVTYPE, sc(this), av, v); + av->create2(EAVTYPE, sc(this), av, v); av->setConfig(animationTree.getConfig(animationConfigName)); }