-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControls.h
212 lines (195 loc) · 3.65 KB
/
Controls.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
source by ibanned / xtk
*/
#pragma once
#include "GUI.h"
class CCheckBox : public CControl
{
public:
CCheckBox();
void SetState(bool s);
bool GetState();
protected:
bool Checked;
void Draw(bool hover);
void OnUpdate();
void OnClick();
};
class CSeperate : public CControl
{
public:
CSeperate();
protected:
void Draw(bool hover);
void OnUpdate();
void OnClick();
};
class CLabel : public CControl
{
public:
CLabel();
void SetText(std::string text);
protected:
std::string Text;
void Draw(bool hover);
void OnUpdate();
void OnClick();
};
class CGroupTab
{
public:
std::string name;
int id;
public:
CGroupTab(std::string _name, int _id)
{
this->name = _name;
this->id = _id;
}
};
class CGroupBox : public CControl
{
public:
CGroupBox();
void SetText(std::string text);
void SetSpacing(int Spacing);
void PlaceLabledControl(std::string Label, CTab *Tab, CControl* control);
void PlaceCheckBox(std::string Label, CTab * Tab, CControl * control);
void PlaceOtherControl(std::string Label, CTab * Tab, CControl * control);
void AddTab(CGroupTab t);
int selected_tab = 0;
std::vector<CGroupTab> group_tabs;
protected:
int Items;
std::string Text;
float iYAdd;
int ItemSpacing;
void Draw(bool hover);
void OnUpdate();
void OnClick();
};
enum SliderFormat
{
FORMAT_INT = 1,
FORMAT_DECDIG1,
FORMAT_DECDIG2
};
class CSlider : public CControl
{
public:
CSlider();
float GetValue();
void SetValue(float v);
void SetBoundaries(float min, float max);
void SetFormat(SliderFormat type);
protected:
float Value;
float Min;
float Max;
int format;
bool DoDrag;
void Draw(bool hover);
void OnUpdate();
void OnClick();
};
class CColorSlider : public CControl
{
public:
CColorSlider();
float GetValue();
void SetValue(float v);
void SetBoundaries(float min, float max);
protected:
float Value;
float Min;
float Max;
bool DoDrag;
void Draw(bool hover);
void OnUpdate();
void OnClick();
};
class CKeyBind : public CControl
{
public:
CKeyBind();
int GetKey();
void SetKey(int key);
protected:
int Key;
bool IsGettingKey;
void Draw(bool hover);
void OnUpdate();
void OnClick();
};
class CButton : public CControl
{
public:
typedef void(*ButtonCallback_t)(void);
CButton();
void SetCallback(ButtonCallback_t callback);
void SetText(std::string text);
protected:
ButtonCallback_t CallBack;
std::string Text;
void Draw(bool hover);
void OnUpdate();
void OnClick();
};
class CComboBox : public CControl
{
public:
CComboBox();
void AddItem(std::string text);
void SelectIndex(int idx);
int GetIndex();
void SetIndex(int index);
std::string GetItem();
protected:
std::vector<std::string> Items;
int SelectedIndex;
bool IsOpen;
void Draw(bool hover);
void OnUpdate();
void OnClick();
};
class CButtonLoad : public CControl
{
public:
typedef void(*ButtonCallback_t)(void);
CButtonLoad();
void SetCallback(ButtonCallback_t callback);
void SetText(std::string text);
protected:
ButtonCallback_t CallBack;
std::string Text;
void Draw(bool hover);
void OnUpdate();
void OnClick();
};
class CButtonSave : public CControl
{
public:
typedef void(*ButtonCallback_t)(void);
CButtonSave();
void SetCallback(ButtonCallback_t callback);
void SetText(std::string text);
protected:
ButtonCallback_t CallBack;
std::string Text;
void Draw(bool hover);
void OnUpdate();
void OnClick();
};
class CTextField : public CControl
{
public:
CTextField();
std::string getText();
void SetText(std::string);
private:
std::string text;
bool IsGettingKey;
void Draw(bool hover);
void OnUpdate();
void OnClick();
};