mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-07 19:45:59 +01:00
Animation config rework
This commit is contained in:
parent
9dd17a4be6
commit
920fdd6bff
11 changed files with 193 additions and 48 deletions
|
@ -3,12 +3,12 @@
|
||||||
#include "render/decorations/CHyprDropShadowDecoration.hpp"
|
#include "render/decorations/CHyprDropShadowDecoration.hpp"
|
||||||
|
|
||||||
CWindow::CWindow() {
|
CWindow::CWindow() {
|
||||||
m_vRealPosition.create(AVARTYPE_VECTOR, &g_pConfigManager->getConfigValuePtr("animations:windows_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:windows")->intValue, &g_pConfigManager->getConfigValuePtr("animations:windows_curve")->strValue, (void*) this, AVARDAMAGE_ENTIRE);
|
m_vRealPosition.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*) this, AVARDAMAGE_ENTIRE);
|
||||||
m_vRealSize.create(AVARTYPE_VECTOR, &g_pConfigManager->getConfigValuePtr("animations:windows_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:windows")->intValue, &g_pConfigManager->getConfigValuePtr("animations:windows_curve")->strValue, (void*)this, AVARDAMAGE_ENTIRE);
|
m_vRealSize.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*)this, AVARDAMAGE_ENTIRE);
|
||||||
m_cRealBorderColor.create(AVARTYPE_COLOR, &g_pConfigManager->getConfigValuePtr("animations:borders_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:borders")->intValue, &g_pConfigManager->getConfigValuePtr("animations:borders_curve")->strValue, (void*)this, AVARDAMAGE_BORDER);
|
m_cRealBorderColor.create(AVARTYPE_COLOR, g_pConfigManager->getAnimationPropertyConfig("border"), (void*)this, AVARDAMAGE_BORDER);
|
||||||
m_fAlpha.create(AVARTYPE_FLOAT, &g_pConfigManager->getConfigValuePtr("animations:fadein_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:fadein")->intValue, &g_pConfigManager->getConfigValuePtr("animations:fadein_curve")->strValue, (void*)this, AVARDAMAGE_ENTIRE);
|
m_fAlpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), (void*)this, AVARDAMAGE_ENTIRE);
|
||||||
m_fActiveInactiveAlpha.create(AVARTYPE_FLOAT, &g_pConfigManager->getConfigValuePtr("animations:fadein_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:fadein")->intValue, &g_pConfigManager->getConfigValuePtr("animations:fadein_curve")->strValue, (void*)this, AVARDAMAGE_ENTIRE);
|
m_fActiveInactiveAlpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeSwitch"), (void*)this, AVARDAMAGE_ENTIRE);
|
||||||
m_cRealShadowColor.create(AVARTYPE_COLOR, &g_pConfigManager->getConfigValuePtr("animations:borders_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:borders")->intValue, &g_pConfigManager->getConfigValuePtr("animations:borders_curve")->strValue, (void*)this, AVARDAMAGE_SHADOW);
|
m_cRealShadowColor.create(AVARTYPE_COLOR, g_pConfigManager->getAnimationPropertyConfig("fadeShadow"), (void*)this, AVARDAMAGE_SHADOW);
|
||||||
|
|
||||||
m_dWindowDecorations.emplace_back(std::make_unique<CHyprDropShadowDecoration>(this)); // put the shadow so it's the first deco (has to be rendered first)
|
m_dWindowDecorations.emplace_back(std::make_unique<CHyprDropShadowDecoration>(this)); // put the shadow so it's the first deco (has to be rendered first)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
CConfigManager::CConfigManager() {
|
CConfigManager::CConfigManager() {
|
||||||
setDefaultVars();
|
setDefaultVars();
|
||||||
|
setDefaultAnimationVars();
|
||||||
|
|
||||||
std::string CONFIGPATH;
|
std::string CONFIGPATH;
|
||||||
if (g_pCompositor->explicitConfigPath == "") {
|
if (g_pCompositor->explicitConfigPath == "") {
|
||||||
|
@ -161,6 +162,56 @@ void CConfigManager::setDeviceDefaultVars(const std::string& dev) {
|
||||||
cfgValues["drag_lock"].intValue = 0;
|
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() {
|
void CConfigManager::init() {
|
||||||
|
|
||||||
loadConfigLoadVars();
|
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));
|
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) {
|
void CConfigManager::handleAnimation(const std::string& command, const std::string& args) {
|
||||||
std::string curitem = "";
|
std::string curitem = "";
|
||||||
|
|
||||||
|
@ -480,33 +542,44 @@ void CConfigManager::handleAnimation(const std::string& command, const std::stri
|
||||||
|
|
||||||
// anim name
|
// anim name
|
||||||
const auto ANIMNAME = curitem;
|
const auto ANIMNAME = curitem;
|
||||||
const auto ANIMMASTERSETTING = configValues.find("animations:" + ANIMNAME);
|
|
||||||
|
|
||||||
if (ANIMMASTERSETTING == configValues.end()) {
|
const auto PANIM = animationConfig.find(ANIMNAME);
|
||||||
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PANIM->second.overriden = true;
|
||||||
|
PANIM->second.pValues = &PANIM->second;
|
||||||
|
|
||||||
nextItem();
|
nextItem();
|
||||||
|
|
||||||
// on/off
|
// on/off
|
||||||
configSetValueSafe("animations:" + ANIMNAME, curitem);
|
PANIM->second.internalEnabled = curitem == "1";
|
||||||
|
|
||||||
nextItem();
|
nextItem();
|
||||||
|
|
||||||
// Speed
|
// speed
|
||||||
configSetValueSafe("animations:" + ANIMNAME + "_speed", curitem);
|
if (isNumber(curitem, true)) {
|
||||||
|
PANIM->second.internalSpeed = std::stof(curitem);
|
||||||
|
} else {
|
||||||
|
PANIM->second.internalSpeed = 10.f;
|
||||||
|
parseError = "Invalid speed";
|
||||||
|
}
|
||||||
|
|
||||||
nextItem();
|
nextItem();
|
||||||
|
|
||||||
// curve
|
// curve
|
||||||
configSetValueSafe("animations:" + ANIMNAME + "_curve", curitem);
|
PANIM->second.internalBezier = curitem;
|
||||||
|
|
||||||
nextItem();
|
nextItem();
|
||||||
|
|
||||||
// style
|
// 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) {
|
void CConfigManager::handleBind(const std::string& command, const std::string& value) {
|
||||||
|
@ -849,6 +922,7 @@ void CConfigManager::loadConfigLoadVars() {
|
||||||
configDynamicVars.clear();
|
configDynamicVars.clear();
|
||||||
deviceConfigs.clear();
|
deviceConfigs.clear();
|
||||||
m_dBlurLSNamespaces.clear();
|
m_dBlurLSNamespaces.clear();
|
||||||
|
setDefaultAnimationVars(); // reset anims
|
||||||
|
|
||||||
// paths
|
// paths
|
||||||
configPaths.clear();
|
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 STRVAL_EMPTY "[[EMPTY]]"
|
||||||
|
|
||||||
|
#define INITANIMCFG(name) animationConfig[name] = {}
|
||||||
|
#define CREATEANIMCFG(name, parent) animationConfig[name] = {true, "", "", 0.f, -1, &animationConfig["global"], &animationConfig[parent]}
|
||||||
|
|
||||||
struct SConfigValue {
|
struct SConfigValue {
|
||||||
int64_t intValue = -1;
|
int64_t intValue = -1;
|
||||||
float floatValue = -1;
|
float floatValue = -1;
|
||||||
|
@ -47,6 +50,18 @@ struct SWindowRule {
|
||||||
std::string szValue;
|
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 {
|
class CConfigManager {
|
||||||
public:
|
public:
|
||||||
CConfigManager();
|
CConfigManager();
|
||||||
|
@ -84,6 +99,8 @@ public:
|
||||||
|
|
||||||
std::string parseKeyword(const std::string&, const std::string&, bool dynamic = false);
|
std::string parseKeyword(const std::string&, const std::string&, bool dynamic = false);
|
||||||
|
|
||||||
|
SAnimationPropertyConfig* getAnimationPropertyConfig(const std::string&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::deque<std::string> configPaths; // stores all the config paths
|
std::deque<std::string> configPaths; // stores all the config paths
|
||||||
std::unordered_map<std::string, time_t> configModifyTimes; // stores modify times
|
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, SConfigValue> configValues;
|
||||||
std::unordered_map<std::string, std::unordered_map<std::string, SConfigValue>> deviceConfigs; // stores device configs
|
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 configCurrentPath;
|
||||||
|
|
||||||
std::string currentCategory = ""; // For storing the category of the current item
|
std::string currentCategory = ""; // For storing the category of the current item
|
||||||
|
@ -110,9 +129,12 @@ private:
|
||||||
|
|
||||||
// internal methods
|
// internal methods
|
||||||
void setDefaultVars();
|
void setDefaultVars();
|
||||||
|
void setDefaultAnimationVars();
|
||||||
void setDeviceDefaultVars(const std::string&);
|
void setDeviceDefaultVars(const std::string&);
|
||||||
void ensureDPMS();
|
void ensureDPMS();
|
||||||
|
|
||||||
|
void setAnimForChildren(SAnimationPropertyConfig *const);
|
||||||
|
|
||||||
void applyUserDefinedVars(std::string&, const size_t);
|
void applyUserDefinedVars(std::string&, const size_t);
|
||||||
void loadConfigLoadVars();
|
void loadConfigLoadVars();
|
||||||
SConfigValue getConfigValueSafe(const std::string&);
|
SConfigValue getConfigValueSafe(const std::string&);
|
||||||
|
|
|
@ -108,6 +108,9 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
|
||||||
layersurface->layerSurface->mapped = true;
|
layersurface->layerSurface->mapped = true;
|
||||||
layersurface->mapped = true;
|
layersurface->mapped = true;
|
||||||
|
|
||||||
|
// anim
|
||||||
|
layersurface->alpha.setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeIn"));
|
||||||
|
|
||||||
// fix if it changed its mon
|
// fix if it changed its mon
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromOutput(layersurface->layerSurface->output);
|
const auto PMONITOR = g_pCompositor->getMonitorFromOutput(layersurface->layerSurface->output);
|
||||||
|
|
||||||
|
@ -168,6 +171,9 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// anim
|
||||||
|
layersurface->alpha.setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeOut"));
|
||||||
|
|
||||||
// make a snapshot and start fade
|
// make a snapshot and start fade
|
||||||
g_pHyprOpenGL->makeLayerSnapshot(layersurface);
|
g_pHyprOpenGL->makeLayerSnapshot(layersurface);
|
||||||
layersurface->alpha = 0.f;
|
layersurface->alpha = 0.f;
|
||||||
|
|
|
@ -29,6 +29,20 @@ void addViewCoords(void* pWindow, int* x, int* y) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setAnimToMove(void* data) {
|
||||||
|
const auto PWINDOW = (CWindow*)data;
|
||||||
|
|
||||||
|
auto *const PANIMCFG = g_pConfigManager->getAnimationPropertyConfig("windowsMove");
|
||||||
|
|
||||||
|
if (!g_pCompositor->windowValidMapped(PWINDOW))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
PWINDOW->m_vRealPosition.setConfig(PANIMCFG);
|
||||||
|
PWINDOW->m_vRealSize.setConfig(PANIMCFG);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Events::listener_mapWindow(void* owner, void* data) {
|
void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
CWindow* PWINDOW = (CWindow*)owner;
|
CWindow* PWINDOW = (CWindow*)owner;
|
||||||
|
|
||||||
|
@ -44,7 +58,6 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
PWINDOW->m_bReadyToDelete = false;
|
PWINDOW->m_bReadyToDelete = false;
|
||||||
PWINDOW->m_bFadingOut = false;
|
PWINDOW->m_bFadingOut = false;
|
||||||
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
|
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
|
||||||
PWINDOW->m_fAlpha = 255.f;
|
|
||||||
|
|
||||||
if (PWINDOW->m_iX11Type == 2)
|
if (PWINDOW->m_iX11Type == 2)
|
||||||
g_pCompositor->moveUnmanagedX11ToWindows(PWINDOW);
|
g_pCompositor->moveUnmanagedX11ToWindows(PWINDOW);
|
||||||
|
@ -271,6 +284,11 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
|
|
||||||
// do the animation thing
|
// do the animation thing
|
||||||
g_pAnimationManager->onWindowPostCreateClose(PWINDOW, false);
|
g_pAnimationManager->onWindowPostCreateClose(PWINDOW, false);
|
||||||
|
PWINDOW->m_fAlpha.setValueAndWarp(0.f);
|
||||||
|
PWINDOW->m_fAlpha = 255.f;
|
||||||
|
|
||||||
|
const auto TIMER = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, setAnimToMove, PWINDOW);
|
||||||
|
wl_event_source_timer_update(TIMER, PWINDOW->m_vRealPosition.getDurationLeftMs() + 5);
|
||||||
|
|
||||||
if (workspaceSilent) {
|
if (workspaceSilent) {
|
||||||
// move the window
|
// move the window
|
||||||
|
@ -343,8 +361,6 @@ void Events::listener_unmapWindow(void* owner, void* data) {
|
||||||
g_pCompositor->m_pLastFocus = nullptr;
|
g_pCompositor->m_pLastFocus = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
PWINDOW->m_fAlpha = 0.f;
|
|
||||||
|
|
||||||
PWINDOW->m_bMappedX11 = false;
|
PWINDOW->m_bMappedX11 = false;
|
||||||
|
|
||||||
// remove the fullscreen window status from workspace if we closed it
|
// remove the fullscreen window status from workspace if we closed it
|
||||||
|
@ -380,7 +396,10 @@ void Events::listener_unmapWindow(void* owner, void* data) {
|
||||||
|
|
||||||
if (!PWINDOW->m_bX11DoesntWantBorders) // don't animate out if they weren't animated in.
|
if (!PWINDOW->m_bX11DoesntWantBorders) // don't animate out if they weren't animated in.
|
||||||
PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition.vec() + Vector2D(0.01f, 0.01f); // it has to be animated, otherwise onWindowPostCreateClose will ignore it
|
PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition.vec() + Vector2D(0.01f, 0.01f); // it has to be animated, otherwise onWindowPostCreateClose will ignore it
|
||||||
|
|
||||||
|
// anims
|
||||||
g_pAnimationManager->onWindowPostCreateClose(PWINDOW, true);
|
g_pAnimationManager->onWindowPostCreateClose(PWINDOW, true);
|
||||||
|
PWINDOW->m_fAlpha = 0.f;
|
||||||
|
|
||||||
// Destroy Foreign Toplevel
|
// Destroy Foreign Toplevel
|
||||||
wlr_foreign_toplevel_handle_v1_destroy(PWINDOW->m_phForeignToplevel);
|
wlr_foreign_toplevel_handle_v1_destroy(PWINDOW->m_phForeignToplevel);
|
||||||
|
|
|
@ -1,25 +1,24 @@
|
||||||
#include "AnimatedVariable.hpp"
|
#include "AnimatedVariable.hpp"
|
||||||
#include "../managers/AnimationManager.hpp"
|
#include "../managers/AnimationManager.hpp"
|
||||||
|
#include "../config/ConfigManager.hpp"
|
||||||
|
|
||||||
CAnimatedVariable::CAnimatedVariable() {
|
CAnimatedVariable::CAnimatedVariable() {
|
||||||
; // dummy var
|
; // dummy var
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimatedVariable::create(ANIMATEDVARTYPE type, float* speed, int64_t* enabled, std::string* pBezier, void* pWindow, AVARDAMAGEPOLICY policy) {
|
void CAnimatedVariable::create(ANIMATEDVARTYPE type, SAnimationPropertyConfig* pAnimConfig, void* pWindow, AVARDAMAGEPOLICY policy) {
|
||||||
m_eVarType = type;
|
m_eVarType = type;
|
||||||
m_eDamagePolicy = policy;
|
m_eDamagePolicy = policy;
|
||||||
m_pSpeed = speed;
|
m_pConfig = pAnimConfig;
|
||||||
m_pEnabled = enabled;
|
|
||||||
m_pWindow = pWindow;
|
m_pWindow = pWindow;
|
||||||
m_pBezier = pBezier;
|
|
||||||
|
|
||||||
g_pAnimationManager->m_lAnimatedVariables.push_back(this);
|
g_pAnimationManager->m_lAnimatedVariables.push_back(this);
|
||||||
|
|
||||||
m_bDummy = false;
|
m_bDummy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimatedVariable::create(ANIMATEDVARTYPE type, std::any val, float* speed, int64_t* enabled, std::string* pBezier, void* pWindow, AVARDAMAGEPOLICY policy) {
|
void CAnimatedVariable::create(ANIMATEDVARTYPE type, std::any val, SAnimationPropertyConfig* pAnimConfig, void* pWindow, AVARDAMAGEPOLICY policy) {
|
||||||
create(type, speed, enabled, pBezier, pWindow, policy);
|
create(type, pAnimConfig, pWindow, policy);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -58,3 +57,7 @@ CAnimatedVariable::~CAnimatedVariable() {
|
||||||
void CAnimatedVariable::unregister() {
|
void CAnimatedVariable::unregister() {
|
||||||
g_pAnimationManager->m_lAnimatedVariables.remove(this);
|
g_pAnimationManager->m_lAnimatedVariables.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CAnimatedVariable::getDurationLeftMs() {
|
||||||
|
return std::clamp((int)(m_pConfig->pValues->internalSpeed * 100) - (int)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - animationBegin).count(), 0, INT_MAX);
|
||||||
|
}
|
||||||
|
|
|
@ -20,13 +20,14 @@ enum AVARDAMAGEPOLICY {
|
||||||
class CAnimationManager;
|
class CAnimationManager;
|
||||||
class CWorkspace;
|
class CWorkspace;
|
||||||
struct SLayerSurface;
|
struct SLayerSurface;
|
||||||
|
struct SAnimationPropertyConfig;
|
||||||
|
|
||||||
class CAnimatedVariable {
|
class CAnimatedVariable {
|
||||||
public:
|
public:
|
||||||
CAnimatedVariable(); // dummy var
|
CAnimatedVariable(); // dummy var
|
||||||
|
|
||||||
void create(ANIMATEDVARTYPE, float* speed, int64_t* enabled, std::string* pBezier, void* pWindow, AVARDAMAGEPOLICY);
|
void create(ANIMATEDVARTYPE, SAnimationPropertyConfig*, void* pWindow, AVARDAMAGEPOLICY);
|
||||||
void create(ANIMATEDVARTYPE, std::any val, float* speed, int64_t* enabled, std::string* pBezier, void* pWindow, AVARDAMAGEPOLICY);
|
void create(ANIMATEDVARTYPE, std::any val, SAnimationPropertyConfig*, void* pWindow, AVARDAMAGEPOLICY);
|
||||||
|
|
||||||
~CAnimatedVariable();
|
~CAnimatedVariable();
|
||||||
|
|
||||||
|
@ -156,6 +157,16 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setConfig(SAnimationPropertyConfig* pConfig) {
|
||||||
|
m_pConfig = pConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
SAnimationPropertyConfig* getConfig() {
|
||||||
|
return m_pConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getDurationLeftMs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Vector2D m_vValue = Vector2D(0,0);
|
Vector2D m_vValue = Vector2D(0,0);
|
||||||
|
@ -170,15 +181,12 @@ private:
|
||||||
float m_fBegun = 0;
|
float m_fBegun = 0;
|
||||||
CColor m_cBegun;
|
CColor m_cBegun;
|
||||||
|
|
||||||
float* m_pSpeed = nullptr;
|
|
||||||
int64_t* m_pEnabled = nullptr;
|
|
||||||
|
|
||||||
// owners
|
// owners
|
||||||
void* m_pWindow = nullptr;
|
void* m_pWindow = nullptr;
|
||||||
void* m_pWorkspace = nullptr;
|
void* m_pWorkspace = nullptr;
|
||||||
void* m_pLayer = nullptr;
|
void* m_pLayer = nullptr;
|
||||||
|
|
||||||
std::string* m_pBezier = nullptr;
|
SAnimationPropertyConfig* m_pConfig = nullptr;
|
||||||
|
|
||||||
bool m_bDummy = true;
|
bool m_bDummy = true;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
#include "../config/ConfigManager.hpp"
|
#include "../config/ConfigManager.hpp"
|
||||||
|
|
||||||
SLayerSurface::SLayerSurface() {
|
SLayerSurface::SLayerSurface() {
|
||||||
alpha.create(AVARTYPE_FLOAT, &g_pConfigManager->getConfigValuePtr("animations:fadein_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:fadein")->intValue, &g_pConfigManager->getConfigValuePtr("animations:fadein_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE);
|
alpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_ENTIRE);
|
||||||
alpha.m_pLayer = this;
|
alpha.m_pLayer = this;
|
||||||
}
|
}
|
|
@ -26,9 +26,9 @@ CWorkspace::CWorkspace(int monitorID, std::string name, bool special) {
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vRenderOffset.m_pWorkspace = this;
|
m_vRenderOffset.m_pWorkspace = this;
|
||||||
m_vRenderOffset.create(AVARTYPE_VECTOR, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE);
|
m_vRenderOffset.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("workspaces"), nullptr, AVARDAMAGE_ENTIRE);
|
||||||
m_fAlpha.m_pWorkspace = this;
|
m_fAlpha.m_pWorkspace = this;
|
||||||
m_fAlpha.create(AVARTYPE_FLOAT, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE);
|
m_fAlpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("workspaces"), nullptr, AVARDAMAGE_ENTIRE);
|
||||||
m_fAlpha.setValueAndWarp(255.f);
|
m_fAlpha.setValueAndWarp(255.f);
|
||||||
|
|
||||||
g_pEventManager->postEvent({"createworkspace", m_szName}, true);
|
g_pEventManager->postEvent({"createworkspace", m_szName}, true);
|
||||||
|
@ -49,7 +49,7 @@ CWorkspace::~CWorkspace() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorkspace::startAnim(bool in, bool left, bool instant) {
|
void CWorkspace::startAnim(bool in, bool left, bool instant) {
|
||||||
const auto ANIMSTYLE = g_pConfigManager->getString("animations:workspaces_style");
|
const auto ANIMSTYLE = m_fAlpha.m_pConfig->pValues->internalStyle;
|
||||||
|
|
||||||
if (ANIMSTYLE == "fade") {
|
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.
|
||||||
|
|
|
@ -101,6 +101,9 @@ void IHyprLayout::onBeginDragWindow() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DRAGGINGWINDOW->m_vRealPosition.setConfig(g_pConfigManager->getAnimationPropertyConfig("windowsMove"));
|
||||||
|
DRAGGINGWINDOW->m_vRealSize.setConfig(g_pConfigManager->getAnimationPropertyConfig("windowsMove"));
|
||||||
|
|
||||||
DRAGGINGWINDOW->m_bDraggingTiled = false;
|
DRAGGINGWINDOW->m_bDraggingTiled = false;
|
||||||
|
|
||||||
if (!DRAGGINGWINDOW->m_bIsFloating) {
|
if (!DRAGGINGWINDOW->m_bIsFloating) {
|
||||||
|
|
|
@ -28,14 +28,10 @@ void CAnimationManager::tick() {
|
||||||
if (!*PANIMENABLED)
|
if (!*PANIMENABLED)
|
||||||
animationsDisabled = true;
|
animationsDisabled = true;
|
||||||
|
|
||||||
static auto *const PANIMSPEED = &g_pConfigManager->getConfigValuePtr("animations:speed")->floatValue;
|
|
||||||
static auto *const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
static auto *const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||||
static auto *const BEZIERSTR = &g_pConfigManager->getConfigValuePtr("animations:curve")->strValue;
|
|
||||||
static auto *const PSHADOWSENABLED = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
|
static auto *const PSHADOWSENABLED = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
|
||||||
|
|
||||||
auto DEFAULTBEZIER = m_mBezierCurves.find(*BEZIERSTR);
|
const auto DEFAULTBEZIER = m_mBezierCurves.find("default");
|
||||||
if (DEFAULTBEZIER == m_mBezierCurves.end())
|
|
||||||
DEFAULTBEZIER = m_mBezierCurves.find("default");
|
|
||||||
|
|
||||||
for (auto& av : m_lAnimatedVariables) {
|
for (auto& av : m_lAnimatedVariables) {
|
||||||
|
|
||||||
|
@ -49,7 +45,7 @@ void CAnimationManager::tick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get speed
|
// get speed
|
||||||
const auto SPEED = *av->m_pSpeed == 0 ? *PANIMSPEED : *av->m_pSpeed;
|
const auto SPEED = av->m_pConfig->pValues->internalSpeed;
|
||||||
|
|
||||||
// get the spent % (0 - 1)
|
// get the spent % (0 - 1)
|
||||||
const auto DURATIONPASSED = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - av->animationBegin).count();
|
const auto DURATIONPASSED = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - av->animationBegin).count();
|
||||||
|
@ -79,7 +75,7 @@ void CAnimationManager::tick() {
|
||||||
switch (av->m_eVarType) {
|
switch (av->m_eVarType) {
|
||||||
case AVARTYPE_FLOAT: {
|
case AVARTYPE_FLOAT: {
|
||||||
// for disabled anims just warp
|
// for disabled anims just warp
|
||||||
if (*av->m_pEnabled == 0 || animationsDisabled) {
|
if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
|
||||||
av->warp();
|
av->warp();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +86,7 @@ void CAnimationManager::tick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto DELTA = av->m_fGoal - av->m_fBegun;
|
const auto DELTA = av->m_fGoal - av->m_fBegun;
|
||||||
const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier);
|
const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
|
||||||
|
|
||||||
if (BEZIER != m_mBezierCurves.end())
|
if (BEZIER != m_mBezierCurves.end())
|
||||||
av->m_fValue = av->m_fBegun + BEZIER->second.getYForPoint(SPENT) * DELTA;
|
av->m_fValue = av->m_fBegun + BEZIER->second.getYForPoint(SPENT) * DELTA;
|
||||||
|
@ -100,7 +96,7 @@ void CAnimationManager::tick() {
|
||||||
}
|
}
|
||||||
case AVARTYPE_VECTOR: {
|
case AVARTYPE_VECTOR: {
|
||||||
// for disabled anims just warp
|
// for disabled anims just warp
|
||||||
if (*av->m_pEnabled == 0 || animationsDisabled) {
|
if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
|
||||||
av->warp();
|
av->warp();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +107,7 @@ void CAnimationManager::tick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto DELTA = av->m_vGoal - av->m_vBegun;
|
const auto DELTA = av->m_vGoal - av->m_vBegun;
|
||||||
const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier);
|
const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
|
||||||
|
|
||||||
if (BEZIER != m_mBezierCurves.end())
|
if (BEZIER != m_mBezierCurves.end())
|
||||||
av->m_vValue = av->m_vBegun + DELTA * BEZIER->second.getYForPoint(SPENT);
|
av->m_vValue = av->m_vBegun + DELTA * BEZIER->second.getYForPoint(SPENT);
|
||||||
|
@ -121,7 +117,7 @@ void CAnimationManager::tick() {
|
||||||
}
|
}
|
||||||
case AVARTYPE_COLOR: {
|
case AVARTYPE_COLOR: {
|
||||||
// for disabled anims just warp
|
// for disabled anims just warp
|
||||||
if (*av->m_pEnabled == 0 || animationsDisabled) {
|
if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
|
||||||
av->warp();
|
av->warp();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +128,7 @@ void CAnimationManager::tick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto DELTA = av->m_cGoal - av->m_cBegun;
|
const auto DELTA = av->m_cGoal - av->m_cBegun;
|
||||||
const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier);
|
const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
|
||||||
|
|
||||||
if (BEZIER != m_mBezierCurves.end())
|
if (BEZIER != m_mBezierCurves.end())
|
||||||
av->m_cValue = av->m_cBegun + DELTA * BEZIER->second.getYForPoint(SPENT);
|
av->m_cValue = av->m_cBegun + DELTA * BEZIER->second.getYForPoint(SPENT);
|
||||||
|
@ -334,7 +330,17 @@ void CAnimationManager::animationSlide(CWindow* pWindow, std::string force, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
|
void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
|
||||||
auto ANIMSTYLE = g_pConfigManager->getString("animations:windows_style");
|
if (!close) {
|
||||||
|
pWindow->m_vRealPosition.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsIn");
|
||||||
|
pWindow->m_vRealSize.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsIn");
|
||||||
|
pWindow->m_fAlpha.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("fadeIn");
|
||||||
|
} else {
|
||||||
|
pWindow->m_vRealPosition.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsOut");
|
||||||
|
pWindow->m_vRealSize.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsOut");
|
||||||
|
pWindow->m_fAlpha.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("fadeOut");
|
||||||
|
}
|
||||||
|
|
||||||
|
auto ANIMSTYLE = pWindow->m_vRealPosition.m_pConfig->pValues->internalStyle;
|
||||||
transform(ANIMSTYLE.begin(), ANIMSTYLE.end(), ANIMSTYLE.begin(), ::tolower);
|
transform(ANIMSTYLE.begin(), ANIMSTYLE.end(), ANIMSTYLE.begin(), ::tolower);
|
||||||
|
|
||||||
// if the window is not being animated, that means the layout set a fixed size for it, don't animate.
|
// if the window is not being animated, that means the layout set a fixed size for it, don't animate.
|
||||||
|
|
Loading…
Reference in a new issue