summaryrefslogtreecommitdiff
path: root/src/managers/AnimationManager.hpp
diff options
context:
space:
mode:
authorMaximilian Seidler <78690852+PaideiaDilemma@users.noreply.github.com>2025-01-07 17:55:14 +0000
committerGitHub <noreply@github.com>2025-01-07 17:55:14 +0000
commit5642ed331df56375c55cd8d56a14054af8bdf8f2 (patch)
tree74a85b022b3319cdfad01343358eaf09a94841d1 /src/managers/AnimationManager.hpp
parentc7086f936a06abebcc863c35f634760ca1ee90c0 (diff)
core: move parts of the animation system to hyprutils (#8868)
* core: change animation manager to use Hyprutils::Animation * config: move animation config to hyprutils animation tree * use g_pAnimationManager->createAnimation and the new PHLANIMVAR template * core: use CGenericAnimatedVariabled::{enabled,setConfig,getStyle} and adapt callbacks * core: adapt animated variable usage (dereference the shared pointer) * misc: bump CMakeLists to hyprutils 0.3.3
Diffstat (limited to 'src/managers/AnimationManager.hpp')
-rw-r--r--src/managers/AnimationManager.hpp75
1 files changed, 41 insertions, 34 deletions
diff --git a/src/managers/AnimationManager.hpp b/src/managers/AnimationManager.hpp
index 3960f261..7bf73f97 100644
--- a/src/managers/AnimationManager.hpp
+++ b/src/managers/AnimationManager.hpp
@@ -1,57 +1,64 @@
#pragma once
+#include <hyprutils/animation/AnimationManager.hpp>
+#include <hyprutils/animation/AnimatedVariable.hpp>
+
#include "../defines.hpp"
-#include <list>
-#include <unordered_map>
#include "../helpers/AnimatedVariable.hpp"
-#include "../helpers/BezierCurve.hpp"
-#include "../helpers/Timer.hpp"
+#include "desktop/DesktopTypes.hpp"
#include "eventLoop/EventLoopTimer.hpp"
-class CWindow;
-
-class CAnimationManager {
+class CHyprAnimationManager : public Hyprutils::Animation::CAnimationManager {
public:
- CAnimationManager();
+ CHyprAnimationManager();
- void tick();
- bool shouldTickForNext();
- void onTicked();
- void scheduleTick();
- void addBezierWithName(std::string, const Vector2D&, const Vector2D&);
- void removeAllBeziers();
+ void tick();
+ virtual void scheduleTick();
+ virtual void onTicked();
- void onWindowPostCreateClose(PHLWINDOW, bool close = false);
+ using SAnimationPropertyConfig = Hyprutils::Animation::SAnimationPropertyConfig;
+ template <Animable VarType>
+ void createAnimation(const VarType& v, PHLANIMVAR<VarType>& pav, SP<SAnimationPropertyConfig> pConfig, eAVarDamagePolicy policy) {
+ constexpr const eAnimatedVarType EAVTYPE = typeToeAnimatedVarType<VarType>;
+ const auto PAV = makeShared<CAnimatedVariable<VarType>>();
- bool bezierExists(const std::string&);
- CBezierCurve* getBezier(const std::string&);
+ PAV->create(EAVTYPE, static_cast<Hyprutils::Animation::CAnimationManager*>(this), PAV, v);
+ PAV->setConfig(pConfig);
+ PAV->m_Context.eDamagePolicy = policy;
- std::string styleValidInConfigVar(const std::string&, const std::string&);
+ pav = std::move(PAV);
+ }
- std::unordered_map<std::string, CBezierCurve> getAllBeziers();
+ template <Animable VarType>
+ void createAnimation(const VarType& v, PHLANIMVAR<VarType>& pav, SP<SAnimationPropertyConfig> pConfig, PHLWINDOW pWindow, eAVarDamagePolicy policy) {
+ createAnimation(v, pav, pConfig, policy);
+ pav->m_Context.pWindow = pWindow;
+ }
+ template <Animable VarType>
+ void createAnimation(const VarType& v, PHLANIMVAR<VarType>& pav, SP<SAnimationPropertyConfig> pConfig, PHLWORKSPACE pWorkspace, eAVarDamagePolicy policy) {
+ createAnimation(v, pav, pConfig, policy);
+ pav->m_Context.pWorkspace = pWorkspace;
+ }
+ template <Animable VarType>
+ void createAnimation(const VarType& v, PHLANIMVAR<VarType>& pav, SP<SAnimationPropertyConfig> pConfig, PHLLS pLayer, eAVarDamagePolicy policy) {
+ createAnimation(v, pav, pConfig, policy);
+ pav->m_Context.pLayer = pLayer;
+ }
- std::vector<CBaseAnimatedVariable*> m_vAnimatedVariables;
- std::vector<CBaseAnimatedVariable*> m_vActiveAnimatedVariables;
+ void onWindowPostCreateClose(PHLWINDOW, bool close = false);
- SP<CEventLoopTimer> m_pAnimationTimer;
+ std::string styleValidInConfigVar(const std::string&, const std::string&);
- float m_fLastTickTime; // in ms
+ SP<CEventLoopTimer> m_pAnimationTimer;
- private:
- bool deltaSmallToFlip(const Vector2D& a, const Vector2D& b);
- bool deltaSmallToFlip(const CHyprColor& a, const CHyprColor& b);
- bool deltaSmallToFlip(const float& a, const float& b);
- bool deltazero(const Vector2D& a, const Vector2D& b);
- bool deltazero(const CHyprColor& a, const CHyprColor& b);
- bool deltazero(const float& a, const float& b);
+ float m_fLastTickTime; // in ms
- std::unordered_map<std::string, CBezierCurve> m_mBezierCurves;
-
- bool m_bTickScheduled = false;
+ private:
+ bool m_bTickScheduled = false;
// Anim stuff
void animationPopin(PHLWINDOW, bool close = false, float minPerc = 0.f);
void animationSlide(PHLWINDOW, std::string force = "", bool close = false);
};
-inline std::unique_ptr<CAnimationManager> g_pAnimationManager;
+inline std::unique_ptr<CHyprAnimationManager> g_pAnimationManager;