diff options
author | vaxerski <[email protected]> | 2022-05-14 16:43:30 +0200 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-05-14 16:43:30 +0200 |
commit | 694f4433a2b6083cef5a4f43e974f9c70b9857af (patch) | |
tree | ece23ce054ccb93a79c538715ed63eeda6c13479 | |
parent | 8f0aa6c941733ac5b540de27909b9b279be61aae (diff) | |
download | Hyprland-694f4433a2b6083cef5a4f43e974f9c70b9857af.tar.gz Hyprland-694f4433a2b6083cef5a4f43e974f9c70b9857af.zip |
Added animation style and style slide
-rw-r--r-- | src/config/ConfigManager.cpp | 9 | ||||
-rw-r--r-- | src/events/Windows.cpp | 3 | ||||
-rw-r--r-- | src/layout/DwindleLayout.cpp | 20 | ||||
-rw-r--r-- | src/layout/IHyprLayout.hpp | 2 | ||||
-rw-r--r-- | src/managers/AnimationManager.cpp | 50 | ||||
-rw-r--r-- | src/managers/AnimationManager.hpp | 3 |
6 files changed, 72 insertions, 15 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index b52b4b96..7635b257 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -48,15 +48,19 @@ void CConfigManager::setDefaultVars() { configValues["animations:enabled"].intValue = 1; configValues["animations:speed"].floatValue = 7.f; configValues["animations:curve"].strValue = "default"; + configValues["animations:windows_style"].strValue = STRVAL_EMPTY; configValues["animations:windows_curve"].strValue = "[[f]]"; configValues["animations:windows_speed"].floatValue = 0.f; configValues["animations:windows"].intValue = 1; + configValues["animations:borders_style"].strValue = STRVAL_EMPTY; configValues["animations:borders_curve"].strValue = "[[f]]"; configValues["animations:borders_speed"].floatValue = 0.f; configValues["animations:borders"].intValue = 1; + configValues["animations:fadein_style"].strValue = STRVAL_EMPTY; configValues["animations:fadein_curve"].strValue = "[[f]]"; configValues["animations:fadein_speed"].floatValue = 0.f; configValues["animations:fadein"].intValue = 1; + configValues["animations:workspaces_style"].strValue = STRVAL_EMPTY; configValues["animations:workspaces_curve"].strValue = "[[f]]"; configValues["animations:workspaces_speed"].floatValue = 0.f; configValues["animations:workspaces"].intValue = 1; @@ -322,6 +326,11 @@ void CConfigManager::handleAnimation(const std::string& command, const std::stri // curve configSetValueSafe("animations:" + ANIMNAME + "_curve", curitem); + + nextItem(); + + // style + configSetValueSafe("animations:" + ANIMNAME + "_style", curitem); } void CConfigManager::handleBind(const std::string& command, const std::string& value) { diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 926d1685..0bbe1629 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -168,6 +168,9 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->hyprListener_setTitleWindow.initCallback(&PWINDOW->m_uSurface.xwayland->events.set_title, &Events::listener_setTitleWindow, PWINDOW, "XWayland Window Late"); } + // do the animation thing + g_pAnimationManager->onWindowPostCreate(PWINDOW); + Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y, PWINDOW->m_vRealSize.goalv().x, PWINDOW->m_vRealSize.goalv().y); } diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index f1d327f0..620143f6 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -278,9 +278,6 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) { applyNodeDataToWindow(PNODE); applyNodeDataToWindow(OPENINGON); } - - pWindow->m_vRealPosition.setValue(PNODE->position + PNODE->size / 2.f); - pWindow->m_vRealSize.setValue(Vector2D(5,5)); } void CHyprDwindleLayout::onWindowRemoved(CWindow* pWindow) { @@ -341,10 +338,6 @@ void CHyprDwindleLayout::onWindowRemoved(CWindow* pWindow) { m_lDwindleNodesData.remove(*PPARENT); m_lDwindleNodesData.remove(*PNODE); - - // jump back like it jumps in - //pWindow->m_vEffectivePosition = pWindow->m_vEffectivePosition + ((pWindow->m_vEffectiveSize - Vector2D(5, 5)) * 0.5f); - // pWindow->m_vEffectiveSize = Vector2D(5, 5); } void CHyprDwindleLayout::recalculateMonitor(const int& monid) { @@ -473,10 +466,10 @@ void CHyprDwindleLayout::onMouseMove(const Vector2D& mousePos) { // get some data about our window const auto PNODE = getNodeFromWindow(DRAGGINGWINDOW); const auto PMONITOR = g_pCompositor->getMonitorFromID(DRAGGINGWINDOW->m_iMonitorID); - const bool DISPLAYLEFT = STICKS(DRAGGINGWINDOW->m_vPosition.x, PMONITOR->vecPosition.x); - const bool DISPLAYRIGHT = STICKS(DRAGGINGWINDOW->m_vPosition.x + DRAGGINGWINDOW->m_vSize.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x); - const bool DISPLAYTOP = STICKS(DRAGGINGWINDOW->m_vPosition.y, PMONITOR->vecPosition.y); - const bool DISPLAYBOTTOM = STICKS(DRAGGINGWINDOW->m_vPosition.y + DRAGGINGWINDOW->m_vSize.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y); + const bool DISPLAYLEFT = STICKS(DRAGGINGWINDOW->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x); + const bool DISPLAYRIGHT = STICKS(DRAGGINGWINDOW->m_vPosition.x + DRAGGINGWINDOW->m_vSize.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x); + const bool DISPLAYTOP = STICKS(DRAGGINGWINDOW->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y); + const bool DISPLAYBOTTOM = STICKS(DRAGGINGWINDOW->m_vPosition.y + DRAGGINGWINDOW->m_vSize.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y); // construct allowed movement Vector2D allowedMovement = TICKDELTA; @@ -578,10 +571,7 @@ void CHyprDwindleLayout::onWindowCreatedFloating(CWindow* pWindow) { } } - if (!pWindow->m_bX11DoesntWantBorders) { - pWindow->m_vRealPosition.setValue(pWindow->m_vRealPosition.goalv() + pWindow->m_vRealSize.goalv() / 2.f); - pWindow->m_vRealSize.setValue(Vector2D(5, 5)); - } else { + if (pWindow->m_bX11DoesntWantBorders) { pWindow->m_vRealPosition.setValue(pWindow->m_vRealPosition.goalv()); pWindow->m_vRealSize.setValue(pWindow->m_vRealSize.goalv()); } diff --git a/src/layout/IHyprLayout.hpp b/src/layout/IHyprLayout.hpp index 6d40ef03..2f569b6e 100644 --- a/src/layout/IHyprLayout.hpp +++ b/src/layout/IHyprLayout.hpp @@ -13,6 +13,8 @@ public: /* Called when a window is created (mapped) + The layout HAS TO set the goal pos and size (anim mgr will use it) + If !animationinprogress, then the anim mgr will not apply an anim. */ virtual void onWindowCreated(CWindow*) = 0; /* diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 639be55e..a881b7d1 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -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)); + } }
\ No newline at end of file diff --git a/src/managers/AnimationManager.hpp b/src/managers/AnimationManager.hpp index ab0d8357..f3343ede 100644 --- a/src/managers/AnimationManager.hpp +++ b/src/managers/AnimationManager.hpp @@ -5,6 +5,7 @@ #include <unordered_map> #include "../helpers/AnimatedVariable.hpp" #include "../helpers/BezierCurve.hpp" +#include "../Window.hpp" class CAnimationManager { public: @@ -15,6 +16,8 @@ public: void addBezierWithName(std::string, const Vector2D&, const Vector2D&); void removeAllBeziers(); + void onWindowPostCreate(CWindow*); + std::list<CAnimatedVariable*> m_lAnimatedVariables; private: |