diff options
| author | xDarksome <dev@darkso.me> | 2022-07-02 19:43:52 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-02 19:43:52 +0300 |
| commit | 185c4d6ea13ad5f4483aa2e389e43bd09106002f (patch) | |
| tree | a7bc4a9510c39e367317b5ce64d2ee0e0a72d4f0 /src/managers/AnimationManager.cpp | |
| parent | fc4b10d13c14c4eb08febb0637f27177cb6a1940 (diff) | |
| parent | b7b3344188e3ebd2baed14bc288ee42a1ae8d6f2 (diff) | |
Merge branch 'hyprwm:main' into main
Diffstat (limited to 'src/managers/AnimationManager.cpp')
| -rw-r--r-- | src/managers/AnimationManager.cpp | 129 |
1 files changed, 65 insertions, 64 deletions
diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 2ceefdd4..e48b4d1e 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -37,9 +37,18 @@ void CAnimationManager::tick() { DEFAULTBEZIER = m_mBezierCurves.find("default"); for (auto& av : m_lAnimatedVariables) { + + // first of all, check if we need to update it at all + if (!av->isBeingAnimated()) + continue; + // get speed const auto SPEED = *av->m_pSpeed == 0 ? *PANIMSPEED : *av->m_pSpeed; + // get the spent % (0 - 1) + const auto DURATIONPASSED = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - av->animationBegin).count(); + const float SPENT = std::clamp((DURATIONPASSED / 100.f) / SPEED, 0.f, 1.f); + // window stuff const auto PWINDOW = (CWindow*)av->m_pWindow; const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace; @@ -47,7 +56,7 @@ void CAnimationManager::tick() { wlr_box WLRBOXPREV = {0,0,0,0}; if (PWINDOW) { - WLRBOXPREV = {(int)PWINDOW->m_vRealPosition.vec().x - (int)*PBORDERSIZE - 1, (int)PWINDOW->m_vRealPosition.vec().y - (int)*PBORDERSIZE - 1, (int)PWINDOW->m_vRealSize.vec().x + 2 * (int)*PBORDERSIZE + 2, (int)PWINDOW->m_vRealSize.vec().y + 2 * (int)*PBORDERSIZE + 2}; + WLRBOXPREV = PWINDOW->getFullWindowBoundingBox(); } else if (PWORKSPACE) { const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID); WLRBOXPREV = {(int)PMONITOR->vecPosition.x, (int)PMONITOR->vecPosition.y, (int)PMONITOR->vecSize.x, (int)PMONITOR->vecSize.y}; @@ -58,84 +67,68 @@ void CAnimationManager::tick() { // beziers are with a switch unforto // TODO: maybe do something cleaner - // get the spent % (0 - 1) - const auto DURATIONPASSED = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - av->animationBegin).count(); - const float SPENT = std::clamp((DURATIONPASSED / 100.f) / SPEED, 0.f, 1.f); - switch (av->m_eVarType) { case AVARTYPE_FLOAT: { - if (!deltazero(av->m_fValue, av->m_fGoal)) { - - // for disabled anims just warp - if (av->m_pEnabled == 0 || animationsDisabled) { - av->warp(); - break; - } + // for disabled anims just warp + if (*av->m_pEnabled == 0 || animationsDisabled) { + av->warp(); + break; + } - const auto DELTA = av->m_fGoal - av->m_fBegun; - const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); + if (SPENT >= 1.f) { + av->warp(); + break; + } - if (BEZIER != m_mBezierCurves.end()) - av->m_fValue = av->m_fBegun + BEZIER->second.getYForPoint(SPENT) * DELTA; - else - av->m_fValue = av->m_fBegun + DEFAULTBEZIER->second.getYForPoint(SPENT) * DELTA; + const auto DELTA = av->m_fGoal - av->m_fBegun; + const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); - if (SPENT >= 1.f) { - av->warp(); - } - } else { - continue; // dont process - } + if (BEZIER != m_mBezierCurves.end()) + av->m_fValue = av->m_fBegun + BEZIER->second.getYForPoint(SPENT) * DELTA; + else + av->m_fValue = av->m_fBegun + DEFAULTBEZIER->second.getYForPoint(SPENT) * DELTA; break; } case AVARTYPE_VECTOR: { - if (!deltazero(av->m_vValue, av->m_vGoal)) { - - // for disabled anims just warp - if (av->m_pEnabled == 0 || animationsDisabled) { - av->warp(); - break; - } + // for disabled anims just warp + if (*av->m_pEnabled == 0 || animationsDisabled) { + av->warp(); + break; + } - const auto DELTA = av->m_vGoal - av->m_vBegun; - const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); + if (SPENT >= 1.f) { + av->warp(); + break; + } - if (BEZIER != m_mBezierCurves.end()) - av->m_vValue = av->m_vBegun + DELTA * BEZIER->second.getYForPoint(SPENT); - else - av->m_vValue = av->m_vBegun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT); + const auto DELTA = av->m_vGoal - av->m_vBegun; + const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); - if (SPENT >= 1.f) { - av->warp(); - } - } else { - continue; // dont process - } + if (BEZIER != m_mBezierCurves.end()) + av->m_vValue = av->m_vBegun + DELTA * BEZIER->second.getYForPoint(SPENT); + else + av->m_vValue = av->m_vBegun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT); break; } case AVARTYPE_COLOR: { - if (!deltazero(av->m_cValue, av->m_cGoal)) { - - // for disabled anims just warp - if (av->m_pEnabled == 0 || animationsDisabled) { - av->warp(); - break; - } + // for disabled anims just warp + if (*av->m_pEnabled == 0 || animationsDisabled) { + av->warp(); + break; + } - const auto DELTA = av->m_cGoal - av->m_cBegun; - const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); + if (SPENT >= 1.f) { + av->warp(); + break; + } - if (BEZIER != m_mBezierCurves.end()) - av->m_cValue = av->m_cBegun + DELTA * BEZIER->second.getYForPoint(SPENT); - else - av->m_cValue = av->m_cBegun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT); + const auto DELTA = av->m_cGoal - av->m_cBegun; + const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); - if (SPENT >= 1.f) { - av->warp(); - } - } else { - continue; // dont process - } + if (BEZIER != m_mBezierCurves.end()) + av->m_cValue = av->m_cBegun + DELTA * BEZIER->second.getYForPoint(SPENT); + else + av->m_cValue = av->m_cBegun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT); break; } default: { @@ -150,8 +143,16 @@ void CAnimationManager::tick() { if (PWINDOW) { g_pHyprRenderer->damageWindow(PWINDOW); - for (auto& wd : PWINDOW->m_dWindowDecorations) { - wd->updateWindow(PWINDOW); + PWINDOW->updateWindowDecos(); + } else if (PWORKSPACE) { + for (auto& w : g_pCompositor->m_vWindows) { + if (!w->m_bIsMapped || w->m_bHidden) + continue; + + if (w->m_iWorkspaceID != PWORKSPACE->m_iID) + continue; + + w->updateWindowDecos(); } } break; |
