diff options
| author | nikitax44 <49244351+nikitax44@users.noreply.github.com> | 2025-09-18 14:53:28 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-18 13:53:28 +0200 |
| commit | 5648077978d73d76312581176700a5df79af71c2 (patch) | |
| tree | a26ac87445a05615606bc6b4fc9ea36f28472ed3 /src/managers | |
| parent | 1cb8cd3930e2c8410bbc99baa0a5bea91994bd71 (diff) | |
animation: fix slide/slidefade to accept forced direction (#11725)
Diffstat (limited to 'src/managers')
| -rw-r--r-- | src/managers/animation/DesktopAnimationManager.cpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/managers/animation/DesktopAnimationManager.cpp b/src/managers/animation/DesktopAnimationManager.cpp index d1ddd8f5..88f0c826 100644 --- a/src/managers/animation/DesktopAnimationManager.cpp +++ b/src/managers/animation/DesktopAnimationManager.cpp @@ -241,6 +241,8 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty const auto PMONITOR = ws->m_monitor.lock(); const auto ANIMSTYLE = ws->m_alpha->getStyle(); float movePerc = 100.f; + // inverted for some reason. TODO: fix the cause + bool vert = ANIMSTYLE.starts_with("slidevert") || ANIMSTYLE.starts_with("slidefadevert"); // set floating windows offset callbacks ws->m_renderOffset->setUpdateCallback([weak = PHLWORKSPACEREF{ws}](auto) { @@ -255,10 +257,28 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty }; }); - if (ANIMSTYLE.find('%') != std::string::npos) { + CVarList args(ANIMSTYLE, 0, 's'); + if (args.size() > 1) { + const auto ARG2 = args[1]; + if (ARG2 == "top") { + left = false; + vert = true; + } else if (ARG2 == "bottom") { + left = true; + vert = true; + } else if (ARG2 == "left") { + left = false; + vert = false; + } else if (ARG2 == "right") { + left = true; + vert = false; + } + } + + const auto percstr = args[args.size() - 1]; + if (percstr.ends_with('%')) { try { - auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1); - movePerc = std::stoi(percstr.substr(0, percstr.length() - 1)); + movePerc = std::stoi(percstr.substr(0, percstr.length() - 1)); } catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); } } @@ -267,7 +287,7 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty ws->m_alpha->setValueAndWarp(1.f); ws->m_renderOffset->setValueAndWarp(Vector2D(0, 0)); - if (ANIMSTYLE.starts_with("slidefadevert")) { + if (vert) { if (IN) { ws->m_alpha->setValueAndWarp(0.f); ws->m_renderOffset->setValueAndWarp(Vector2D(0.0, (left ? PMONITOR->m_size.y : -PMONITOR->m_size.y) * (movePerc / 100.f))); @@ -300,7 +320,7 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty ws->m_alpha->setValueAndWarp(1.f); *ws->m_alpha = 0.f; } - } else if (ANIMSTYLE.starts_with("slidevert")) { + } else if (vert) { const auto YDISTANCE = (PMONITOR->m_size.y + *PWORKSPACEGAP) * (movePerc / 100.f); ws->m_alpha->setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide. |
