From b2c34404777ea0850f90f4c38f64484f03599d14 Mon Sep 17 00:00:00 2001 From: GartoxFR Date: Sat, 2 Mar 2024 01:35:17 +0100 Subject: animations: Refactor AnimatedVariable (#4911) * animation: Refactor AnimatedVariable This commit decomposes the AnimatedVariable class into a base class with the common attribute to all variable types and a templated derived type containing strongly typed info on the type being animated. Access to the typed version is perfomed using the visitor pattern. A utility is provided to build a visitor on the fly using lambdas. Adding a new type to be animated should just be a matter of adding the typed in the list defined by the ANIMABLE_TYPES macro The size of the commit is justified by the API change in the AnimatedVariable class. No more vec(), fl() or col() method but a unified value() method. * animation: Remove visitor pattern * animation: Fix coding style * animation: Fix coding style --- src/Window.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/Window.hpp') diff --git a/src/Window.hpp b/src/Window.hpp index 620ae06d..aeb674d1 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -221,8 +221,8 @@ class CWindow { Vector2D m_vSize = Vector2D(0, 0); // this is the real position and size used to draw the thing - CAnimatedVariable m_vRealPosition; - CAnimatedVariable m_vRealSize; + CAnimatedVariable m_vRealPosition; + CAnimatedVariable m_vRealSize; // for not spamming the protocols Vector2D m_vReportedPosition; @@ -282,13 +282,13 @@ class CWindow { std::unique_ptr m_pPopupHead; // Animated border - CGradientValueData m_cRealBorderColor = {0}; - CGradientValueData m_cRealBorderColorPrevious = {0}; - CAnimatedVariable m_fBorderFadeAnimationProgress; - CAnimatedVariable m_fBorderAngleAnimationProgress; + CGradientValueData m_cRealBorderColor = {0}; + CGradientValueData m_cRealBorderColorPrevious = {0}; + CAnimatedVariable m_fBorderFadeAnimationProgress; + CAnimatedVariable m_fBorderAngleAnimationProgress; // Fade in-out - CAnimatedVariable m_fAlpha; + CAnimatedVariable m_fAlpha; bool m_bFadingOut = false; bool m_bReadyToDelete = false; Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in @@ -322,13 +322,13 @@ class CWindow { std::vector> m_vTransformers; // for alpha - CAnimatedVariable m_fActiveInactiveAlpha; + CAnimatedVariable m_fActiveInactiveAlpha; // animated shadow color - CAnimatedVariable m_cRealShadowColor; + CAnimatedVariable m_cRealShadowColor; // animated tint - CAnimatedVariable m_fDimPercent; + CAnimatedVariable m_fDimPercent; // swallowing CWindow* m_pSwallowed = nullptr; -- cgit v1.2.3