-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.h
More file actions
61 lines (41 loc) · 1.19 KB
/
GUI.h
File metadata and controls
61 lines (41 loc) · 1.19 KB
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 "GUIComponent.h"
#include "GUIPanel.h"
#include "GUIButton.h"
#include "GUILabel.h"
#include "GUITextField.h"
class ConnectionBase;
class FocusGUIVisitor : public GUIVisitor
{
public:
FocusGUIVisitor(int x, int y) : x(x), y(y), mFocusedComponent(nullptr) {}
void Visit(GUIPanel*) override;
void Visit(GUIButton*) override;
void Visit(GUILabel*) override {} // ignore
void Visit(GUITextField*) override;
GUIComponent * GetFocusedComponent() { return mFocusedComponent; }
private:
int x, y;
GUIComponent *mFocusedComponent;
};
class GUI
{
public:
GUI(GUIComponent *root);
~GUI();
GUIComponent *GetRoot() { return mRoot; }
void SetVisible(bool visible) { mRoot->SetVisible(visible); }
bool IsVisible() const { return mRoot->IsVisible(); }
bool IsInside(int x, int y) { return mRoot->IsInside(x, y); }
void Destroy() { mIsDeleted = true; }
bool IsDeleted() { return mIsDeleted; }
void OnMouseMove(int x, int y);
void OnMousePress(int x, int y);
void OnMouseRelease(int x, int y);
void OnKeyPress(int key);
private:
bool mIsDeleted = false;
GUIComponent *mRoot;
GUIComponent *mFocusedComponent = nullptr;
GUIComponent *mSelectedComponent = nullptr;
};