Added animation style and style slide

This commit is contained in:
vaxerski
2022-05-14 16:43:30 +02:00
parent 8f0aa6c941
commit 694f4433a2
6 changed files with 72 additions and 15 deletions

View File

@@ -197,4 +197,54 @@ bool CAnimationManager::deltazero(const float& a, const float& b) {
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;
}
// animation on events
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;
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 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);
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));
}
} else {
// anim popin, fallback
pWindow->m_vRealPosition.setValue(GOALPOS + GOALSIZE / 2.f);
pWindow->m_vRealSize.setValue(Vector2D(5, 5));
}
}