Animation config rework
This commit is contained in:
parent
9dd17a4be6
commit
920fdd6bff
11 changed files with 193 additions and 48 deletions
|
|
@ -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];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
#define STRVAL_EMPTY "[[EMPTY]]"
|
||||
|
||||
#define INITANIMCFG(name) animationConfig[name] = {}
|
||||
#define CREATEANIMCFG(name, parent) animationConfig[name] = {true, "", "", 0.f, -1, &animationConfig["global"], &animationConfig[parent]}
|
||||
|
||||
struct SConfigValue {
|
||||
int64_t intValue = -1;
|
||||
float floatValue = -1;
|
||||
|
|
@ -47,6 +50,18 @@ struct SWindowRule {
|
|||
std::string szValue;
|
||||
};
|
||||
|
||||
struct SAnimationPropertyConfig {
|
||||
bool overriden = true;
|
||||
|
||||
std::string internalBezier = "";
|
||||
std::string internalStyle = "";
|
||||
float internalSpeed = 0.f;
|
||||
int internalEnabled = -1;
|
||||
|
||||
SAnimationPropertyConfig* pValues = nullptr;
|
||||
SAnimationPropertyConfig* pParentAnimation = nullptr;
|
||||
};
|
||||
|
||||
class CConfigManager {
|
||||
public:
|
||||
CConfigManager();
|
||||
|
|
@ -84,6 +99,8 @@ public:
|
|||
|
||||
std::string parseKeyword(const std::string&, const std::string&, bool dynamic = false);
|
||||
|
||||
SAnimationPropertyConfig* getAnimationPropertyConfig(const std::string&);
|
||||
|
||||
private:
|
||||
std::deque<std::string> configPaths; // stores all the config paths
|
||||
std::unordered_map<std::string, time_t> configModifyTimes; // stores modify times
|
||||
|
|
@ -91,6 +108,8 @@ private:
|
|||
std::unordered_map<std::string, SConfigValue> configValues;
|
||||
std::unordered_map<std::string, std::unordered_map<std::string, SConfigValue>> deviceConfigs; // stores device configs
|
||||
|
||||
std::unordered_map<std::string, SAnimationPropertyConfig> animationConfig; // stores all the animations with their set values
|
||||
|
||||
std::string configCurrentPath;
|
||||
|
||||
std::string currentCategory = ""; // For storing the category of the current item
|
||||
|
|
@ -110,9 +129,12 @@ private:
|
|||
|
||||
// internal methods
|
||||
void setDefaultVars();
|
||||
void setDefaultAnimationVars();
|
||||
void setDeviceDefaultVars(const std::string&);
|
||||
void ensureDPMS();
|
||||
|
||||
void setAnimForChildren(SAnimationPropertyConfig *const);
|
||||
|
||||
void applyUserDefinedVars(std::string&, const size_t);
|
||||
void loadConfigLoadVars();
|
||||
SConfigValue getConfigValueSafe(const std::string&);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue