summaryrefslogtreecommitdiff
path: root/src/desktop/rule/layerRule/LayerRuleApplicator.hpp
blob: 97f15b043cac3d18caadacefc859d11b26633fef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once

#include "../../DesktopTypes.hpp"
#include "../Rule.hpp"
#include "../../types/OverridableVar.hpp"
#include "../../../helpers/math/Math.hpp"
#include "../../../config/ConfigDataValues.hpp"

namespace Desktop::Rule {
    class CLayerRule;

    class CLayerRuleApplicator {
      public:
        CLayerRuleApplicator(PHLLS ls);
        ~CLayerRuleApplicator() = default;

        CLayerRuleApplicator(const CLayerRuleApplicator&) = delete;
        CLayerRuleApplicator(CLayerRuleApplicator&)       = delete;
        CLayerRuleApplicator(CLayerRuleApplicator&&)      = delete;

        void propertiesChanged(std::underlying_type_t<eRuleProperty> props);
        void resetProps(std::underlying_type_t<eRuleProperty> props, Types::eOverridePriority prio = Types::PRIORITY_WINDOW_RULE);

#define COMMA ,
#define DEFINE_PROP(type, name, def)                                                                                                                                               \
  private:                                                                                                                                                                         \
    std::pair<Types::COverridableVar<type>, std::underlying_type_t<eRuleProperty>> m_##name = {def, RULE_PROP_NONE};                                                               \
                                                                                                                                                                                   \
  public:                                                                                                                                                                          \
    Types::COverridableVar<type>& name() {                                                                                                                                         \
        return m_##name.first;                                                                                                                                                     \
    }                                                                                                                                                                              \
    void name##Override(const Types::COverridableVar<type>& other) {                                                                                                               \
        m_##name.first = other;                                                                                                                                                    \
    }

        // dynamic props
        DEFINE_PROP(bool, noanim, false)
        DEFINE_PROP(bool, blur, false)
        DEFINE_PROP(bool, blurPopups, false)
        DEFINE_PROP(bool, dimAround, false)
        DEFINE_PROP(bool, xray, false)
        DEFINE_PROP(bool, noScreenShare, false)

        DEFINE_PROP(Hyprlang::INT, order, 0)
        DEFINE_PROP(Hyprlang::INT, aboveLock, 0)

        DEFINE_PROP(Hyprlang::FLOAT, ignoreAlpha, 0.F)

        DEFINE_PROP(std::string, animationStyle, std::string(""))

#undef COMMA
#undef DEFINE_PROP

      private:
        PHLLSREF m_ls;

        void     applyDynamicRule(const SP<CLayerRule>& rule);
    };
};