2022-04-23 14:16:02 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2025-01-07 17:55:14 +00:00
|
|
|
#include <hyprutils/animation/AnimatedVariable.hpp>
|
|
|
|
|
|
2023-08-07 13:35:19 +02:00
|
|
|
#include "Color.hpp"
|
2024-04-27 12:43:12 +01:00
|
|
|
#include "../defines.hpp"
|
2024-04-02 20:32:39 +01:00
|
|
|
#include "../desktop/DesktopTypes.hpp"
|
2022-04-23 14:16:02 +02:00
|
|
|
|
2025-01-07 17:55:14 +00:00
|
|
|
enum eAVarDamagePolicy : int8_t {
|
|
|
|
|
AVARDAMAGE_NONE = -1,
|
|
|
|
|
AVARDAMAGE_ENTIRE = 0,
|
|
|
|
|
AVARDAMAGE_BORDER,
|
|
|
|
|
AVARDAMAGE_SHADOW
|
|
|
|
|
};
|
|
|
|
|
|
2024-12-07 18:51:18 +01:00
|
|
|
enum eAnimatedVarType : int8_t {
|
2022-04-23 14:16:02 +02:00
|
|
|
AVARTYPE_INVALID = -1,
|
|
|
|
|
AVARTYPE_FLOAT,
|
|
|
|
|
AVARTYPE_VECTOR,
|
|
|
|
|
AVARTYPE_COLOR
|
|
|
|
|
};
|
|
|
|
|
|
2024-12-07 18:51:18 +01:00
|
|
|
// Utility to bind a type with its corresponding eAnimatedVarType
|
2024-03-02 01:35:17 +01:00
|
|
|
template <class T>
|
2024-12-07 18:51:18 +01:00
|
|
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
|
|
|
struct STypeToAnimatedVarType_t {
|
|
|
|
|
static constexpr eAnimatedVarType value = AVARTYPE_INVALID;
|
2024-03-02 01:35:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <>
|
2024-12-07 18:51:18 +01:00
|
|
|
struct STypeToAnimatedVarType_t<float> {
|
|
|
|
|
static constexpr eAnimatedVarType value = AVARTYPE_FLOAT;
|
2024-03-02 01:35:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <>
|
2024-12-07 18:51:18 +01:00
|
|
|
struct STypeToAnimatedVarType_t<Vector2D> {
|
|
|
|
|
static constexpr eAnimatedVarType value = AVARTYPE_VECTOR;
|
2024-03-02 01:35:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <>
|
2024-12-07 18:51:18 +01:00
|
|
|
struct STypeToAnimatedVarType_t<CHyprColor> {
|
|
|
|
|
static constexpr eAnimatedVarType value = AVARTYPE_COLOR;
|
2024-03-02 01:35:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <class T>
|
2024-12-07 18:51:18 +01:00
|
|
|
inline constexpr eAnimatedVarType typeToeAnimatedVarType = STypeToAnimatedVarType_t<T>::value;
|
2024-03-02 01:35:17 +01:00
|
|
|
|
|
|
|
|
// Utility to define a concept as a list of possible type
|
|
|
|
|
template <class T, class... U>
|
|
|
|
|
concept OneOf = (... or std::same_as<T, U>);
|
2022-04-23 14:16:02 +02:00
|
|
|
|
2024-03-02 01:35:17 +01:00
|
|
|
// Concept to describe which type can be placed into CAnimatedVariable
|
|
|
|
|
// This is mainly to get better errors if we put a type that's not supported
|
|
|
|
|
// Otherwise template errors are ugly
|
|
|
|
|
template <class T>
|
2024-12-03 18:58:24 +00:00
|
|
|
concept Animable = OneOf<T, Vector2D, float, CHyprColor>;
|
2022-04-23 14:16:02 +02:00
|
|
|
|
2025-01-07 17:55:14 +00:00
|
|
|
struct SAnimationContext {
|
|
|
|
|
PHLWINDOWREF pWindow;
|
|
|
|
|
PHLWORKSPACEREF pWorkspace;
|
|
|
|
|
PHLLSREF pLayer;
|
2022-04-23 14:16:02 +02:00
|
|
|
|
2025-01-07 17:55:14 +00:00
|
|
|
eAVarDamagePolicy eDamagePolicy = AVARDAMAGE_NONE;
|
2022-09-25 20:07:48 +02:00
|
|
|
};
|
2024-03-02 01:35:17 +01:00
|
|
|
|
|
|
|
|
template <Animable VarType>
|
2025-01-07 17:55:14 +00:00
|
|
|
using CAnimatedVariable = Hyprutils::Animation::CGenericAnimatedVariable<VarType, SAnimationContext>;
|
2024-03-02 01:35:17 +01:00
|
|
|
|
2025-01-07 17:55:14 +00:00
|
|
|
template <Animable VarType>
|
|
|
|
|
using PHLANIMVAR = SP<CAnimatedVariable<VarType>>;
|
2024-03-02 01:35:17 +01:00
|
|
|
|
2025-01-07 17:55:14 +00:00
|
|
|
template <Animable VarType>
|
|
|
|
|
using PHLANIMVARREF = WP<CAnimatedVariable<VarType>>;
|