diff --git a/src/helpers/AnimatedVariable.cpp b/src/helpers/AnimatedVariable.cpp index f3b1d1e4..5b98e426 100644 --- a/src/helpers/AnimatedVariable.cpp +++ b/src/helpers/AnimatedVariable.cpp @@ -69,4 +69,13 @@ int CAnimatedVariable::getDurationLeftMs() { float CAnimatedVariable::getPercent() { const auto DURATIONPASSED = std::chrono::duration_cast(std::chrono::system_clock::now() - animationBegin).count(); return std::clamp((DURATIONPASSED / 100.f) / m_pConfig->pValues->internalSpeed, 0.f, 1.f); +} + +float CAnimatedVariable::getCurveValue() { + const auto SPENT = getPercent(); + + if (SPENT >= 1.f) + return 1.f; + + return g_pAnimationManager->getBezier(m_pConfig->pValues->internalBezier)->getYForPoint(SPENT); } \ No newline at end of file diff --git a/src/helpers/AnimatedVariable.hpp b/src/helpers/AnimatedVariable.hpp index 6aa33255..b01ca48c 100644 --- a/src/helpers/AnimatedVariable.hpp +++ b/src/helpers/AnimatedVariable.hpp @@ -3,16 +3,14 @@ #include "../defines.hpp" #include -enum ANIMATEDVARTYPE -{ +enum ANIMATEDVARTYPE { AVARTYPE_INVALID = -1, AVARTYPE_FLOAT, AVARTYPE_VECTOR, AVARTYPE_COLOR }; -enum AVARDAMAGEPOLICY -{ +enum AVARDAMAGEPOLICY { AVARDAMAGE_INVALID = -1, AVARDAMAGE_ENTIRE = 0, AVARDAMAGE_BORDER, @@ -190,6 +188,9 @@ class CAnimatedVariable { /* returns the spent (completion) % */ float getPercent(); + /* returns the current curve value */ + float getCurveValue(); + /* sets a function to be ran when the animation finishes. if an animation is not running, runs instantly. if "remove" is set to true, will remove the callback when ran. */ diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index c257622a..cb0f6669 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -201,8 +201,8 @@ void CAnimationManager::tick() { const auto EXTENTS = PDECO->getWindowDecorationExtents(); wlr_box dmg = {PWINDOW->m_vRealPosition.vec().x - EXTENTS.topLeft.x, PWINDOW->m_vRealPosition.vec().y - EXTENTS.topLeft.y, - PWINDOW->m_vRealSize.vec().x + EXTENTS.topLeft.x + EXTENTS.bottomRight.x, - PWINDOW->m_vRealSize.vec().y + EXTENTS.topLeft.y + EXTENTS.bottomRight.y}; + PWINDOW->m_vRealSize.vec().x + EXTENTS.topLeft.x + EXTENTS.bottomRight.x, + PWINDOW->m_vRealSize.vec().y + EXTENTS.topLeft.y + EXTENTS.bottomRight.y}; if (!*PSHADOWIGNOREWINDOW) { // easy, damage the entire box @@ -458,3 +458,9 @@ std::string CAnimationManager::styleValidInConfigVar(const std::string& config, return ""; } + +CBezierCurve* CAnimationManager::getBezier(const std::string& name) { + const auto BEZIER = std::find_if(m_mBezierCurves.begin(), m_mBezierCurves.end(), [&](const auto& other) { return other.first == name; }); + + return BEZIER == m_mBezierCurves.end() ? &m_mBezierCurves["default"] : &BEZIER->second; +} \ No newline at end of file diff --git a/src/managers/AnimationManager.hpp b/src/managers/AnimationManager.hpp index 3a2905b0..d08d3395 100644 --- a/src/managers/AnimationManager.hpp +++ b/src/managers/AnimationManager.hpp @@ -18,6 +18,7 @@ class CAnimationManager { void onWindowPostCreateClose(CWindow*, bool close = false); bool bezierExists(const std::string&); + CBezierCurve* getBezier(const std::string&); std::string styleValidInConfigVar(const std::string&, const std::string&); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index bf2a7f34..2703d40b 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -506,7 +506,7 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) { const auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID); const auto SPECIALANIMPROGRS = - PSPECIALWORKSPACE->m_vRenderOffset.isBeingAnimated() ? PSPECIALWORKSPACE->m_vRenderOffset.getPercent() : PSPECIALWORKSPACE->m_fAlpha.getPercent(); + PSPECIALWORKSPACE->m_vRenderOffset.isBeingAnimated() ? PSPECIALWORKSPACE->m_vRenderOffset.getCurveValue() : PSPECIALWORKSPACE->m_fAlpha.getCurveValue(); const bool ANIMOUT = !PMONITOR->specialWorkspaceID;