-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample.cpp
50 lines (40 loc) · 1.45 KB
/
Example.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
#include <micro_ui/app.h>
#include <string_format>
using namespace MicroUI;
UITab* tab1 = nullptr;
UIWindow* window = nullptr;
UIWindow* window2 = nullptr;
UITextbox* textbox = nullptr;
UITextbox* tab1_textbox = nullptr;
UITextbox* tab2_textbox = nullptr;
UI_Main {
auto* ui = MicroUI::GetAPI();
auto* app = ui->GetApplication();
window = app->NewWindow("Window 1");
window2 = app->NewWindow("Window 2");
window->SetHeight(800);
window->SetWidth(800);
window->AddLabel("Hi, I am a label!");
textbox = window->AddTextbox("Butts.");
window->AddButton("I am button! CLICK ME", [](auto*) {
textbox->SetText("The button was pressed!");
});
window->AddButton("Show second window", [](auto*) { window2->Show(); });
window->AddButton("Hide second window", [](auto*) { window2->Hide(); });
tab1 = window->AddTab("Tab 1");
auto* tab2 = window->AddTab("Tab 2");
tab1->AddLabel("Tab 1 label!");
tab1_textbox = tab1->AddTextbox("Tab 1 textbox.");
tab1->AddButton("Tab 1 button", [](auto* button) {
tab1_textbox->SetText(string_format("The {} button was pressed!", button->GetText()).c_str()
);
});
tab2->AddLabel("Butts!");
tab2_textbox = tab2->AddTextbox("Butts.");
tab2->AddButton("I am BUTTS! CLICK ME", [](auto*) {
tab2_textbox->SetText("The BUTTS was pressed!");
});
window->Show();
app->Run();
return 0;
}