Added workspace animations

This commit is contained in:
vaxerski 2022-05-12 11:27:31 +02:00
parent 07e208aa73
commit ff0f535c28
11 changed files with 86 additions and 16 deletions

View file

@ -52,5 +52,9 @@ void CAnimatedVariable::create(ANIMATEDVARTYPE type, std::any val, float* speed,
}
CAnimatedVariable::~CAnimatedVariable() {
unregister();
}
void CAnimatedVariable::unregister() {
g_pAnimationManager->m_lAnimatedVariables.remove(this);
}

View file

@ -17,6 +17,7 @@ enum AVARDAMAGEPOLICY {
};
class CAnimationManager;
class CWorkspace;
class CAnimatedVariable {
public:
@ -27,6 +28,8 @@ public:
~CAnimatedVariable();
void unregister();
// gets the current vector value (real time)
const Vector2D& vec() const {
RASSERT(m_eVarType == AVARTYPE_VECTOR, "Tried to access vec() of AVARTYPE %i!", m_eVarType);
@ -129,6 +132,22 @@ public:
warp();
}
// checks if an animation is in progress
bool isBeingAnimated() {
switch (m_eVarType) {
case AVARTYPE_FLOAT:
return m_fValue != m_fGoal;
case AVARTYPE_VECTOR:
return m_vValue != m_vGoal;
case AVARTYPE_COLOR:
return m_cValue != m_cGoal;
default:
return false;
}
return false; // unreachable
}
private:
void warp() {
@ -165,6 +184,7 @@ private:
float* m_pSpeed = nullptr;
int64_t* m_pEnabled = nullptr;
void* m_pWindow = nullptr;
void* m_pWorkspace = nullptr;
std::string* m_pBezier = nullptr;
bool m_bDummy = true;
@ -175,4 +195,5 @@ private:
AVARDAMAGEPOLICY m_eDamagePolicy = AVARDAMAGE_INVALID;
friend class CAnimationManager;
friend class CWorkspace;
};

View file

@ -24,4 +24,7 @@ public:
return CColor(r * v, g * v, b * v, a * v);
}
bool operator==(const CColor& c2) const {
return r == c2.r && g == c2.g && b == c2.b && a == c2.a;
}
};

View file

@ -20,9 +20,14 @@ CWorkspace::CWorkspace(int monitorID) {
wlr_ext_workspace_handle_v1_set_coordinates(m_pWlrHandle, &m_wlrCoordinateArr);
wlr_ext_workspace_handle_v1_set_hidden(m_pWlrHandle, false);
wlr_ext_workspace_handle_v1_set_urgent(m_pWlrHandle, false);
m_vRenderOffset.m_pWorkspace = this;
m_vRenderOffset.create(AVARTYPE_VECTOR, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE);
}
CWorkspace::~CWorkspace() {
m_vRenderOffset.unregister();
if (m_pWlrHandle) {
wlr_ext_workspace_handle_v1_set_active(m_pWlrHandle, false);
wlr_ext_workspace_handle_v1_destroy(m_pWlrHandle);

View file

@ -1,6 +1,7 @@
#pragma once
#include "../defines.hpp"
#include "AnimatedVariable.hpp"
class CWorkspace {
public:
@ -17,4 +18,7 @@ public:
wlr_ext_workspace_handle_v1* m_pWlrHandle = nullptr;
wl_array m_wlrCoordinateArr;
// for animations
CAnimatedVariable m_vRenderOffset;
};