summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2022-08-07 19:28:46 +0200
committervaxerski <vaxry@vaxry.net>2022-08-07 19:28:46 +0200
commit3a8dcf284aa3953585e3f700afa1095903c3a65f (patch)
tree9a80dd5058ae27457abf43c080cf4d0ab6d98695 /src
parent1744be7bdd942e0cbd5ad1b1d4426b0b9023208a (diff)
add more errors
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigManager.cpp23
-rw-r--r--src/managers/AnimationManager.cpp43
-rw-r--r--src/managers/AnimationManager.hpp4
3 files changed, 69 insertions, 1 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 3889177a..5c592e36 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -573,14 +573,23 @@ void CConfigManager::handleAnimation(const std::string& command, const std::stri
// on/off
PANIM->second.internalEnabled = curitem == "1";
+ if (curitem != "0" && curitem != "1") {
+ parseError = "invalid animation on/off state";
+ }
+
nextItem();
// speed
if (isNumber(curitem, true)) {
PANIM->second.internalSpeed = std::stof(curitem);
+
+ if (PANIM->second.internalSpeed <= 0) {
+ parseError = "invalid speed";
+ PANIM->second.internalSpeed = 1.f;
+ }
} else {
PANIM->second.internalSpeed = 10.f;
- parseError = "Invalid speed";
+ parseError = "invalid speed";
}
nextItem();
@@ -588,11 +597,23 @@ void CConfigManager::handleAnimation(const std::string& command, const std::stri
// curve
PANIM->second.internalBezier = curitem;
+ if (!g_pAnimationManager->bezierExists(curitem)) {
+ parseError = "no such bezier";
+ PANIM->second.internalBezier = "default";
+ }
+
nextItem();
// style
PANIM->second.internalStyle = curitem;
+ if (curitem != "") {
+ const auto ERR = g_pAnimationManager->styleValidInConfigVar(ANIMNAME, curitem);
+
+ if (ERR != "")
+ parseError = ERR;
+ }
+
// now, check for children, recursively
setAnimForChildren(&PANIM->second);
}
diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp
index 052daff8..640b462c 100644
--- a/src/managers/AnimationManager.cpp
+++ b/src/managers/AnimationManager.cpp
@@ -257,6 +257,15 @@ 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;
}
+bool CAnimationManager::bezierExists(const std::string& bezier) {
+ for (auto&[bc, bz] : m_mBezierCurves) {
+ if (bc == bezier)
+ return true;
+ }
+
+ return false;
+}
+
//
// Anims
//
@@ -393,4 +402,38 @@ void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
animationPopin(pWindow, close, minPerc / 100.f);
}
}
+}
+
+std::string CAnimationManager::styleValidInConfigVar(const std::string& config, const std::string& style) {
+ if (config.find("window") == 0) {
+ if (style == "slide") {
+ return "";
+ } else if (style.find("popin") == 0) {
+ // try parsing
+ float minPerc = 0.f;
+ if (style.find("%") != 0) {
+ try {
+ auto percstr = style.substr(style.find_last_of(' '));
+ minPerc = std::stoi(percstr.substr(0, percstr.length() - 1));
+ } catch (std::exception& e) {
+ return "invalid minperc";
+ }
+
+ return "";
+ }
+
+ return "";
+ }
+
+ return "unknown style";
+ } else if (config == "workspaces") {
+ if (style == "slide" || style == "slidevert" || style == "fade")
+ return "";
+
+ return "unknown style";
+ } else {
+ return "animation has no styles";
+ }
+
+ return "";
} \ No newline at end of file
diff --git a/src/managers/AnimationManager.hpp b/src/managers/AnimationManager.hpp
index 9b422da7..b3148d25 100644
--- a/src/managers/AnimationManager.hpp
+++ b/src/managers/AnimationManager.hpp
@@ -18,6 +18,10 @@ public:
void onWindowPostCreateClose(CWindow*, bool close = false);
+ bool bezierExists(const std::string&);
+
+ std::string styleValidInConfigVar(const std::string&, const std::string&);
+
std::list<CAnimatedVariable*> m_lAnimatedVariables;
private: