diff options
| author | Maximilian Seidler <78690852+PaideiaDilemma@users.noreply.github.com> | 2025-01-07 17:55:14 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-07 17:55:14 +0000 |
| commit | 5642ed331df56375c55cd8d56a14054af8bdf8f2 (patch) | |
| tree | 74a85b022b3319cdfad01343358eaf09a94841d1 /src/config/ConfigManager.cpp | |
| parent | c7086f936a06abebcc863c35f634760ca1ee90c0 (diff) | |
core: move parts of the animation system to hyprutils (#8868)
* core: change animation manager to use Hyprutils::Animation
* config: move animation config to hyprutils animation tree
* use g_pAnimationManager->createAnimation and the new PHLANIMVAR template
* core: use CGenericAnimatedVariabled::{enabled,setConfig,getStyle} and adapt callbacks
* core: adapt animated variable usage (dereference the shared pointer)
* misc: bump CMakeLists to hyprutils 0.3.3
Diffstat (limited to 'src/config/ConfigManager.cpp')
| -rw-r--r-- | src/config/ConfigManager.cpp | 168 |
1 files changed, 60 insertions, 108 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 927cee9f..1ab29b1f 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -11,6 +11,7 @@ #include "../protocols/LayerShell.hpp" #include "../xwayland/XWayland.hpp" #include "../protocols/OutputManagement.hpp" +#include "managers/AnimationManager.hpp" #include <cstddef> #include <cstdint> @@ -32,6 +33,7 @@ #include <hyprutils/string/String.hpp> #include <filesystem> using namespace Hyprutils::String; +using namespace Hyprutils::Animation; //NOLINTNEXTLINE extern "C" char** environ; @@ -681,7 +683,6 @@ CConfigManager::CConfigManager() { m_pConfig->commence(); - setDefaultAnimationVars(); resetHLConfig(); Debug::log(INFO, @@ -780,76 +781,46 @@ void CConfigManager::reload() { } void CConfigManager::setDefaultAnimationVars() { - if (isFirstLaunch) { - INITANIMCFG("__internal_fadeCTM"); - - INITANIMCFG("global"); - INITANIMCFG("windows"); - INITANIMCFG("layers"); - INITANIMCFG("fade"); - INITANIMCFG("border"); - INITANIMCFG("borderangle"); - - // windows - INITANIMCFG("windowsIn"); - INITANIMCFG("windowsOut"); - INITANIMCFG("windowsMove"); - - // layers - INITANIMCFG("layersIn"); - INITANIMCFG("layersOut"); - - // fade - INITANIMCFG("fadeIn"); - INITANIMCFG("fadeOut"); - INITANIMCFG("fadeSwitch"); - INITANIMCFG("fadeShadow"); - INITANIMCFG("fadeDim"); - - // border - - // workspaces - INITANIMCFG("workspaces"); - INITANIMCFG("workspacesIn"); - INITANIMCFG("workspacesOut"); - INITANIMCFG("specialWorkspace"); - INITANIMCFG("specialWorkspaceIn"); - INITANIMCFG("specialWorkspaceOut"); - } - - // init the values - animationConfig["global"] = {false, "default", "", 8.f, 1, &animationConfig["general"], nullptr}; - - animationConfig["__internal_fadeCTM"] = {false, "linear", "", 5.F, 1, &animationConfig["__internal_fadeCTM"], nullptr}; - - CREATEANIMCFG("windows", "global"); - CREATEANIMCFG("layers", "global"); - CREATEANIMCFG("fade", "global"); - CREATEANIMCFG("border", "global"); - CREATEANIMCFG("borderangle", "global"); - CREATEANIMCFG("workspaces", "global"); - - CREATEANIMCFG("layersIn", "layers"); - CREATEANIMCFG("layersOut", "layers"); - - CREATEANIMCFG("windowsIn", "windows"); - CREATEANIMCFG("windowsOut", "windows"); - CREATEANIMCFG("windowsMove", "windows"); - - CREATEANIMCFG("fadeIn", "fade"); - CREATEANIMCFG("fadeOut", "fade"); - CREATEANIMCFG("fadeSwitch", "fade"); - CREATEANIMCFG("fadeShadow", "fade"); - CREATEANIMCFG("fadeDim", "fade"); - CREATEANIMCFG("fadeLayers", "fade"); - CREATEANIMCFG("fadeLayersIn", "fadeLayers"); - CREATEANIMCFG("fadeLayersOut", "fadeLayers"); - - CREATEANIMCFG("workspacesIn", "workspaces"); - CREATEANIMCFG("workspacesOut", "workspaces"); - CREATEANIMCFG("specialWorkspace", "workspaces"); - CREATEANIMCFG("specialWorkspaceIn", "specialWorkspace"); - CREATEANIMCFG("specialWorkspaceOut", "specialWorkspace"); + m_AnimationTree.createNode("__internal_fadeCTM"); + m_AnimationTree.createNode("global"); + + // global + m_AnimationTree.createNode("windows", "global"); + m_AnimationTree.createNode("layers", "global"); + m_AnimationTree.createNode("fade", "global"); + m_AnimationTree.createNode("border", "global"); + m_AnimationTree.createNode("borderangle", "global"); + m_AnimationTree.createNode("workspaces", "global"); + + // layer + m_AnimationTree.createNode("layersIn", "layers"); + m_AnimationTree.createNode("layersOut", "layers"); + + // windows + m_AnimationTree.createNode("windowsIn", "windows"); + m_AnimationTree.createNode("windowsOut", "windows"); + m_AnimationTree.createNode("windowsMove", "windows"); + + // fade + m_AnimationTree.createNode("fadeIn", "fade"); + m_AnimationTree.createNode("fadeOut", "fade"); + m_AnimationTree.createNode("fadeSwitch", "fade"); + m_AnimationTree.createNode("fadeShadow", "fade"); + m_AnimationTree.createNode("fadeDim", "fade"); + m_AnimationTree.createNode("fadeLayers", "fade"); + m_AnimationTree.createNode("fadeLayersIn", "fadeLayers"); + m_AnimationTree.createNode("fadeLayersOut", "fadeLayers"); + + // workspaces + m_AnimationTree.createNode("workspacesIn", "workspaces"); + m_AnimationTree.createNode("workspacesOut", "workspaces"); + m_AnimationTree.createNode("specialWorkspace", "workspaces"); + m_AnimationTree.createNode("specialWorkspaceIn", "specialWorkspace"); + m_AnimationTree.createNode("specialWorkspaceOut", "specialWorkspace"); + + // init the root nodes + m_AnimationTree.setConfigForNode("global", 1, 8.f, "", "default"); + m_AnimationTree.setConfigForNode("__internal_fadeCTM", 1, 5.f, "", "linear"); } std::optional<std::string> CConfigManager::resetHLConfig() { @@ -857,6 +828,8 @@ std::optional<std::string> CConfigManager::resetHLConfig() { m_vWindowRules.clear(); g_pKeybindManager->clearKeybinds(); g_pAnimationManager->removeAllBeziers(); + g_pAnimationManager->addBezierWithName("linear", Vector2D(0.0, 0.0), Vector2D(1.0, 1.0)); + m_mAdditionalReservedAreas.clear(); m_dBlurLSNamespaces.clear(); m_vWorkspaceRules.clear(); @@ -1647,8 +1620,8 @@ void CConfigManager::ensureVRR(PHLMONITOR pMonitor) { } } -SAnimationPropertyConfig* CConfigManager::getAnimationPropertyConfig(const std::string& name) { - return &animationConfig[name]; +SP<SAnimationPropertyConfig> CConfigManager::getAnimationPropertyConfig(const std::string& name) { + return m_AnimationTree.getConfig(name); } void CConfigManager::addParseError(const std::string& err) { @@ -1711,8 +1684,8 @@ ICustomConfigValueData::~ICustomConfigValueData() { ; // empty } -std::unordered_map<std::string, SAnimationPropertyConfig> CConfigManager::getAnimationConfig() { - return animationConfig; +const std::unordered_map<std::string, SP<SAnimationPropertyConfig>>& CConfigManager::getAnimationConfig() { + return m_AnimationTree.getFullConfig(); } void CConfigManager::addPluginConfigVar(HANDLE handle, const std::string& name, const Hyprlang::CConfigValue& value) { @@ -2058,17 +2031,6 @@ std::optional<std::string> CConfigManager::handleBezier(const std::string& comma return {}; } -void CConfigManager::setAnimForChildren(SAnimationPropertyConfig* const ANIM) { - for (auto& [name, anim] : animationConfig) { - if (anim.pParentAnimation == ANIM && !anim.overridden) { - // if a child isnt overridden, set the values of the parent - anim.pValues = ANIM->pValues; - - setAnimForChildren(&anim); - } - } -}; - std::optional<std::string> CConfigManager::handleAnimation(const std::string& command, const std::string& args) { const auto ARGS = CVarList(args); @@ -2077,14 +2039,9 @@ std::optional<std::string> CConfigManager::handleAnimation(const std::string& co // anim name const auto ANIMNAME = ARGS[0]; - const auto PANIM = animationConfig.find(ANIMNAME); - - if (PANIM == animationConfig.end()) + if (!m_AnimationTree.nodeExists(ANIMNAME)) return "no such animation"; - PANIM->second.overridden = true; - PANIM->second.pValues = &PANIM->second; - // This helper casts strings like "1", "true", "off", "yes"... to int. int64_t enabledInt = configStringToInt(ARGS[1]).value_or(0) == 1; @@ -2092,33 +2049,31 @@ std::optional<std::string> CConfigManager::handleAnimation(const std::string& co if (enabledInt != 0 && enabledInt != 1) return "invalid animation on/off state"; - PANIM->second.internalEnabled = configStringToInt(ARGS[1]).value_or(0) == 1; + if (enabledInt) { + int64_t speed = -1; - if (PANIM->second.internalEnabled) { // speed if (isNumber(ARGS[2], true)) { - PANIM->second.internalSpeed = std::stof(ARGS[2]); + speed = std::stof(ARGS[2]); - if (PANIM->second.internalSpeed <= 0) { - PANIM->second.internalSpeed = 1.f; + if (speed <= 0) { + speed = 1.f; return "invalid speed"; } } else { - PANIM->second.internalSpeed = 10.f; + speed = 10.f; return "invalid speed"; } - // curve - PANIM->second.internalBezier = ARGS[3]; + std::string bezierName = ARGS[3]; + m_AnimationTree.setConfigForNode(ANIMNAME, enabledInt, speed, ARGS[3], ARGS[4]); - if (!g_pAnimationManager->bezierExists(ARGS[3])) { - PANIM->second.internalBezier = "default"; + if (!g_pAnimationManager->bezierExists(bezierName)) { + const auto PANIMNODE = m_AnimationTree.getConfig(ANIMNAME); + PANIMNODE->internalBezier = "default"; return "no such bezier"; } - // style - PANIM->second.internalStyle = ARGS[4]; - if (ARGS[4] != "") { auto ERR = g_pAnimationManager->styleValidInConfigVar(ANIMNAME, ARGS[4]); @@ -2127,9 +2082,6 @@ std::optional<std::string> CConfigManager::handleAnimation(const std::string& co } } - // now, check for children, recursively - setAnimForChildren(&PANIM->second); - return {}; } |
