mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-08 22:46:01 +01:00
add more errors
This commit is contained in:
parent
1744be7bdd
commit
3a8dcf284a
3 changed files with 69 additions and 1 deletions
|
@ -573,14 +573,23 @@ void CConfigManager::handleAnimation(const std::string& command, const std::stri
|
||||||
// on/off
|
// on/off
|
||||||
PANIM->second.internalEnabled = curitem == "1";
|
PANIM->second.internalEnabled = curitem == "1";
|
||||||
|
|
||||||
|
if (curitem != "0" && curitem != "1") {
|
||||||
|
parseError = "invalid animation on/off state";
|
||||||
|
}
|
||||||
|
|
||||||
nextItem();
|
nextItem();
|
||||||
|
|
||||||
// speed
|
// speed
|
||||||
if (isNumber(curitem, true)) {
|
if (isNumber(curitem, true)) {
|
||||||
PANIM->second.internalSpeed = std::stof(curitem);
|
PANIM->second.internalSpeed = std::stof(curitem);
|
||||||
|
|
||||||
|
if (PANIM->second.internalSpeed <= 0) {
|
||||||
|
parseError = "invalid speed";
|
||||||
|
PANIM->second.internalSpeed = 1.f;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
PANIM->second.internalSpeed = 10.f;
|
PANIM->second.internalSpeed = 10.f;
|
||||||
parseError = "Invalid speed";
|
parseError = "invalid speed";
|
||||||
}
|
}
|
||||||
|
|
||||||
nextItem();
|
nextItem();
|
||||||
|
@ -588,11 +597,23 @@ void CConfigManager::handleAnimation(const std::string& command, const std::stri
|
||||||
// curve
|
// curve
|
||||||
PANIM->second.internalBezier = curitem;
|
PANIM->second.internalBezier = curitem;
|
||||||
|
|
||||||
|
if (!g_pAnimationManager->bezierExists(curitem)) {
|
||||||
|
parseError = "no such bezier";
|
||||||
|
PANIM->second.internalBezier = "default";
|
||||||
|
}
|
||||||
|
|
||||||
nextItem();
|
nextItem();
|
||||||
|
|
||||||
// style
|
// style
|
||||||
PANIM->second.internalStyle = curitem;
|
PANIM->second.internalStyle = curitem;
|
||||||
|
|
||||||
|
if (curitem != "") {
|
||||||
|
const auto ERR = g_pAnimationManager->styleValidInConfigVar(ANIMNAME, curitem);
|
||||||
|
|
||||||
|
if (ERR != "")
|
||||||
|
parseError = ERR;
|
||||||
|
}
|
||||||
|
|
||||||
// now, check for children, recursively
|
// now, check for children, recursively
|
||||||
setAnimForChildren(&PANIM->second);
|
setAnimForChildren(&PANIM->second);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
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
|
// Anims
|
||||||
//
|
//
|
||||||
|
@ -394,3 +403,37 @@ void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 "";
|
||||||
|
}
|
|
@ -18,6 +18,10 @@ public:
|
||||||
|
|
||||||
void onWindowPostCreateClose(CWindow*, bool close = false);
|
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;
|
std::list<CAnimatedVariable*> m_lAnimatedVariables;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue