mirror of
https://github.com/hyprwm/hyprlock.git
synced 2025-01-27 12:59:48 +01:00
animations: fix overshoot beziers and cleanup animation config parsing (#642)
This commit is contained in:
parent
de844d39ad
commit
73e23e535f
2 changed files with 26 additions and 29 deletions
|
@ -605,10 +605,9 @@ std::optional<std::string> CConfigManager::handleAnimation(const std::string& co
|
||||||
int64_t enabledInt = configStringToInt(ARGS[1]);
|
int64_t enabledInt = configStringToInt(ARGS[1]);
|
||||||
|
|
||||||
// Checking that the int is 1 or 0 because the helper can return integers out of range.
|
// Checking that the int is 1 or 0 because the helper can return integers out of range.
|
||||||
if (enabledInt != 0 && enabledInt != 1)
|
if (enabledInt > 1 || enabledInt < 0)
|
||||||
return "invalid animation on/off state";
|
return "invalid animation on/off state";
|
||||||
|
|
||||||
if (enabledInt) {
|
|
||||||
int64_t speed = -1;
|
int64_t speed = -1;
|
||||||
|
|
||||||
// speed
|
// speed
|
||||||
|
@ -626,14 +625,13 @@ std::optional<std::string> CConfigManager::handleAnimation(const std::string& co
|
||||||
|
|
||||||
std::string bezierName = ARGS[3];
|
std::string bezierName = ARGS[3];
|
||||||
// ARGS[4] (style) currently usused by hyprlock
|
// ARGS[4] (style) currently usused by hyprlock
|
||||||
m_AnimationTree.setConfigForNode(ANIMNAME, enabledInt, speed, ARGS[3], "");
|
m_AnimationTree.setConfigForNode(ANIMNAME, enabledInt, speed, bezierName, "");
|
||||||
|
|
||||||
if (!g_pAnimationManager->bezierExists(bezierName)) {
|
if (!g_pAnimationManager->bezierExists(bezierName)) {
|
||||||
const auto PANIMNODE = m_AnimationTree.getConfig(ANIMNAME);
|
const auto PANIMNODE = m_AnimationTree.getConfig(ANIMNAME);
|
||||||
PANIMNODE->internalBezier = "default";
|
PANIMNODE->internalBezier = "default";
|
||||||
return "no such bezier";
|
return "no such bezier";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,13 @@
|
||||||
#include "../config/ConfigDataValues.hpp"
|
#include "../config/ConfigDataValues.hpp"
|
||||||
#include "../config/ConfigManager.hpp"
|
#include "../config/ConfigManager.hpp"
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
CHyprlockAnimationManager::CHyprlockAnimationManager() {
|
CHyprlockAnimationManager::CHyprlockAnimationManager() {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <Animable VarType>
|
template <Animable VarType>
|
||||||
void updateVariable(CAnimatedVariable<VarType>& av, const float POINTY, bool warp = false) {
|
void updateVariable(CAnimatedVariable<VarType>& av, const float POINTY, bool warp = false) {
|
||||||
if (POINTY >= 1.f || warp || !av.enabled() || av.value() == av.goal()) {
|
if (warp || !av.enabled() || av.value() == av.goal()) {
|
||||||
av.warp();
|
av.warp();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +19,7 @@ void updateVariable(CAnimatedVariable<VarType>& av, const float POINTY, bool war
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateColorVariable(CAnimatedVariable<CHyprColor>& av, const float POINTY, bool warp = false) {
|
void updateColorVariable(CAnimatedVariable<CHyprColor>& av, const float POINTY, bool warp = false) {
|
||||||
if (POINTY >= 1.f || warp || !av.enabled() || av.value() == av.goal()) {
|
if (warp || !av.enabled() || av.value() == av.goal()) {
|
||||||
av.warp();
|
av.warp();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +43,7 @@ void updateColorVariable(CAnimatedVariable<CHyprColor>& av, const float POINTY,
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateGradientVariable(CAnimatedVariable<CGradientValueData>& av, const float POINTY, bool warp = false) {
|
void updateGradientVariable(CAnimatedVariable<CGradientValueData>& av, const float POINTY, bool warp = false) {
|
||||||
if (POINTY >= 1.f || warp || av.value() == av.goal()) {
|
if (warp || av.value() == av.goal()) {
|
||||||
av.warp();
|
av.warp();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -87,27 +85,28 @@ void CHyprlockAnimationManager::tick() {
|
||||||
const auto SPENT = PAV->getPercent();
|
const auto SPENT = PAV->getPercent();
|
||||||
const auto PBEZIER = getBezier(PAV->getBezierName());
|
const auto PBEZIER = getBezier(PAV->getBezierName());
|
||||||
const auto POINTY = PBEZIER->getYForPoint(SPENT);
|
const auto POINTY = PBEZIER->getYForPoint(SPENT);
|
||||||
|
const bool WARP = !**PANIMATIONSENABLED || SPENT >= 1.f;
|
||||||
|
|
||||||
switch (PAV->m_Type) {
|
switch (PAV->m_Type) {
|
||||||
case AVARTYPE_FLOAT: {
|
case AVARTYPE_FLOAT: {
|
||||||
auto pTypedAV = dynamic_cast<CAnimatedVariable<float>*>(PAV.get());
|
auto pTypedAV = dynamic_cast<CAnimatedVariable<float>*>(PAV.get());
|
||||||
RASSERT(pTypedAV, "Failed to upcast animated float");
|
RASSERT(pTypedAV, "Failed to upcast animated float");
|
||||||
updateVariable(*pTypedAV, POINTY, !**PANIMATIONSENABLED);
|
updateVariable(*pTypedAV, POINTY, WARP);
|
||||||
} break;
|
} break;
|
||||||
case AVARTYPE_VECTOR: {
|
case AVARTYPE_VECTOR: {
|
||||||
auto pTypedAV = dynamic_cast<CAnimatedVariable<Vector2D>*>(PAV.get());
|
auto pTypedAV = dynamic_cast<CAnimatedVariable<Vector2D>*>(PAV.get());
|
||||||
RASSERT(pTypedAV, "Failed to upcast animated Vector2D");
|
RASSERT(pTypedAV, "Failed to upcast animated Vector2D");
|
||||||
updateVariable(*pTypedAV, POINTY, !**PANIMATIONSENABLED);
|
updateVariable(*pTypedAV, POINTY, WARP);
|
||||||
} break;
|
} break;
|
||||||
case AVARTYPE_COLOR: {
|
case AVARTYPE_COLOR: {
|
||||||
auto pTypedAV = dynamic_cast<CAnimatedVariable<CHyprColor>*>(PAV.get());
|
auto pTypedAV = dynamic_cast<CAnimatedVariable<CHyprColor>*>(PAV.get());
|
||||||
RASSERT(pTypedAV, "Failed to upcast animated CHyprColor");
|
RASSERT(pTypedAV, "Failed to upcast animated CHyprColor");
|
||||||
updateColorVariable(*pTypedAV, POINTY, !**PANIMATIONSENABLED);
|
updateColorVariable(*pTypedAV, POINTY, WARP);
|
||||||
} break;
|
} break;
|
||||||
case AVARTYPE_GRADIENT: {
|
case AVARTYPE_GRADIENT: {
|
||||||
auto pTypedAV = dynamic_cast<CAnimatedVariable<CGradientValueData>*>(PAV.get());
|
auto pTypedAV = dynamic_cast<CAnimatedVariable<CGradientValueData>*>(PAV.get());
|
||||||
RASSERT(pTypedAV, "Failed to upcast animated CGradientValueData");
|
RASSERT(pTypedAV, "Failed to upcast animated CGradientValueData");
|
||||||
updateGradientVariable(*pTypedAV, POINTY, !**PANIMATIONSENABLED);
|
updateGradientVariable(*pTypedAV, POINTY, WARP);
|
||||||
} break;
|
} break;
|
||||||
default: continue;
|
default: continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue