animation: fix slide/slidevert to accept params (#11574)
This commit is contained in:
parent
4e785d12a9
commit
56dd1124ab
2 changed files with 15 additions and 20 deletions
|
|
@ -300,7 +300,7 @@ std::string CHyprAnimationManager::styleValidInConfigVar(const std::string& conf
|
||||||
} else if (config.starts_with("workspaces") || config.starts_with("specialWorkspace")) {
|
} else if (config.starts_with("workspaces") || config.starts_with("specialWorkspace")) {
|
||||||
if (style == "slide" || style == "slidevert" || style == "fade")
|
if (style == "slide" || style == "slidevert" || style == "fade")
|
||||||
return "";
|
return "";
|
||||||
else if (style.starts_with("slidefade")) {
|
else if (style.starts_with("slide")) {
|
||||||
// try parsing
|
// try parsing
|
||||||
float movePerc = 0.f;
|
float movePerc = 0.f;
|
||||||
if (style.find('%') != std::string::npos) {
|
if (style.find('%') != std::string::npos) {
|
||||||
|
|
|
||||||
|
|
@ -237,9 +237,10 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty
|
||||||
ws->m_alpha->setConfig(g_pConfigManager->getAnimationPropertyConfig(ANIMNAME));
|
ws->m_alpha->setConfig(g_pConfigManager->getAnimationPropertyConfig(ANIMNAME));
|
||||||
ws->m_renderOffset->setConfig(g_pConfigManager->getAnimationPropertyConfig(ANIMNAME));
|
ws->m_renderOffset->setConfig(g_pConfigManager->getAnimationPropertyConfig(ANIMNAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto ANIMSTYLE = ws->m_alpha->getStyle();
|
|
||||||
static auto PWORKSPACEGAP = CConfigValue<Hyprlang::INT>("general:gaps_workspaces");
|
static auto PWORKSPACEGAP = CConfigValue<Hyprlang::INT>("general:gaps_workspaces");
|
||||||
|
const auto PMONITOR = ws->m_monitor.lock();
|
||||||
|
const auto ANIMSTYLE = ws->m_alpha->getStyle();
|
||||||
|
float movePerc = 100.f;
|
||||||
|
|
||||||
// set floating windows offset callbacks
|
// set floating windows offset callbacks
|
||||||
ws->m_renderOffset->setUpdateCallback([weak = PHLWORKSPACEREF{ws}](auto) {
|
ws->m_renderOffset->setUpdateCallback([weak = PHLWORKSPACEREF{ws}](auto) {
|
||||||
|
|
@ -254,16 +255,14 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
if (ANIMSTYLE.starts_with("slidefade")) {
|
if (ANIMSTYLE.find('%') != std::string::npos) {
|
||||||
const auto PMONITOR = ws->m_monitor.lock();
|
try {
|
||||||
float movePerc = 100.f;
|
auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1);
|
||||||
|
movePerc = std::stoi(percstr.substr(0, percstr.length() - 1));
|
||||||
|
} catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); }
|
||||||
|
}
|
||||||
|
|
||||||
if (ANIMSTYLE.find('%') != std::string::npos) {
|
if (ANIMSTYLE.starts_with("slidefade")) {
|
||||||
try {
|
|
||||||
auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1);
|
|
||||||
movePerc = std::stoi(percstr.substr(0, percstr.length() - 1));
|
|
||||||
} catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); }
|
|
||||||
}
|
|
||||||
|
|
||||||
ws->m_alpha->setValueAndWarp(1.f);
|
ws->m_alpha->setValueAndWarp(1.f);
|
||||||
ws->m_renderOffset->setValueAndWarp(Vector2D(0, 0));
|
ws->m_renderOffset->setValueAndWarp(Vector2D(0, 0));
|
||||||
|
|
@ -301,11 +300,8 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty
|
||||||
ws->m_alpha->setValueAndWarp(1.f);
|
ws->m_alpha->setValueAndWarp(1.f);
|
||||||
*ws->m_alpha = 0.f;
|
*ws->m_alpha = 0.f;
|
||||||
}
|
}
|
||||||
} else if (ANIMSTYLE == "slidevert") {
|
} else if (ANIMSTYLE.starts_with("slidevert")) {
|
||||||
// fallback is slide
|
const auto YDISTANCE = (PMONITOR->m_size.y + *PWORKSPACEGAP) * (movePerc / 100.f);
|
||||||
const auto PMONITOR = ws->m_monitor.lock();
|
|
||||||
const auto YDISTANCE = PMONITOR->m_size.y + *PWORKSPACEGAP;
|
|
||||||
|
|
||||||
ws->m_alpha->setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
|
ws->m_alpha->setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
|
||||||
|
|
||||||
if (IN) {
|
if (IN) {
|
||||||
|
|
@ -314,11 +310,10 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty
|
||||||
} else {
|
} else {
|
||||||
*ws->m_renderOffset = Vector2D(0.0, left ? -YDISTANCE : YDISTANCE);
|
*ws->m_renderOffset = Vector2D(0.0, left ? -YDISTANCE : YDISTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// fallback is slide
|
// fallback is slide
|
||||||
const auto PMONITOR = ws->m_monitor.lock();
|
const auto XDISTANCE = (PMONITOR->m_size.x + *PWORKSPACEGAP) * (movePerc / 100.f);
|
||||||
const auto XDISTANCE = PMONITOR->m_size.x + *PWORKSPACEGAP;
|
|
||||||
|
|
||||||
ws->m_alpha->setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
|
ws->m_alpha->setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
|
||||||
|
|
||||||
if (IN) {
|
if (IN) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue