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
This commit is contained in:
Maximilian Seidler
2025-01-07 17:55:14 +00:00
committed by GitHub
parent c7086f936a
commit 5642ed331d
44 changed files with 1031 additions and 1664 deletions

View File

@@ -3,13 +3,13 @@
#include "../Compositor.hpp"
#include "../config/ConfigValue.hpp"
#include "../render/pass/TexPassElement.hpp"
#include "../managers/AnimationManager.hpp"
#include <hyprutils/utils/ScopeGuard.hpp>
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<CTexture>();
}
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<CTexPassElement>(data));
}