-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvclcontrols.h
More file actions
73 lines (56 loc) · 1.49 KB
/
vclcontrols.h
File metadata and controls
73 lines (56 loc) · 1.49 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once
// If defined no Controls will Compiled into the App
#ifndef COMPILE_NO_CONTROLS
class TButton : public TControl {
private:
bool clicked = false;
public:
void (*OnClick)(TControl* Sender) = 0;
str label = "Button";
private:
public:
TButton(TWindow* owner, int x, int y, str label) : TControl(owner) {
this->label = label;
this->x = x;
this->y = y;
sizeX = 60;
sizeY = 24;
};
void Draw(Renderer* renderer) {
if (InBounds(owner->GetLastMouseX(), owner->GetLastMouseY())) {
if (clicked)
renderer->FillRoundedRect(x, y, sizeX, sizeY, Color(0xffffff, 25));
renderer->DrawRoundedRect(x, y, sizeX, sizeY, Color(0xffffff));
} else
renderer->DrawRoundedRect(x, y, sizeX, sizeY, Color(0x808080));
renderer->DrawString(x, y, sizeX, sizeY, Color(0xffffff), label);
};
void UserInputEvent(InputType inputType, ulong64 param) {
switch (inputType) {
case InputType::MouseDown:
clicked = true;
break;
case InputType::MouseUp:
if (clicked && InBounds(owner->GetLastMouseX(), owner->GetLastMouseY()) && OnClick != nullptr)
OnClick(this);
clicked = false;
break;
}
};
};
class TLabel : public TControl {
public:
str label = "Label";
public:
TLabel(TWindow* owner, int x, int y, int width, int height, str label) : TControl(owner) {
this->x = x;
this->y = y;
this->sizeX = width;
this->sizeY = height;
this->label = label;
};
void Draw(Renderer* renderer) {
renderer->DrawString(x, y, sizeX, sizeY, Color(0xffffff), label);
};
};
#endif