diff options
| author | vaxerski <vaxry@vaxry.net> | 2022-08-06 22:11:08 +0200 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2022-08-06 22:11:08 +0200 |
| commit | 64e80991ca335c4ef7da736bb5582747caca284a (patch) | |
| tree | d8b68be806bc0940b28436133220ec9c8ee437d1 /src/managers/AnimationManager.cpp | |
| parent | 3829b1626e2aea5eb479d29f3014f50b1961a1f7 (diff) | |
added popin anim minimum %
Diffstat (limited to 'src/managers/AnimationManager.cpp')
| -rw-r--r-- | src/managers/AnimationManager.cpp | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 54c4ab30..052daff8 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -262,16 +262,16 @@ bool CAnimationManager::deltazero(const CColor& a, const CColor& b) { // // -void CAnimationManager::animationPopin(CWindow* pWindow, bool close) { +void CAnimationManager::animationPopin(CWindow* pWindow, bool close, float minPerc) { const auto GOALPOS = pWindow->m_vRealPosition.goalv(); const auto GOALSIZE = pWindow->m_vRealSize.goalv(); if (!close) { - pWindow->m_vRealPosition.setValue(GOALPOS + GOALSIZE / 2.f); - pWindow->m_vRealSize.setValue(Vector2D(5, 5)); + pWindow->m_vRealSize.setValue((GOALSIZE * minPerc).clamp({5, 5}, {GOALSIZE.x, GOALSIZE.y})); + pWindow->m_vRealPosition.setValue(GOALPOS + GOALSIZE / 2.f - pWindow->m_vRealSize.m_vValue / 2.f); } else { - pWindow->m_vRealPosition = GOALPOS + GOALSIZE / 2.f; - pWindow->m_vRealSize = Vector2D(5, 5); + pWindow->m_vRealSize = (GOALSIZE * minPerc).clamp({5, 5}, {GOALSIZE.x, GOALSIZE.y}); + pWindow->m_vRealPosition = GOALPOS + GOALSIZE / 2.f - pWindow->m_vRealSize.m_vGoal / 2.f; } } @@ -361,14 +361,36 @@ void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) { } } else { // anim popin, fallback - animationPopin(pWindow, close); + + float minPerc = 0.f; + if (pWindow->m_sAdditionalConfigData.animationStyle.find("%") != 0) { + try { + auto percstr = pWindow->m_sAdditionalConfigData.animationStyle.substr(pWindow->m_sAdditionalConfigData.animationStyle.find_last_of(' ')); + minPerc = std::stoi(percstr.substr(0, percstr.length() - 1)); + } catch (std::exception& e) { + ; // oops + } + } + + animationPopin(pWindow, close, minPerc / 100.f); } } else { if (ANIMSTYLE == "slide") { animationSlide(pWindow, "", close); } else { // anim popin, fallback - animationPopin(pWindow, close); + + float minPerc = 0.f; + if (ANIMSTYLE.find("%") != 0) { + try { + auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ')); + minPerc = std::stoi(percstr.substr(0, percstr.length() - 1)); + } catch (std::exception& e) { + ; // oops + } + } + + animationPopin(pWindow, close, minPerc / 100.f); } } }
\ No newline at end of file |
