summaryrefslogtreecommitdiffhomepage
path: root/Public/Kits/System.Graphics/Frame.hxx
blob: 6c305cd3c2c24abb917ce05d677571b38cf0c790 (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
/* -------------------------------------------

    Copyright Mahrouss Logic

    File: Frame.hxx
    Purpose:

    Revision History:

    31/01/24: Added file (amlel)

------------------------------------------- */

#pragma once

#include <System.Graphics/Core.hxx>
#include <System.Graphics/Dim2d.hxx>
#include <NewKit/MutableArray.hpp>

namespace System::Graphics {
class G_API GFrame {
 public:
  explicit GFrame(GFrame* parent = nullptr) : m_ParentFrame(parent) {}
  ~GFrame() {}

  GFrame& operator=(const GFrame&) = default;
  GFrame(const GFrame&) = default;

  virtual void Update() {
    if (m_Frames.Count() == 0) return;

    for (int x = 0; x < m_Frames.Count(); ++x) {
      if (!m_Frames[x]->ShouldBeUpdated()) continue;

      m_Frames[x]->Update();
    }

    this->Paint();
  }

  virtual void UpdateInput() {
    if (m_Frames.Count() == 0) return;

    for (int x = 0; x < m_Frames.Count(); ++x) {
      if (!m_Frames[x]->ShouldBeUpdated()) continue;

      m_Frames[x]->UpdateInput();
    }
  }

  virtual bool ShouldBeUpdated() { return false; }

  virtual void Paint() = 0;

 private:
  HCore::MutableArray<GFrame*> m_Frames;
  GFrame* m_ParentFrame{nullptr};
};
}  // namespace System::Graphics