-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiple_windows.cpp
More file actions
71 lines (53 loc) · 1.72 KB
/
multiple_windows.cpp
File metadata and controls
71 lines (53 loc) · 1.72 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
// See hello_world.cpp first
#include <functional>
#include "DearImKit/dearimkit.h"
class HelloWorldAgain : public DearImKit::Panel {
public:
HelloWorldAgain(int index, int num_times = 1) : DearImKit::Panel("Hello World Again##" + index), m_num_times(num_times) {};
bool draw() override {
bool stay_open = true;
// Check out https://github.com/ocornut/imgui for guide to ImGui logic
if (!DearImKit::Begin(*this, &stay_open)) {
ImGui::End();
return stay_open;
}
for (int i = 0; i < m_num_times; i++) {
ImGui::Text("Hello World again from DearImKit");
}
ImGui::End();
return stay_open;
}
private:
int m_num_times;
};
class HelloWorld : public DearImKit::Panel {
public:
HelloWorld(int num_times = 1) : DearImKit::Panel("Hello World"), m_num_times(num_times) {};
bool draw() override {
bool stay_open = true;
// Check out https://github.com/ocornut/imgui for guide to ImGui logic
if (!DearImKit::Begin(*this, &stay_open)) {
ImGui::End();
return stay_open;
}
for (int i = 0; i < m_num_times; i++) {
ImGui::Text("Hello World from DearImKit");
}
if (ImGui::Button("Say Hello World again")) {
// HelloWorld2 will now be rendered
DearImKit::AddPanel<HelloWorldAgain>(m_num_windows_opened, 3);
m_num_windows_opened++;
}
ImGui::End();
return stay_open;
}
private:
int m_num_times;
int m_num_windows_opened = 0;
};
int main() {
std::function<void(void)> at_start = []() {
DearImKit::AddPanel<HelloWorld>(2);
};
DearImKit::SetupApp(at_start);
}