summaryrefslogtreecommitdiff
path: root/src/helpers/AnimatedVariable.cpp
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/helpers/AnimatedVariable.cpp
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/helpers/AnimatedVariable.cpp')
-rw-r--r--src/helpers/AnimatedVariable.cpp87
1 files changed, 0 insertions, 87 deletions
diff --git a/src/helpers/AnimatedVariable.cpp b/src/helpers/AnimatedVariable.cpp
deleted file mode 100644
index ab5643a6..00000000
--- a/src/helpers/AnimatedVariable.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "AnimatedVariable.hpp"
-#include "../managers/AnimationManager.hpp"
-#include "../config/ConfigManager.hpp"
-
-CBaseAnimatedVariable::CBaseAnimatedVariable(eAnimatedVarType type) : m_Type(type) {
- ; // dummy var
-}
-
-void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, PHLWINDOW pWindow, eAVarDamagePolicy policy) {
- m_eDamagePolicy = policy;
- m_pConfig = pAnimConfig;
- m_pWindow = pWindow;
-
- m_bDummy = false;
-}
-
-void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, PHLLS pLayer, eAVarDamagePolicy policy) {
- m_eDamagePolicy = policy;
- m_pConfig = pAnimConfig;
- m_pLayer = pLayer;
-
- m_bDummy = false;
-}
-
-void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, PHLWORKSPACE pWorkspace, eAVarDamagePolicy policy) {
- m_eDamagePolicy = policy;
- m_pConfig = pAnimConfig;
- m_pWorkspace = pWorkspace;
-
- m_bDummy = false;
-}
-
-void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, eAVarDamagePolicy policy) {
- m_eDamagePolicy = policy;
- m_pConfig = pAnimConfig;
-
- m_bDummy = false;
-}
-
-CBaseAnimatedVariable::~CBaseAnimatedVariable() {
- unregister();
-}
-
-void CBaseAnimatedVariable::unregister() {
- if (!g_pAnimationManager)
- return;
- std::erase_if(g_pAnimationManager->m_vAnimatedVariables, [&](const auto& other) { return other == this; });
- m_bIsRegistered = false;
- disconnectFromActive();
-}
-
-void CBaseAnimatedVariable::registerVar() {
- if (!m_bIsRegistered)
- g_pAnimationManager->m_vAnimatedVariables.push_back(this);
- m_bIsRegistered = true;
-}
-
-float CBaseAnimatedVariable::getPercent() {
- const auto DURATIONPASSED = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - animationBegin).count();
- return std::clamp((DURATIONPASSED / 100.f) / m_pConfig->pValues->internalSpeed, 0.f, 1.f);
-}
-
-float CBaseAnimatedVariable::getCurveValue() {
- if (!m_bIsBeingAnimated)
- return 1.f;
-
- const auto SPENT = getPercent();
-
- if (SPENT >= 1.f)
- return 1.f;
-
- return g_pAnimationManager->getBezier(m_pConfig->pValues->internalBezier)->getYForPoint(SPENT);
-}
-
-void CBaseAnimatedVariable::connectToActive() {
- g_pAnimationManager->scheduleTick(); // otherwise the animation manager will never pick this up
-
- if (!m_bIsConnectedToActive)
- g_pAnimationManager->m_vActiveAnimatedVariables.push_back(this);
-
- m_bIsConnectedToActive = true;
-}
-
-void CBaseAnimatedVariable::disconnectFromActive() {
- std::erase_if(g_pAnimationManager->m_vActiveAnimatedVariables, [&](const auto& other) { return other == this; });
- m_bIsConnectedToActive = false;
-}