From 5642ed331df56375c55cd8d56a14054af8bdf8f2 Mon Sep 17 00:00:00 2001 From: Maximilian Seidler <78690852+PaideiaDilemma@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:55:14 +0000 Subject: 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 --- src/managers/AnimationManager.hpp | 75 +++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 34 deletions(-) (limited to 'src/managers/AnimationManager.hpp') 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 +#include + #include "../defines.hpp" -#include -#include #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 + void createAnimation(const VarType& v, PHLANIMVAR& pav, SP pConfig, eAVarDamagePolicy policy) { + constexpr const eAnimatedVarType EAVTYPE = typeToeAnimatedVarType; + const auto PAV = makeShared>(); - bool bezierExists(const std::string&); - CBezierCurve* getBezier(const std::string&); + PAV->create(EAVTYPE, static_cast(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 getAllBeziers(); + template + void createAnimation(const VarType& v, PHLANIMVAR& pav, SP pConfig, PHLWINDOW pWindow, eAVarDamagePolicy policy) { + createAnimation(v, pav, pConfig, policy); + pav->m_Context.pWindow = pWindow; + } + template + void createAnimation(const VarType& v, PHLANIMVAR& pav, SP pConfig, PHLWORKSPACE pWorkspace, eAVarDamagePolicy policy) { + createAnimation(v, pav, pConfig, policy); + pav->m_Context.pWorkspace = pWorkspace; + } + template + void createAnimation(const VarType& v, PHLANIMVAR& pav, SP pConfig, PHLLS pLayer, eAVarDamagePolicy policy) { + createAnimation(v, pav, pConfig, policy); + pav->m_Context.pLayer = pLayer; + } - std::vector m_vAnimatedVariables; - std::vector m_vActiveAnimatedVariables; + void onWindowPostCreateClose(PHLWINDOW, bool close = false); - SP m_pAnimationTimer; + std::string styleValidInConfigVar(const std::string&, const std::string&); - float m_fLastTickTime; // in ms + SP 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 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 g_pAnimationManager; +inline std::unique_ptr g_pAnimationManager; -- cgit v1.2.3