summaryrefslogtreecommitdiff
path: root/src/config/ConfigManager.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-07-28 13:28:43 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-07-28 13:28:43 +0200
commit920fdd6bff0f78d6f7f5de6167a23af303e00e57 (patch)
treeff28eaba4ee9c6647e0a3b8ac1fab1cb8e14fbf3 /src/config/ConfigManager.cpp
parent9dd17a4be6a719ab0cc501f63cf07cfd066f3ef8 (diff)
Animation config rework
Diffstat (limited to 'src/config/ConfigManager.cpp')
-rw-r--r--src/config/ConfigManager.cpp96
1 files changed, 87 insertions, 9 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index ed4511c6..3b5fce8f 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -12,6 +12,7 @@
CConfigManager::CConfigManager() {
setDefaultVars();
+ setDefaultAnimationVars();
std::string CONFIGPATH;
if (g_pCompositor->explicitConfigPath == "") {
@@ -161,6 +162,56 @@ void CConfigManager::setDeviceDefaultVars(const std::string& dev) {
cfgValues["drag_lock"].intValue = 0;
}
+void CConfigManager::setDefaultAnimationVars() {
+ if (isFirstLaunch) {
+ INITANIMCFG("global");
+ INITANIMCFG("windows");
+ INITANIMCFG("fade");
+ INITANIMCFG("border");
+ INITANIMCFG("workspaces");
+
+ // windows
+ INITANIMCFG("windowsIn");
+ INITANIMCFG("windowsOut");
+ INITANIMCFG("windowsMove");
+
+ // fade
+ INITANIMCFG("fadeIn");
+ INITANIMCFG("fadeOut");
+ INITANIMCFG("fadeSwitch");
+ INITANIMCFG("fadeShadow");
+
+ // border
+
+ // workspaces
+ }
+
+ // init the values
+ animationConfig["global"] = {
+ false,
+ "default",
+ "",
+ 8.f,
+ 1,
+ &animationConfig["general"],
+ nullptr
+ };
+
+ CREATEANIMCFG("windows", "global");
+ CREATEANIMCFG("fade", "global");
+ CREATEANIMCFG("border", "global");
+ CREATEANIMCFG("workspaces", "global");
+
+ CREATEANIMCFG("windowsIn", "windows");
+ CREATEANIMCFG("windowsOut", "windows");
+ CREATEANIMCFG("windowsMove", "windows");
+
+ CREATEANIMCFG("fadeIn", "fade");
+ CREATEANIMCFG("fadeOut", "fade");
+ CREATEANIMCFG("fadeSwitch", "fade");
+ CREATEANIMCFG("fadeShadow", "fade");
+}
+
void CConfigManager::init() {
loadConfigLoadVars();
@@ -457,6 +508,17 @@ void CConfigManager::handleBezier(const std::string& command, const std::string&
g_pAnimationManager->addBezierWithName(bezierName, Vector2D(p1x, p1y), Vector2D(p2x, p2y));
}
+void CConfigManager::setAnimForChildren(SAnimationPropertyConfig *const ANIM) {
+ for (auto& [name, anim] : animationConfig) {
+ if (anim.pParentAnimation == ANIM && !anim.overriden) {
+ // if a child isnt overriden, set the values of the parent
+ anim.pValues = ANIM->pValues;
+
+ setAnimForChildren(&anim);
+ }
+ }
+};
+
void CConfigManager::handleAnimation(const std::string& command, const std::string& args) {
std::string curitem = "";
@@ -480,33 +542,44 @@ void CConfigManager::handleAnimation(const std::string& command, const std::stri
// anim name
const auto ANIMNAME = curitem;
- const auto ANIMMASTERSETTING = configValues.find("animations:" + ANIMNAME);
+
+ const auto PANIM = animationConfig.find(ANIMNAME);
- if (ANIMMASTERSETTING == configValues.end()) {
- Debug::log(ERR, "Anim %s doesnt exist", ANIMNAME.c_str());
- parseError = "Animation " + ANIMNAME + " does not exist";
+ if (PANIM == animationConfig.end()) {
+ parseError = "no such animation";
return;
}
+ PANIM->second.overriden = true;
+ PANIM->second.pValues = &PANIM->second;
+
nextItem();
// on/off
- configSetValueSafe("animations:" + ANIMNAME, curitem);
+ PANIM->second.internalEnabled = curitem == "1";
nextItem();
- // Speed
- configSetValueSafe("animations:" + ANIMNAME + "_speed", curitem);
+ // speed
+ if (isNumber(curitem, true)) {
+ PANIM->second.internalSpeed = std::stof(curitem);
+ } else {
+ PANIM->second.internalSpeed = 10.f;
+ parseError = "Invalid speed";
+ }
nextItem();
// curve
- configSetValueSafe("animations:" + ANIMNAME + "_curve", curitem);
+ PANIM->second.internalBezier = curitem;
nextItem();
// style
- configSetValueSafe("animations:" + ANIMNAME + "_style", curitem);
+ PANIM->second.internalStyle = curitem;
+
+ // now, check for children, recursively
+ setAnimForChildren(&PANIM->second);
}
void CConfigManager::handleBind(const std::string& command, const std::string& value) {
@@ -849,6 +922,7 @@ void CConfigManager::loadConfigLoadVars() {
configDynamicVars.clear();
deviceConfigs.clear();
m_dBlurLSNamespaces.clear();
+ setDefaultAnimationVars(); // reset anims
// paths
configPaths.clear();
@@ -1226,3 +1300,7 @@ void CConfigManager::ensureDPMS() {
}
}
}
+
+SAnimationPropertyConfig* CConfigManager::getAnimationPropertyConfig(const std::string& name) {
+ return &animationConfig[name];
+}