summaryrefslogtreecommitdiff
path: root/src/helpers
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-03-29 00:23:16 +0000
committerVaxry <vaxry@vaxry.net>2024-03-29 00:23:23 +0000
commit2930c5cb6f5d71dbdfd4d396287f90e19cd41228 (patch)
tree113e1ab6045b2f44c01f2fa0af44c7ef878b2cb6 /src/helpers
parentd8429eebc66e7091381502edc0fc7335790f62e4 (diff)
animvar: fixup update callbacks and cleanup
Diffstat (limited to 'src/helpers')
-rw-r--r--src/helpers/AnimatedVariable.cpp25
-rw-r--r--src/helpers/AnimatedVariable.hpp28
-rw-r--r--src/helpers/WLClasses.cpp9
3 files changed, 53 insertions, 9 deletions
diff --git a/src/helpers/AnimatedVariable.cpp b/src/helpers/AnimatedVariable.cpp
index 3a891e37..74575c83 100644
--- a/src/helpers/AnimatedVariable.cpp
+++ b/src/helpers/AnimatedVariable.cpp
@@ -6,7 +6,7 @@ CBaseAnimatedVariable::CBaseAnimatedVariable(ANIMATEDVARTYPE type) : m_Type(type
; // dummy var
}
-void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, void* pWindow, AVARDAMAGEPOLICY policy) {
+void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, CWindow* pWindow, AVARDAMAGEPOLICY policy) {
m_eDamagePolicy = policy;
m_pConfig = pAnimConfig;
m_pWindow = pWindow;
@@ -14,6 +14,29 @@ void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, void*
m_bDummy = false;
}
+void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, SLayerSurface* pLayer, AVARDAMAGEPOLICY policy) {
+ m_eDamagePolicy = policy;
+ m_pConfig = pAnimConfig;
+ m_pLayer = pLayer;
+
+ m_bDummy = false;
+}
+
+void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, CWorkspace* pWorkspace, AVARDAMAGEPOLICY policy) {
+ m_eDamagePolicy = policy;
+ m_pConfig = pAnimConfig;
+ m_pWorkspace = pWorkspace;
+
+ m_bDummy = false;
+}
+
+void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, AVARDAMAGEPOLICY policy) {
+ m_eDamagePolicy = policy;
+ m_pConfig = pAnimConfig;
+
+ m_bDummy = false;
+}
+
CBaseAnimatedVariable::~CBaseAnimatedVariable() {
unregister();
}
diff --git a/src/helpers/AnimatedVariable.hpp b/src/helpers/AnimatedVariable.hpp
index 88c775af..82e30892 100644
--- a/src/helpers/AnimatedVariable.hpp
+++ b/src/helpers/AnimatedVariable.hpp
@@ -67,7 +67,10 @@ concept Animable = OneOf<T, Vector2D, float, CColor>;
class CBaseAnimatedVariable {
public:
CBaseAnimatedVariable(ANIMATEDVARTYPE type);
- void create(SAnimationPropertyConfig* pAnimConfig, void* pWindow, AVARDAMAGEPOLICY policy);
+ void create(SAnimationPropertyConfig* pAnimConfig, CWindow* pWindow, AVARDAMAGEPOLICY policy);
+ void create(SAnimationPropertyConfig* pAnimConfig, SLayerSurface* pLayer, AVARDAMAGEPOLICY policy);
+ void create(SAnimationPropertyConfig* pAnimConfig, CWorkspace* pWorkspace, AVARDAMAGEPOLICY policy);
+ void create(SAnimationPropertyConfig* pAnimConfig, AVARDAMAGEPOLICY policy);
CBaseAnimatedVariable(const CBaseAnimatedVariable&) = delete;
CBaseAnimatedVariable(CBaseAnimatedVariable&&) = delete;
@@ -204,11 +207,26 @@ class CAnimatedVariable : public CBaseAnimatedVariable {
public:
CAnimatedVariable() : CBaseAnimatedVariable(typeToANIMATEDVARTYPE<VarType>) {} // dummy var
- void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, void* pWindow, AVARDAMAGEPOLICY policy) {
+ void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, CWindow* pWindow, AVARDAMAGEPOLICY policy) {
create(pAnimConfig, pWindow, policy);
m_Value = value;
m_Goal = value;
}
+ void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, SLayerSurface* pLayer, AVARDAMAGEPOLICY policy) {
+ create(pAnimConfig, pLayer, policy);
+ m_Value = value;
+ m_Goal = value;
+ }
+ void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, CWorkspace* pWorkspace, AVARDAMAGEPOLICY policy) {
+ create(pAnimConfig, pWorkspace, policy);
+ m_Value = value;
+ m_Goal = value;
+ }
+ void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, AVARDAMAGEPOLICY policy) {
+ create(pAnimConfig, policy);
+ m_Value = value;
+ m_Goal = value;
+ }
using CBaseAnimatedVariable::create;
@@ -261,10 +279,16 @@ class CAnimatedVariable : public CBaseAnimatedVariable {
}
void warp(bool endCallback = true) override {
+ if (m_Value == m_Goal)
+ return;
+
m_Value = m_Goal;
m_bIsBeingAnimated = false;
+ if (m_fUpdateCallback)
+ m_fUpdateCallback(this);
+
if (endCallback)
onAnimationEnd();
}
diff --git a/src/helpers/WLClasses.cpp b/src/helpers/WLClasses.cpp
index edcdfb14..084a719d 100644
--- a/src/helpers/WLClasses.cpp
+++ b/src/helpers/WLClasses.cpp
@@ -3,12 +3,9 @@
#include "../Compositor.hpp"
SLayerSurface::SLayerSurface() {
- alpha.create(g_pConfigManager->getAnimationPropertyConfig("fadeLayers"), nullptr, AVARDAMAGE_ENTIRE);
- realPosition.create(g_pConfigManager->getAnimationPropertyConfig("layers"), nullptr, AVARDAMAGE_ENTIRE);
- realSize.create(g_pConfigManager->getAnimationPropertyConfig("layers"), nullptr, AVARDAMAGE_ENTIRE);
- alpha.m_pLayer = this;
- realPosition.m_pLayer = this;
- realSize.m_pLayer = this;
+ alpha.create(g_pConfigManager->getAnimationPropertyConfig("fadeLayers"), this, AVARDAMAGE_ENTIRE);
+ realPosition.create(g_pConfigManager->getAnimationPropertyConfig("layers"), this, AVARDAMAGE_ENTIRE);
+ realSize.create(g_pConfigManager->getAnimationPropertyConfig("layers"), this, AVARDAMAGE_ENTIRE);
alpha.registerVar();
realPosition.registerVar();
realSize.registerVar();