mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-09 23:25:57 +01:00
use curves for special dim anim
This commit is contained in:
parent
759490689c
commit
5d095bb9e1
5 changed files with 24 additions and 7 deletions
|
@ -70,3 +70,12 @@ float CAnimatedVariable::getPercent() {
|
||||||
const auto DURATIONPASSED = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - animationBegin).count();
|
const auto DURATIONPASSED = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - animationBegin).count();
|
||||||
return std::clamp((DURATIONPASSED / 100.f) / m_pConfig->pValues->internalSpeed, 0.f, 1.f);
|
return std::clamp((DURATIONPASSED / 100.f) / m_pConfig->pValues->internalSpeed, 0.f, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CAnimatedVariable::getCurveValue() {
|
||||||
|
const auto SPENT = getPercent();
|
||||||
|
|
||||||
|
if (SPENT >= 1.f)
|
||||||
|
return 1.f;
|
||||||
|
|
||||||
|
return g_pAnimationManager->getBezier(m_pConfig->pValues->internalBezier)->getYForPoint(SPENT);
|
||||||
|
}
|
|
@ -3,16 +3,14 @@
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
#include <any>
|
#include <any>
|
||||||
|
|
||||||
enum ANIMATEDVARTYPE
|
enum ANIMATEDVARTYPE {
|
||||||
{
|
|
||||||
AVARTYPE_INVALID = -1,
|
AVARTYPE_INVALID = -1,
|
||||||
AVARTYPE_FLOAT,
|
AVARTYPE_FLOAT,
|
||||||
AVARTYPE_VECTOR,
|
AVARTYPE_VECTOR,
|
||||||
AVARTYPE_COLOR
|
AVARTYPE_COLOR
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AVARDAMAGEPOLICY
|
enum AVARDAMAGEPOLICY {
|
||||||
{
|
|
||||||
AVARDAMAGE_INVALID = -1,
|
AVARDAMAGE_INVALID = -1,
|
||||||
AVARDAMAGE_ENTIRE = 0,
|
AVARDAMAGE_ENTIRE = 0,
|
||||||
AVARDAMAGE_BORDER,
|
AVARDAMAGE_BORDER,
|
||||||
|
@ -190,6 +188,9 @@ class CAnimatedVariable {
|
||||||
/* returns the spent (completion) % */
|
/* returns the spent (completion) % */
|
||||||
float getPercent();
|
float getPercent();
|
||||||
|
|
||||||
|
/* returns the current curve value */
|
||||||
|
float getCurveValue();
|
||||||
|
|
||||||
/* sets a function to be ran when the animation finishes.
|
/* sets a function to be ran when the animation finishes.
|
||||||
if an animation is not running, runs instantly.
|
if an animation is not running, runs instantly.
|
||||||
if "remove" is set to true, will remove the callback when ran. */
|
if "remove" is set to true, will remove the callback when ran. */
|
||||||
|
|
|
@ -458,3 +458,9 @@ std::string CAnimationManager::styleValidInConfigVar(const std::string& config,
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CBezierCurve* CAnimationManager::getBezier(const std::string& name) {
|
||||||
|
const auto BEZIER = std::find_if(m_mBezierCurves.begin(), m_mBezierCurves.end(), [&](const auto& other) { return other.first == name; });
|
||||||
|
|
||||||
|
return BEZIER == m_mBezierCurves.end() ? &m_mBezierCurves["default"] : &BEZIER->second;
|
||||||
|
}
|
|
@ -18,6 +18,7 @@ class CAnimationManager {
|
||||||
void onWindowPostCreateClose(CWindow*, bool close = false);
|
void onWindowPostCreateClose(CWindow*, bool close = false);
|
||||||
|
|
||||||
bool bezierExists(const std::string&);
|
bool bezierExists(const std::string&);
|
||||||
|
CBezierCurve* getBezier(const std::string&);
|
||||||
|
|
||||||
std::string styleValidInConfigVar(const std::string&, const std::string&);
|
std::string styleValidInConfigVar(const std::string&, const std::string&);
|
||||||
|
|
||||||
|
|
|
@ -506,7 +506,7 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
|
||||||
const auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID);
|
const auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID);
|
||||||
|
|
||||||
const auto SPECIALANIMPROGRS =
|
const auto SPECIALANIMPROGRS =
|
||||||
PSPECIALWORKSPACE->m_vRenderOffset.isBeingAnimated() ? PSPECIALWORKSPACE->m_vRenderOffset.getPercent() : PSPECIALWORKSPACE->m_fAlpha.getPercent();
|
PSPECIALWORKSPACE->m_vRenderOffset.isBeingAnimated() ? PSPECIALWORKSPACE->m_vRenderOffset.getCurveValue() : PSPECIALWORKSPACE->m_fAlpha.getCurveValue();
|
||||||
|
|
||||||
const bool ANIMOUT = !PMONITOR->specialWorkspaceID;
|
const bool ANIMOUT = !PMONITOR->specialWorkspaceID;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue