summaryrefslogtreecommitdiff
path: root/src/desktop/reserved/ReservedArea.hpp
blob: ca5978a7c86c14bc6c757a1af1e17e889b2a7561 (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
#pragma once

#include "../../helpers/math/Math.hpp"
#include <array>

namespace Desktop {
    enum eReservedDynamicType : uint8_t {
        RESERVED_DYNAMIC_TYPE_LS = 0,
        RESERVED_DYNAMIC_TYPE_ERROR_BAR,

        RESERVED_DYNAMIC_TYPE_END,
    };

    class CReservedArea {
      public:
        CReservedArea() = default;
        CReservedArea(const Vector2D& tl, const Vector2D& br);
        CReservedArea(double top, double right, double bottom, double left);
        CReservedArea(const CBox& parent, const CBox& child);
        ~CReservedArea() = default;

        CBox   apply(const CBox& other) const;
        void   applyip(CBox& other) const;

        void   resetType(eReservedDynamicType);
        void   addType(eReservedDynamicType, const Vector2D& topLeft, const Vector2D& bottomRight);
        void   addType(eReservedDynamicType, const CReservedArea& area);

        double left() const;
        double right() const;
        double top() const;
        double bottom() const;

        bool   ok() const;

        bool   operator==(const CReservedArea& other) const;

      private:
        void     calculate();

        Vector2D m_topLeft, m_bottomRight;
        Vector2D m_initialTopLeft, m_initialBottomRight;

        bool     m_ok = true;

        struct SDynamicData {
            Vector2D topLeft, bottomRight;
        };

        std::array<SDynamicData, RESERVED_DYNAMIC_TYPE_END> m_dynamicReserved;
    };
};