-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
60 lines (43 loc) · 1.7 KB
/
main.cpp
File metadata and controls
60 lines (43 loc) · 1.7 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
#include <iostream>
#include "application.h"
#include "windows/scrollBar.h"
const Color purple = Color(77, 0, 153);
const Color orange = Color(255, 165, 0);
class ColorChangeButton: public RectButton {
public:
ColorChangeButton(int x, int y, int width, int height, const Color& color, SystemEventSender* systemEventSender):
RectButton(x, y, width, height, color, systemEventSender) {}
void onLeftClick(std::unique_ptr<Event>& event) override {
color = orange;
}
void onLeftUnclick(std::unique_ptr<Event>& event) override {
color = purple;
}
void getEvent(std::unique_ptr<Event> &event) override {
if (event->type == Event::ScrollBarAction) {
y = 50 + dynamic_cast<ScrollBarActionEvent*>(event.get())->percent * 200;
// printf("%f\n", dynamic_cast<ScrollBarActionEvent*>(event.get())->percent);
}
checkClick(event);
for (auto window: subWindows) {
window->getEvent(event);
}
}
};
int main() {
Application app(1800, 900, "Engine work");
app.setBackgroundColor(255, 255, 255);
ColorChangeButton button(50, 50, 200, 75, purple, app.getSystemEventManager());
app.addDrawableObject(&button);
ColorChangeButton button2(50, 400, 200, 75, purple, app.getSystemEventManager());
app.addDrawableObject(&button2);
ScrollBar scrollBar(600, 50, 30, 300, app.getSystemEventManager());
app.addDrawableObject(&scrollBar);
EventManager::addListener(&scrollBar, &button);
Slider testSlider(500, 500, 50, 50, {255, 0, 0},
app.getSystemEventManager(),
400, 600);
app.addDrawableObject(&testSlider);
app.run();
return 0;
}