summaryrefslogtreecommitdiff
path: root/src/managers/AnimationManager.cpp
diff options
context:
space:
mode:
authorNarice <narice@tutanota.com>2022-05-16 11:53:28 +0100
committerGitHub <noreply@github.com>2022-05-16 11:53:28 +0100
commit23c3534197f54e2f74b791ce2a8857b25bbba259 (patch)
treec48e00553bb7027779b19e93a7f631a5f10eee98 /src/managers/AnimationManager.cpp
parent4f10d8e07dd330bf1c4ce9eebecc0db919e522d9 (diff)
parente991550abe8f4b13af586d635cdfec3b5c18fcd9 (diff)
Merge branch 'vaxerski:main' into main
Diffstat (limited to 'src/managers/AnimationManager.cpp')
-rw-r--r--src/managers/AnimationManager.cpp109
1 files changed, 76 insertions, 33 deletions
diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp
index a881b7d1..20302da6 100644
--- a/src/managers/AnimationManager.cpp
+++ b/src/managers/AnimationManager.cpp
@@ -41,12 +41,16 @@ void CAnimationManager::tick() {
// window stuff
const auto PWINDOW = (CWindow*)av->m_pWindow;
const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace;
+ const auto PLAYER = (SLayerSurface*)av->m_pLayer;
+
wlr_box WLRBOXPREV = {0,0,0,0};
if (PWINDOW) {
WLRBOXPREV = {(int)PWINDOW->m_vRealPosition.vec().x - BORDERSIZE - 1, (int)PWINDOW->m_vRealPosition.vec().y - BORDERSIZE - 1, (int)PWINDOW->m_vRealSize.vec().x + 2 * BORDERSIZE + 2, (int)PWINDOW->m_vRealSize.vec().y + 2 * BORDERSIZE + 2};
} 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};
+ } else if (PLAYER) {
+ WLRBOXPREV = PLAYER->geometry;
}
// check if it's disabled, if so, warp
@@ -199,52 +203,91 @@ bool CAnimationManager::deltazero(const CColor& a, const CColor& b) {
return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a;
}
+//
+// Anims
+//
+//
-// animation on events
-void CAnimationManager::onWindowPostCreate(CWindow* pWindow) {
- auto ANIMSTYLE = g_pConfigManager->getString("animations:windows_style");
- transform(ANIMSTYLE.begin(), ANIMSTYLE.end(), ANIMSTYLE.begin(), ::tolower);
+void CAnimationManager::animationPopin(CWindow* pWindow) {
+ const auto GOALPOS = pWindow->m_vRealPosition.goalv();
+ const auto GOALSIZE = pWindow->m_vRealSize.goalv();
- // if the window is not being animated, that means the layout set a fixed size for it, don't animate.
- if (!pWindow->m_vRealPosition.isBeingAnimated() && !pWindow->m_vRealSize.isBeingAnimated())
- return;
+ pWindow->m_vRealPosition.setValue(GOALPOS + GOALSIZE / 2.f);
+ pWindow->m_vRealSize.setValue(Vector2D(5, 5));
+}
+
+void CAnimationManager::animationSlide(CWindow* pWindow, std::string force) {
+ pWindow->m_vRealSize.warp(); // size we preserve in slide
const auto GOALPOS = pWindow->m_vRealPosition.goalv();
const auto GOALSIZE = pWindow->m_vRealSize.goalv();
- if (ANIMSTYLE == "slide") {
- pWindow->m_vRealSize.warp(); // size we preserve in slide
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+
+ if (force != "") {
+ if (force == "bottom") pWindow->m_vRealPosition.setValue(Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y));
+ else if (force == "left") pWindow->m_vRealPosition.setValue(GOALPOS - Vector2D(GOALSIZE.x, 0));
+ else if (force == "right") pWindow->m_vRealPosition.setValue(GOALPOS + Vector2D(GOALSIZE.x, 0));
+ else pWindow->m_vRealPosition.setValue(Vector2D(GOALPOS.x, PMONITOR->vecPosition.y - GOALSIZE.y));
+
+ return;
+ }
- const auto MIDPOINT = GOALPOS + GOALSIZE / 2.f;
+ const auto MIDPOINT = GOALPOS + GOALSIZE / 2.f;
- // check sides it touches
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
- const bool DISPLAYLEFT = STICKS(pWindow->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
- const bool DISPLAYRIGHT = STICKS(pWindow->m_vPosition.x + pWindow->m_vSize.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
- const bool DISPLAYTOP = STICKS(pWindow->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
- const bool DISPLAYBOTTOM = STICKS(pWindow->m_vPosition.y + pWindow->m_vSize.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
+ // check sides it touches
+ const bool DISPLAYLEFT = STICKS(pWindow->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
+ const bool DISPLAYRIGHT = STICKS(pWindow->m_vPosition.x + pWindow->m_vSize.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
+ const bool DISPLAYTOP = STICKS(pWindow->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
+ const bool DISPLAYBOTTOM = STICKS(pWindow->m_vPosition.y + pWindow->m_vSize.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
- if (DISPLAYBOTTOM && DISPLAYTOP) {
- if (DISPLAYLEFT && DISPLAYRIGHT) {
- pWindow->m_vRealPosition.setValue(GOALPOS + Vector2D(0, GOALSIZE.y));
- } else if (DISPLAYLEFT) {
- pWindow->m_vRealPosition.setValue(GOALPOS - Vector2D(GOALSIZE.x, 0));
+ if (DISPLAYBOTTOM && DISPLAYTOP) {
+ if (DISPLAYLEFT && DISPLAYRIGHT) {
+ pWindow->m_vRealPosition.setValue(GOALPOS + Vector2D(0, GOALSIZE.y));
+ } else if (DISPLAYLEFT) {
+ pWindow->m_vRealPosition.setValue(GOALPOS - Vector2D(GOALSIZE.x, 0));
+ } else {
+ pWindow->m_vRealPosition.setValue(GOALPOS + Vector2D(GOALSIZE.x, 0));
+ }
+ } else if (DISPLAYTOP) {
+ pWindow->m_vRealPosition.setValue(GOALPOS - Vector2D(0, GOALSIZE.y));
+ } else if (DISPLAYBOTTOM) {
+ pWindow->m_vRealPosition.setValue(GOALPOS + Vector2D(0, GOALSIZE.y));
+ } else {
+ if (MIDPOINT.y > PMONITOR->vecPosition.y + PMONITOR->vecSize.y / 2.f)
+ pWindow->m_vRealPosition.setValue(Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y));
+ else
+ pWindow->m_vRealPosition.setValue(Vector2D(GOALPOS.x, PMONITOR->vecPosition.y - GOALSIZE.y));
+ }
+}
+
+void CAnimationManager::onWindowPostCreate(CWindow* pWindow) {
+ auto ANIMSTYLE = g_pConfigManager->getString("animations:windows_style");
+ transform(ANIMSTYLE.begin(), ANIMSTYLE.end(), ANIMSTYLE.begin(), ::tolower);
+
+ // if the window is not being animated, that means the layout set a fixed size for it, don't animate.
+ if (!pWindow->m_vRealPosition.isBeingAnimated() && !pWindow->m_vRealSize.isBeingAnimated())
+ return;
+
+ if (pWindow->m_sAdditionalConfigData.animationStyle != "") {
+ // the window has config'd special anim
+ if (pWindow->m_sAdditionalConfigData.animationStyle.find("slide") == 0) {
+ if (pWindow->m_sAdditionalConfigData.animationStyle.find(' ') != std::string::npos) {
+ // has a direction
+ animationSlide(pWindow, pWindow->m_sAdditionalConfigData.animationStyle.substr(pWindow->m_sAdditionalConfigData.animationStyle.find(' ') + 1));
} else {
- pWindow->m_vRealPosition.setValue(GOALPOS + Vector2D(GOALSIZE.x, 0));
+ animationSlide(pWindow);
}
- } else if (DISPLAYTOP) {
- pWindow->m_vRealPosition.setValue(GOALPOS - Vector2D(0, GOALSIZE.y));
- } else if (DISPLAYBOTTOM) {
- pWindow->m_vRealPosition.setValue(GOALPOS + Vector2D(0, GOALSIZE.y));
} else {
- if (MIDPOINT.y > PMONITOR->vecPosition.y + PMONITOR->vecSize.y / 2.f)
- pWindow->m_vRealPosition.setValue(Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y));
- else
- pWindow->m_vRealPosition.setValue(Vector2D(GOALPOS.x, PMONITOR->vecPosition.y - GOALSIZE.y));
+ // anim popin, fallback
+ animationPopin(pWindow);
}
} else {
- // anim popin, fallback
- pWindow->m_vRealPosition.setValue(GOALPOS + GOALSIZE / 2.f);
- pWindow->m_vRealSize.setValue(Vector2D(5, 5));
+ if (ANIMSTYLE == "slide") {
+ animationSlide(pWindow);
+ } else {
+ // anim popin, fallback
+ animationPopin(pWindow);
+ }
}
} \ No newline at end of file