mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 08:05:59 +01:00
animatedvariable: don't reset timers on duplicate setters
Fixes the annoying jump when a recalc happens while a window is being animated
This commit is contained in:
parent
8fefb180b1
commit
35df4693ea
1 changed files with 25 additions and 5 deletions
|
@ -7,14 +7,16 @@
|
||||||
#include "Color.hpp"
|
#include "Color.hpp"
|
||||||
#include "../macros.hpp"
|
#include "../macros.hpp"
|
||||||
|
|
||||||
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_NONE = -1,
|
AVARDAMAGE_NONE = -1,
|
||||||
AVARDAMAGE_ENTIRE = 0,
|
AVARDAMAGE_ENTIRE = 0,
|
||||||
AVARDAMAGE_BORDER,
|
AVARDAMAGE_BORDER,
|
||||||
|
@ -75,6 +77,9 @@ class CAnimatedVariable {
|
||||||
}
|
}
|
||||||
|
|
||||||
CAnimatedVariable& operator=(const Vector2D& v) {
|
CAnimatedVariable& operator=(const Vector2D& v) {
|
||||||
|
if (v == m_vGoal)
|
||||||
|
return *this;
|
||||||
|
|
||||||
m_vGoal = v;
|
m_vGoal = v;
|
||||||
animationBegin = std::chrono::system_clock::now();
|
animationBegin = std::chrono::system_clock::now();
|
||||||
m_vBegun = m_vValue;
|
m_vBegun = m_vValue;
|
||||||
|
@ -85,6 +90,9 @@ class CAnimatedVariable {
|
||||||
}
|
}
|
||||||
|
|
||||||
CAnimatedVariable& operator=(const float& v) {
|
CAnimatedVariable& operator=(const float& v) {
|
||||||
|
if (v == m_fGoal)
|
||||||
|
return *this;
|
||||||
|
|
||||||
m_fGoal = v;
|
m_fGoal = v;
|
||||||
animationBegin = std::chrono::system_clock::now();
|
animationBegin = std::chrono::system_clock::now();
|
||||||
m_fBegun = m_fValue;
|
m_fBegun = m_fValue;
|
||||||
|
@ -95,6 +103,9 @@ class CAnimatedVariable {
|
||||||
}
|
}
|
||||||
|
|
||||||
CAnimatedVariable& operator=(const CColor& v) {
|
CAnimatedVariable& operator=(const CColor& v) {
|
||||||
|
if (v == m_cGoal)
|
||||||
|
return *this;
|
||||||
|
|
||||||
m_cGoal = v;
|
m_cGoal = v;
|
||||||
animationBegin = std::chrono::system_clock::now();
|
animationBegin = std::chrono::system_clock::now();
|
||||||
m_cBegun = m_cValue;
|
m_cBegun = m_cValue;
|
||||||
|
@ -106,6 +117,9 @@ class CAnimatedVariable {
|
||||||
|
|
||||||
// Sets the actual stored value, without affecting the goal, but resets the timer
|
// Sets the actual stored value, without affecting the goal, but resets the timer
|
||||||
void setValue(const Vector2D& v) {
|
void setValue(const Vector2D& v) {
|
||||||
|
if (v == m_vValue)
|
||||||
|
return;
|
||||||
|
|
||||||
m_vValue = v;
|
m_vValue = v;
|
||||||
animationBegin = std::chrono::system_clock::now();
|
animationBegin = std::chrono::system_clock::now();
|
||||||
m_vBegun = m_vValue;
|
m_vBegun = m_vValue;
|
||||||
|
@ -115,6 +129,9 @@ class CAnimatedVariable {
|
||||||
|
|
||||||
// Sets the actual stored value, without affecting the goal, but resets the timer
|
// Sets the actual stored value, without affecting the goal, but resets the timer
|
||||||
void setValue(const float& v) {
|
void setValue(const float& v) {
|
||||||
|
if (v == m_fValue)
|
||||||
|
return;
|
||||||
|
|
||||||
m_fValue = v;
|
m_fValue = v;
|
||||||
animationBegin = std::chrono::system_clock::now();
|
animationBegin = std::chrono::system_clock::now();
|
||||||
m_vBegun = m_vValue;
|
m_vBegun = m_vValue;
|
||||||
|
@ -124,6 +141,9 @@ class CAnimatedVariable {
|
||||||
|
|
||||||
// Sets the actual stored value, without affecting the goal, but resets the timer
|
// Sets the actual stored value, without affecting the goal, but resets the timer
|
||||||
void setValue(const CColor& v) {
|
void setValue(const CColor& v) {
|
||||||
|
if (v == m_cValue)
|
||||||
|
return;
|
||||||
|
|
||||||
m_cValue = v;
|
m_cValue = v;
|
||||||
animationBegin = std::chrono::system_clock::now();
|
animationBegin = std::chrono::system_clock::now();
|
||||||
m_vBegun = m_vValue;
|
m_vBegun = m_vValue;
|
||||||
|
|
Loading…
Reference in a new issue