introduce create2 to avoid breaking the API

This commit is contained in:
Maximilian Seidler 2025-11-28 08:35:37 +01:00
parent 7b54f66387
commit d6776a1a92
3 changed files with 25 additions and 4 deletions

View file

@ -21,7 +21,8 @@ namespace Hyprutils {
; // m_bDummy = true;
};
void create(CAnimationManager*, int, Memory::CWeakPointer<CBaseAnimatedVariable>);
void create(CAnimationManager*, int, Memory::CSharedPointer<CBaseAnimatedVariable>);
void create2(CAnimationManager*, int, Memory::CWeakPointer<CBaseAnimatedVariable>);
void connectToActive();
void disconnectFromActive();
@ -136,7 +137,8 @@ namespace Hyprutils {
public:
CGenericAnimatedVariable() = default;
void create(const int typeInfo, CAnimationManager* pAnimationManager, Memory::CWeakPointer<CGenericAnimatedVariable<VarType, AnimationContext>> pSelf,
/* Deprecated: use create2 */
void create(const int typeInfo, CAnimationManager* pAnimationManager, Memory::CSharedPointer<CGenericAnimatedVariable<VarType, AnimationContext>> 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<CGenericAnimatedVariable<VarType, AnimationContext>> 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;

View file

@ -11,7 +11,16 @@ static const std::string DEFAULTSTYLE = "";
#define SP CSharedPointer
#define WP CWeakPointer
void CBaseAnimatedVariable::create(CAnimationManager* pManager, int typeInfo, WP<CBaseAnimatedVariable> pSelf) {
void CBaseAnimatedVariable::create(CAnimationManager* pManager, int typeInfo, SP<CBaseAnimatedVariable> 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<CBaseAnimatedVariable> pSelf) {
m_Type = typeInfo;
m_pSelf = std::move(pSelf);

View file

@ -94,7 +94,7 @@ class CMyAnimationManager : public CAnimationManager {
constexpr const eAVTypes EAVTYPE = std::is_same_v<VarType, int> ? eAVTypes::INT : eAVTypes::TEST;
av = makeUnique<CGenericAnimatedVariable<VarType, EmtpyContext>>();
av->create(EAVTYPE, sc<CAnimationManager*>(this), av, v);
av->create2(EAVTYPE, sc<CAnimationManager*>(this), av, v);
av->setConfig(animationTree.getConfig(animationConfigName));
}