diff options
| author | end-4 <97237370+end-4@users.noreply.github.com> | 2023-08-18 03:30:20 +0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-17 22:30:20 +0200 |
| commit | 37a211a2ae94abad0f606433a58603e70261d0bb (patch) | |
| tree | 7b3ba96fe4257489eb5be38de95832859848dbe5 /src/helpers/Workspace.cpp | |
| parent | 7155b4c26606d7681bacb2517b1d19495336c6c3 (diff) | |
animations: add slidefade and slidefadevert styles for workspaces (#3008)
* add slidefade and slidefadevert animations
* fix swiping for slidefadevert
* rename minPerc to movePerc for slidefade anim styles
* change default slidefade percentage to 100%
* remove useless comments
* findlastof + 1
* debug logging for slidefade/slidefadevert percentage
Diffstat (limited to 'src/helpers/Workspace.cpp')
| -rw-r--r-- | src/helpers/Workspace.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/helpers/Workspace.cpp b/src/helpers/Workspace.cpp index a71dd55d..eddd2143 100644 --- a/src/helpers/Workspace.cpp +++ b/src/helpers/Workspace.cpp @@ -58,7 +58,46 @@ CWorkspace::~CWorkspace() { void CWorkspace::startAnim(bool in, bool left, bool instant) { const auto ANIMSTYLE = m_fAlpha.m_pConfig->pValues->internalStyle; - if (ANIMSTYLE == "fade") { + if (ANIMSTYLE.find("slidefade") == 0) { + const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); + float movePerc = 100.f; + + if (ANIMSTYLE.find("%") != std::string::npos) { + try { + auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1); + movePerc = std::stoi(percstr.substr(0, percstr.length() - 1)); + } catch (std::exception& e) { + Debug::log(ERR, "Error in startAnim: invalid percentage"); + } + } + + m_fAlpha.setValueAndWarp(1.f); + m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); + + if (ANIMSTYLE.find("slidefadevert") == 0) { + if (in) { + m_fAlpha.setValueAndWarp(0.f); + m_vRenderOffset.setValueAndWarp(Vector2D(0, (left ? PMONITOR->vecSize.y : -PMONITOR->vecSize.y) * (movePerc / 100.f))); + m_fAlpha = 1.f; + m_vRenderOffset = Vector2D(0, 0); + } else { + m_fAlpha.setValueAndWarp(1.f); + m_fAlpha = 0.f; + m_vRenderOffset = Vector2D(0, (left ? -PMONITOR->vecSize.y : PMONITOR->vecSize.y) * (movePerc / 100.f)); + } + } else { + if (in) { + m_fAlpha.setValueAndWarp(0.f); + m_vRenderOffset.setValueAndWarp(Vector2D((left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x) * (movePerc / 100.f), 0)); + m_fAlpha = 1.f; + m_vRenderOffset = Vector2D(0, 0); + } else { + m_fAlpha.setValueAndWarp(1.f); + m_fAlpha = 0.f; + m_vRenderOffset = Vector2D((left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x) * (movePerc / 100.f), 0); + } + } + } else if (ANIMSTYLE == "fade") { m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); // fix a bug, if switching from slide -> fade. if (in) { |
