mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-27 00:05:58 +01:00
animations: add slidefade and slidefadevert styles for workspaces (#3008)
* add slidefade and slidefadevert animations * fix swiping for slidefadevert * rename minPerc to movePerc for slidefade anim styles * change default slidefade percentage to 100% * remove useless comments * findlastof + 1 * debug logging for slidefade/slidefadevert percentage
This commit is contained in:
parent
7155b4c266
commit
37a211a2ae
3 changed files with 60 additions and 3 deletions
|
@ -58,7 +58,46 @@ CWorkspace::~CWorkspace() {
|
||||||
void CWorkspace::startAnim(bool in, bool left, bool instant) {
|
void CWorkspace::startAnim(bool in, bool left, bool instant) {
|
||||||
const auto ANIMSTYLE = m_fAlpha.m_pConfig->pValues->internalStyle;
|
const auto ANIMSTYLE = m_fAlpha.m_pConfig->pValues->internalStyle;
|
||||||
|
|
||||||
if (ANIMSTYLE == "fade") {
|
if (ANIMSTYLE.find("slidefade") == 0) {
|
||||||
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
|
||||||
|
float movePerc = 100.f;
|
||||||
|
|
||||||
|
if (ANIMSTYLE.find("%") != std::string::npos) {
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_fAlpha.setValueAndWarp(1.f);
|
||||||
|
m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
||||||
|
|
||||||
|
if (ANIMSTYLE.find("slidefadevert") == 0) {
|
||||||
|
if (in) {
|
||||||
|
m_fAlpha.setValueAndWarp(0.f);
|
||||||
|
m_vRenderOffset.setValueAndWarp(Vector2D(0, (left ? PMONITOR->vecSize.y : -PMONITOR->vecSize.y) * (movePerc / 100.f)));
|
||||||
|
m_fAlpha = 1.f;
|
||||||
|
m_vRenderOffset = Vector2D(0, 0);
|
||||||
|
} else {
|
||||||
|
m_fAlpha.setValueAndWarp(1.f);
|
||||||
|
m_fAlpha = 0.f;
|
||||||
|
m_vRenderOffset = Vector2D(0, (left ? -PMONITOR->vecSize.y : PMONITOR->vecSize.y) * (movePerc / 100.f));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (in) {
|
||||||
|
m_fAlpha.setValueAndWarp(0.f);
|
||||||
|
m_vRenderOffset.setValueAndWarp(Vector2D((left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x) * (movePerc / 100.f), 0));
|
||||||
|
m_fAlpha = 1.f;
|
||||||
|
m_vRenderOffset = Vector2D(0, 0);
|
||||||
|
} else {
|
||||||
|
m_fAlpha.setValueAndWarp(1.f);
|
||||||
|
m_fAlpha = 0.f;
|
||||||
|
m_vRenderOffset = Vector2D((left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x) * (movePerc / 100.f), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (ANIMSTYLE == "fade") {
|
||||||
m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); // fix a bug, if switching from slide -> fade.
|
m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); // fix a bug, if switching from slide -> fade.
|
||||||
|
|
||||||
if (in) {
|
if (in) {
|
||||||
|
|
|
@ -485,6 +485,22 @@ std::string CAnimationManager::styleValidInConfigVar(const std::string& config,
|
||||||
} else if (config == "workspaces" || config == "specialWorkspace") {
|
} else if (config == "workspaces" || config == "specialWorkspace") {
|
||||||
if (style == "slide" || style == "slidevert" || style == "fade")
|
if (style == "slide" || style == "slidevert" || style == "fade")
|
||||||
return "";
|
return "";
|
||||||
|
else if (style.find("slidefade") == 0) {
|
||||||
|
// try parsing
|
||||||
|
float movePerc = 0.f;
|
||||||
|
if (style.find("%") != std::string::npos) {
|
||||||
|
try {
|
||||||
|
auto percstr = style.substr(style.find_last_of(' ') + 1);
|
||||||
|
movePerc = std::stoi(percstr.substr(0, percstr.length() - 1));
|
||||||
|
} catch (std::exception& e) { return "invalid movePerc"; }
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
movePerc; // fix warning
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
return "unknown style";
|
return "unknown style";
|
||||||
} else if (config == "borderangle") {
|
} else if (config == "borderangle") {
|
||||||
|
|
|
@ -50,7 +50,8 @@ void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) {
|
||||||
static auto* const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
|
static auto* const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
|
||||||
static auto* const PSWIPENUMBER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_numbered")->intValue;
|
static auto* const PSWIPENUMBER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_numbered")->intValue;
|
||||||
static auto* const PSWIPEUSER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_use_r")->intValue;
|
static auto* const PSWIPEUSER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_use_r")->intValue;
|
||||||
const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert";
|
const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert" ||
|
||||||
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle.find("slidefadevert") == 0;
|
||||||
|
|
||||||
// commit
|
// commit
|
||||||
std::string wsname = "";
|
std::string wsname = "";
|
||||||
|
@ -194,7 +195,8 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
|
||||||
static auto* const PSWIPENUMBER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_numbered")->intValue;
|
static auto* const PSWIPENUMBER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_numbered")->intValue;
|
||||||
static auto* const PSWIPEUSER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_use_r")->intValue;
|
static auto* const PSWIPEUSER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_use_r")->intValue;
|
||||||
|
|
||||||
const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert";
|
const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert" ||
|
||||||
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle.find("slidefadevert") == 0;
|
||||||
|
|
||||||
m_sActiveSwipe.delta += VERTANIMS ? (*PSWIPEINVR ? -e->dy : e->dy) : (*PSWIPEINVR ? -e->dx : e->dx);
|
m_sActiveSwipe.delta += VERTANIMS ? (*PSWIPEINVR ? -e->dy : e->dy) : (*PSWIPEINVR ? -e->dx : e->dx);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue