animationmgr: allow empty avars

This commit is contained in:
vaxerski 2023-05-15 17:11:51 +01:00
parent 621eac32d3
commit 5b84b0fb44
2 changed files with 18 additions and 5 deletions

View file

@ -3,14 +3,16 @@
#include "../defines.hpp" #include "../defines.hpp"
#include <any> #include <any>
enum ANIMATEDVARTYPE { enum ANIMATEDVARTYPE
{
AVARTYPE_INVALID = -1, AVARTYPE_INVALID = -1,
AVARTYPE_FLOAT, AVARTYPE_FLOAT,
AVARTYPE_VECTOR, AVARTYPE_VECTOR,
AVARTYPE_COLOR AVARTYPE_COLOR
}; };
enum AVARDAMAGEPOLICY { enum AVARDAMAGEPOLICY
{
AVARDAMAGE_NONE = -1, AVARDAMAGE_NONE = -1,
AVARDAMAGE_ENTIRE = 0, AVARDAMAGE_ENTIRE = 0,
AVARDAMAGE_BORDER, AVARDAMAGE_BORDER,
@ -209,10 +211,17 @@ class CAnimatedVariable {
m_bRemoveBeginAfterRan = remove; m_bRemoveBeginAfterRan = remove;
} }
/* Sets the update callback, called every time the value is animated and a step is done
Warning: calling unregisterVar/registerVar in this handler will cause UB */
void setUpdateCallback(std::function<void(void* thisptr)> func) {
m_fUpdateCallback = func;
}
/* resets all callbacks. Does not call any. */ /* resets all callbacks. Does not call any. */
void resetAllCallbacks() { void resetAllCallbacks() {
m_fBeginCallback = nullptr; m_fBeginCallback = nullptr;
m_fEndCallback = nullptr; m_fEndCallback = nullptr;
m_fUpdateCallback = nullptr;
m_bRemoveBeginAfterRan = false; m_bRemoveBeginAfterRan = false;
m_bRemoveEndAfterRan = false; m_bRemoveEndAfterRan = false;
} }
@ -249,6 +258,7 @@ class CAnimatedVariable {
bool m_bRemoveBeginAfterRan = true; bool m_bRemoveBeginAfterRan = true;
std::function<void(void* thisptr)> m_fEndCallback; std::function<void(void* thisptr)> m_fEndCallback;
std::function<void(void* thisptr)> m_fBeginCallback; std::function<void(void* thisptr)> m_fBeginCallback;
std::function<void(void* thisptr)> m_fUpdateCallback;
// methods // methods
void onAnimationEnd() { void onAnimationEnd() {

View file

@ -184,6 +184,9 @@ void CAnimationManager::tick() {
if (!VISIBLE) if (!VISIBLE)
continue; continue;
if (av->m_fUpdateCallback)
av->m_fUpdateCallback(av);
switch (av->m_eDamagePolicy) { switch (av->m_eDamagePolicy) {
case AVARDAMAGE_ENTIRE: { case AVARDAMAGE_ENTIRE: {
g_pHyprRenderer->damageBox(&WLRBOXPREV); g_pHyprRenderer->damageBox(&WLRBOXPREV);