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/hyprerror/HyprError.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src/hyprerror/HyprError.cpp') diff --git a/src/hyprerror/HyprError.cpp b/src/hyprerror/HyprError.cpp index d3cd8273..5e0dcf5e 100644 --- a/src/hyprerror/HyprError.cpp +++ b/src/hyprerror/HyprError.cpp @@ -3,13 +3,13 @@ #include "../Compositor.hpp" #include "../config/ConfigValue.hpp" #include "../render/pass/TexPassElement.hpp" +#include "../managers/AnimationManager.hpp" #include -using namespace Hyprutils::Utils; +using namespace Hyprutils::Animation; CHyprError::CHyprError() { - m_fFadeOpacity.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), AVARDAMAGE_NONE); - m_fFadeOpacity.registerVar(); + g_pAnimationManager->createAnimation(0.f, m_fFadeOpacity, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), AVARDAMAGE_NONE); static auto P = g_pHookSystem->hookDynamic("focusedMon", [&](void* self, SCallbackInfo& info, std::any param) { if (!m_bIsCreated) @@ -23,16 +23,14 @@ CHyprError::CHyprError() { if (!m_bIsCreated) return; - if (m_fFadeOpacity.isBeingAnimated() || m_bMonitorChanged) + if (m_fFadeOpacity->isBeingAnimated() || m_bMonitorChanged) g_pHyprRenderer->damageBox(&m_bDamageBox); }); m_pTexture = makeShared(); } -CHyprError::~CHyprError() { - m_fFadeOpacity.unregister(); -} +CHyprError::~CHyprError() = default; void CHyprError::queueCreate(std::string message, const CHyprColor& color) { m_szQueued = message; @@ -43,10 +41,10 @@ void CHyprError::createQueued() { if (m_bIsCreated) m_pTexture->destroyTexture(); - m_fFadeOpacity.setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeIn")); + m_fFadeOpacity->setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeIn")); - m_fFadeOpacity.setValueAndWarp(0.f); - m_fFadeOpacity = 1.f; + m_fFadeOpacity->setValueAndWarp(0.f); + *m_fFadeOpacity = 1.f; const auto PMONITOR = g_pCompositor->m_vMonitors.front(); @@ -176,8 +174,8 @@ void CHyprError::draw() { } if (m_bQueuedDestroy) { - if (!m_fFadeOpacity.isBeingAnimated()) { - if (m_fFadeOpacity.value() == 0.f) { + if (!m_fFadeOpacity->isBeingAnimated()) { + if (m_fFadeOpacity->value() == 0.f) { m_bQueuedDestroy = false; m_pTexture->destroyTexture(); m_bIsCreated = false; @@ -189,8 +187,8 @@ void CHyprError::draw() { return; } else { - m_fFadeOpacity.setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeOut")); - m_fFadeOpacity = 0.f; + m_fFadeOpacity->setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeOut")); + *m_fFadeOpacity = 0.f; } } } @@ -202,7 +200,7 @@ void CHyprError::draw() { m_bDamageBox.x = (int)PMONITOR->vecPosition.x; m_bDamageBox.y = (int)PMONITOR->vecPosition.y; - if (m_fFadeOpacity.isBeingAnimated() || m_bMonitorChanged) + if (m_fFadeOpacity->isBeingAnimated() || m_bMonitorChanged) g_pHyprRenderer->damageBox(&m_bDamageBox); m_bMonitorChanged = false; @@ -210,7 +208,7 @@ void CHyprError::draw() { CTexPassElement::SRenderData data; data.tex = m_pTexture; data.box = monbox; - data.a = m_fFadeOpacity.value(); + data.a = m_fFadeOpacity->value(); g_pHyprRenderer->m_sRenderPass.add(makeShared(data)); } -- cgit v1.2.3