-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinput_demo.cpp
77 lines (52 loc) · 2.03 KB
/
input_demo.cpp
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
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#define STB_TRUETYPE_IMPLEMENTATION
#include <iostream>
#include <cstddef>
#include "second.h"
#include "rmkit.h"
using namespace std;
class App {
public:
ui::Scene demo_scene;
App() {
demo_scene = ui::make_scene();
ui::MainLoop::set_scene(demo_scene);
auto fb = framebuffer::get();
fb->clear_screen();
fb->redraw_screen();
auto structuredArgs_0 = fb->get_display_size(); auto w = get<0>(structuredArgs_0); auto h = get<1>(structuredArgs_0);
auto v_layout = ui::VerticalLayout(0, 0, w, h, demo_scene);
auto h_layout1 = ui::HorizontalLayout(0, 0, w, 50, demo_scene);
auto h_layout2 = ui::HorizontalLayout(0, 0, w, 50, demo_scene);
auto h_layout3 = ui::HorizontalLayout(0, 0, w, 50, demo_scene);
v_layout.pack_start(h_layout1);
v_layout.pack_start(h_layout2);
v_layout.pack_start(h_layout3);
h_layout1.pack_start(new ui::Text(0, 0, 200, 50, "Héllo world"));
h_layout2.pack_center(new ui::Text(0, 0, 200, 50, "Hello world"));
h_layout3.pack_end(new ui::Text(0, 0, 200, 50, "Hello world"));
auto h_layout = ui::HorizontalLayout(0, 0, w, h, demo_scene);
v_layout.pack_start(h_layout);
h_layout.pack_center(new ui::TextInput(0, 50, 1000, 50));
auto range = new ui::RangeInput(0, 150, 1000, 50);
range->set_range(0, 100);
h_layout.pack_center(range); }
auto handle_key_event(input::SynKeyEvent &key_ev) {
std::cerr << "KEY PRESSED" << ' ' << key_ev.key << std::endl; }
auto handle_motion_event(input::SynMotionEvent &syn_ev) {
(void)0; }
auto run() {
ui::MainLoop::key_event += PLS_DELEGATE(this->handle_key_event);
ui::MainLoop::motion_event += PLS_DELEGATE(this->handle_motion_event);
ui::MainLoop::refresh();
ui::MainLoop::redraw();
while (true) {
ui::MainLoop::main();
ui::MainLoop::redraw();
ui::MainLoop::read_input(); } } };
int main() {
App app;
Secondary::exported();
app.run(); };