From 3ebe7d79722c1bdc333b236960ff136ab607a02c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 23 Apr 2022 21:47:16 +0200 Subject: Added bezier curves --- src/config/ConfigManager.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'src/config/ConfigManager.cpp') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 49af08b8..e6d0ccd1 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -43,10 +43,14 @@ void CConfigManager::setDefaultVars() { configValues["animations:enabled"].intValue = 1; configValues["animations:speed"].floatValue = 7.f; + configValues["animations:curve"].strValue = "default"; + configValues["animations:windows_curve"].strValue = "[[f]]"; configValues["animations:windows_speed"].floatValue = 0.f; configValues["animations:windows"].intValue = 1; + configValues["animations:borders_curve"].strValue = "[[f]]"; configValues["animations:borders_speed"].floatValue = 0.f; configValues["animations:borders"].intValue = 1; + configValues["animations:fadein_curve"].strValue = "[[f]]"; configValues["animations:fadein_speed"].floatValue = 0.f; configValues["animations:fadein"].intValue = 1; @@ -207,6 +211,39 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string m_dMonitorRules.push_back(newrule); } +void CConfigManager::handleBezier(const std::string& command, const std::string& args) { + std::string curitem = ""; + + std::string argZ = args; + + auto nextItem = [&]() { + auto idx = argZ.find_first_of(','); + + if (idx != std::string::npos) { + curitem = argZ.substr(0, idx); + argZ = argZ.substr(idx + 1); + } else { + curitem = argZ; + argZ = ""; + } + }; + + nextItem(); + + std::string bezierName = curitem; + + nextItem(); + float p1x = std::stof(curitem); + nextItem(); + float p1y = std::stof(curitem); + nextItem(); + float p2x = std::stof(curitem); + nextItem(); + float p2y = std::stof(curitem); + + g_pAnimationManager->addBezierWithName(bezierName, Vector2D(p1x, p1y), Vector2D(p2x, p2y)); +} + void CConfigManager::handleBind(const std::string& command, const std::string& value) { // example: // bind=SUPER,G,exec,dmenu_run @@ -311,6 +348,8 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std:: handleDefaultWorkspace(COMMAND, VALUE); } else if (COMMAND == "windowrule") { handleWindowRule(COMMAND, VALUE); + } else if (COMMAND == "bezier") { + handleBezier(COMMAND, VALUE); } else { configSetValueSafe(currentCategory + (currentCategory == "" ? "" : ":") + COMMAND, VALUE); } @@ -379,10 +418,10 @@ void CConfigManager::loadConfigLoadVars() { // reset all vars before loading setDefaultVars(); - m_dMonitorRules.clear(); m_dWindowRules.clear(); g_pKeybindManager->clearKeybinds(); + g_pAnimationManager->removeAllBeziers(); const char* const ENVHOME = getenv("HOME"); const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf"); -- cgit v1.2.3