summaryrefslogtreecommitdiff
path: root/src/hyprerror
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/hyprerror
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/hyprerror')
-rw-r--r--src/hyprerror/HyprError.cpp30
-rw-r--r--src/hyprerror/HyprError.hpp22
2 files changed, 25 insertions, 27 deletions
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 <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));
}
diff --git a/src/hyprerror/HyprError.hpp b/src/hyprerror/HyprError.hpp
index 042dccd0..9a662423 100644
--- a/src/hyprerror/HyprError.hpp
+++ b/src/hyprerror/HyprError.hpp
@@ -19,17 +19,17 @@ class CHyprError {
float height(); // logical
private:
- void createQueued();
- std::string m_szQueued = "";
- CHyprColor m_cQueued;
- bool m_bQueuedDestroy = false;
- bool m_bIsCreated = false;
- SP<CTexture> m_pTexture;
- CAnimatedVariable<float> m_fFadeOpacity;
- CBox m_bDamageBox = {0, 0, 0, 0};
- float m_fLastHeight = 0.F;
-
- bool m_bMonitorChanged = false;
+ void createQueued();
+ std::string m_szQueued = "";
+ CHyprColor m_cQueued;
+ bool m_bQueuedDestroy = false;
+ bool m_bIsCreated = false;
+ SP<CTexture> m_pTexture;
+ PHLANIMVAR<float> m_fFadeOpacity;
+ CBox m_bDamageBox = {0, 0, 0, 0};
+ float m_fLastHeight = 0.F;
+
+ bool m_bMonitorChanged = false;
};
inline std::unique_ptr<CHyprError> g_pHyprError; // This is a full-screen error. Treat it with respect, and there can only be one at a time.