-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestapp.cpp
More file actions
53 lines (36 loc) · 1.45 KB
/
testapp.cpp
File metadata and controls
53 lines (36 loc) · 1.45 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
#include "wui.h"
#include <embed/files.h>
int main(int argc, char const* argv[]) {
wui::allow_inspect(true);
auto w = wui::create_view();
// w->set_styling(wui::window_style::NO_OS_DECORATIONS);
w->on_asset_requested = [](std::string uri) -> wui::asset_t {
printf("ASSET REQUEST: %s\n", uri.c_str());
return {"text/html", std::vector<uint8_t>(std::begin(wui_internal::example_html), std::end(wui_internal::example_html))};
};
w->bind_function("print", wui::make_binding([](std::string message) { printf("%s\n", message.c_str()); }));
w->bind_function("sum", wui::make_binding([](int first, int second) { return first + second; }));
wui::view w2;
w->bind_function("mkwindow", wui::make_binding([&]() {
w2 = wui::create_view();
w2->set_html("example");
}));
w->bind_function("hide", wui::make_binding([&]() { w2->hide(); }));
w->bind_function("restore", wui::make_binding([&]() { w2->show(); }));
w->bind_function("echo", wui::make_binding([](std::string m) { return m + " ECHO"; }));
w->bind_function("resize", wui::make_binding([&](int width, int height) {
w->set_size(width, height);
}));
w->bind_function("minimize", wui::make_binding([&]() {
w->minimize();
}));
w->bind_function("maximize", wui::make_binding([&]() {
w->maximize();
}));
w->bind_function("throws", wui::make_binding([]() { throw std::runtime_error("fuck"); }));
w->navigate("wui://internal/index.html");
w->set_size(1280, 720);
w->show();
wui::run();
return 0;
}