-
Notifications
You must be signed in to change notification settings - Fork 1
/
UIElementTracker.h
51 lines (37 loc) · 1008 Bytes
/
UIElementTracker.h
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
/** $VER: UIElementTracker.h (2024.06.12) P. Stuer - Tracks the instances of the panel. **/
#pragma once
#include "framework.h"
#include "UIElement.h"
class uielement_tracker_t
{
public:
uielement_tracker_t() : _CurrentUIElement()
{
}
void Add(UIElement * element) noexcept
{
_UIElements.push_back(element);
SetCurrentElement(element);
}
void Remove(UIElement * element) noexcept
{
auto Iter = std::find(_UIElements.begin(), _UIElements.end(), element);
if (Iter != _UIElements.end())
{
_UIElements.erase(Iter);
SetCurrentElement(nullptr);
}
}
UIElement * GetCurrentElement() const noexcept
{
return _CurrentUIElement;
}
void SetCurrentElement(UIElement * element) noexcept
{
_CurrentUIElement = element;
}
private:
UIElement * _CurrentUIElement;
std::vector<UIElement *> _UIElements;
};
extern uielement_tracker_t _UIElementTracker;