Skip to content

Commit 0639685

Browse files
authored
demo: Quality of Life updates
- Meaningful titles across all Demos - Switch to CTRL+Q to exit the demos
1 parent 409de19 commit 0639685

24 files changed

Lines changed: 119 additions & 48 deletions

File tree

demo/allegro5/main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ int main(void)
100100
al_set_mouse_wheel_precision(150);
101101
al_install_keyboard();
102102

103+
al_set_new_window_title("allegro5");
103104
al_set_new_display_flags(ALLEGRO_WINDOWED|ALLEGRO_RESIZABLE|ALLEGRO_OPENGL);
104105
al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST);
105106
al_set_new_display_option(ALLEGRO_SAMPLES, 8, ALLEGRO_SUGGEST);
@@ -133,8 +134,11 @@ int main(void)
133134

134135
get_event = al_wait_for_event_until(event_queue, &ev, &timeout);
135136

136-
if (get_event && ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
137-
break;
137+
if (get_event) {
138+
if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE ||
139+
(ev.keyboard.keycode == ALLEGRO_KEY_Q && ev.keyboard.modifiers & ALLEGRO_KEYMOD_CTRL)) {
140+
break;
141+
}
138142
}
139143

140144
/* Very Important: Always do nk_input_begin / nk_input_end even if

demo/common/overview.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ overview(struct nk_context *ctx)
890890
"BOTTOM_CENTER",
891891
"BOTTOM_RIGHT"
892892
};
893-
static int cur_pos = NK_TOP_LEFT;
893+
int cur_pos = NK_TOP_LEFT;
894894

895895
if (!text_initialized) {
896896
const char text_default[] = "you can customize this!";
@@ -902,7 +902,7 @@ overview(struct nk_context *ctx)
902902
bounds = nk_widget_bounds(ctx);
903903
nk_label(ctx, "Hover for custom tooltip (you can customize it below)", NK_TEXT_LEFT);
904904
if (nk_input_is_mouse_hovering_rect(in, bounds)) {
905-
nk_tooltip_offset(ctx, text_buf, cur_pos, offset);
905+
nk_tooltip_offset(ctx, text_buf, (enum nk_tooltip_pos)cur_pos, offset);
906906
}
907907
nk_layout_row_dynamic(ctx, 1, 1);
908908
nk_rule_horizontal(ctx, nk_white, nk_true);
@@ -1445,11 +1445,11 @@ overview(struct nk_context *ctx)
14451445
nk_layout_row_dynamic(ctx, 20, 2);
14461446
for (i = 0; i < NK_BUTTON_MAX; i++) {
14471447
nk_label(ctx, button_names[i], NK_TEXT_LEFT);
1448-
if (nk_input_is_mouse_pressed(in, i))
1448+
if (nk_input_is_mouse_pressed(in, (enum nk_buttons)i))
14491449
nk_label(ctx, "Pressed", NK_TEXT_LEFT);
1450-
else if (nk_input_is_mouse_down(in, i))
1450+
else if (nk_input_is_mouse_down(in, (enum nk_buttons)i))
14511451
nk_label(ctx, "Down", NK_TEXT_LEFT);
1452-
else if (nk_input_is_mouse_released(in, i))
1452+
else if (nk_input_is_mouse_released(in, (enum nk_buttons)i))
14531453
nk_label(ctx, "Released", NK_TEXT_LEFT);
14541454
else
14551455
nk_label(ctx, "Up", NK_TEXT_LEFT);

demo/d3d11/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ int main(void)
228228
{
229229
if (msg.message == WM_QUIT)
230230
running = 0;
231+
if (msg.message == WM_SYSKEYDOWN && msg.wParam == 'Q' && GetKeyState(VK_CONTROL) & (1 << 15))
232+
running = 0;
231233
TranslateMessage(&msg);
232234
DispatchMessageW(&msg);
233235
}

demo/d3d12/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/* nuklear - 1.32.0 - public domain */
22

33
/*
4-
* === IMPORTATE NOTE FOR D3D12 ===
4+
* === IMPORTATE NOTE FOR D3D12 ===
55
*
66
* Due to a bug in the Windows SDK that
77
* was fixed in version 10.0.22000.0 the
88
* D3D12 Backend requires this version as
99
* a minimum! Compiling with a lower version
1010
* will result in compiler warnings and a
1111
* crashing application!
12-
*
12+
*
1313
*/
1414

1515
#define COBJMACROS
@@ -333,6 +333,8 @@ int main(void)
333333
{
334334
if (msg.message == WM_QUIT)
335335
running = 0;
336+
if (msg.message == WM_SYSKEYDOWN && msg.wParam == 'Q' && GetKeyState(VK_CONTROL) & (1 << 15))
337+
running = 0;
336338
TranslateMessage(&msg);
337339
DispatchMessageW(&msg);
338340
}

demo/d3d9/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ int main(void)
233233
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
234234
if (msg.message == WM_QUIT)
235235
running = 0;
236+
if (msg.message == WM_SYSKEYDOWN && msg.wParam == 'Q' && GetKeyState(VK_CONTROL) & (1 << 15))
237+
running = 0;
236238
TranslateMessage(&msg);
237239
DispatchMessageW(&msg);
238240
}

demo/gdi/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,11 @@ int main(void)
129129
MSG msg;
130130
nk_input_begin(ctx);
131131
if (needs_refresh == 0) {
132-
if (GetMessageW(&msg, NULL, 0, 0) <= 0)
132+
if (GetMessageW(&msg, NULL, 0, 0) <= 0) {
133133
running = 0;
134-
else {
134+
} else if (msg.message == WM_SYSKEYDOWN && msg.wParam == 'Q' && GetKeyState(VK_CONTROL) & (1 << 15))
135+
running = 0;
136+
} else {
135137
TranslateMessage(&msg);
136138
DispatchMessageW(&msg);
137139
}

demo/gdip/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ int main(void)
136136
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
137137
if (msg.message == WM_QUIT)
138138
running = 0;
139+
if (msg.message == WM_SYSKEYDOWN && msg.wParam == 'Q' && GetKeyState(VK_CONTROL) & (1 << 15))
140+
running = 0;
139141
TranslateMessage(&msg);
140142
DispatchMessageW(&msg);
141143
needs_refresh = 1;

demo/glfw_opengl2/main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ int main(void)
110110
fprintf(stdout, "[GFLW] failed to init!\n");
111111
exit(1);
112112
}
113-
win = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Demo", NULL, NULL);
113+
win = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "glfw_opengl2", NULL, NULL);
114114
glfwMakeContextCurrent(win);
115115
glfwGetWindowSize(win, &width, &height);
116116

@@ -154,6 +154,11 @@ int main(void)
154154
{
155155
/* Input */
156156
glfwPollEvents();
157+
if (glfwGetKey(win, GLFW_KEY_Q) == GLFW_PRESS &&
158+
(glfwGetKey(win, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS ||
159+
glfwGetKey(win, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS)) {
160+
glfwSetWindowShouldClose(win, nk_true);
161+
}
157162
nk_glfw3_new_frame();
158163

159164
/* GUI */

demo/glfw_opengl3/main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ int main(void)
107107
#ifdef __APPLE__
108108
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
109109
#endif
110-
win = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Demo", NULL, NULL);
110+
win = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "glfw_opengl3", NULL, NULL);
111111
glfwMakeContextCurrent(win);
112112
glfwGetWindowSize(win, &width, &height);
113113

@@ -139,6 +139,11 @@ int main(void)
139139
{
140140
/* Input */
141141
glfwPollEvents();
142+
if (glfwGetKey(win, GLFW_KEY_Q) == GLFW_PRESS &&
143+
(glfwGetKey(win, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS ||
144+
glfwGetKey(win, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS)) {
145+
glfwSetWindowShouldClose(win, nk_true);
146+
}
142147
nk_glfw3_new_frame(&glfw);
143148

144149
/* GUI */

demo/glfw_opengl4/main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ int main(void)
107107
#ifdef __APPLE__
108108
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
109109
#endif
110-
win = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Demo", NULL, NULL);
110+
win = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "glfw_opengl4", NULL, NULL);
111111
glfwMakeContextCurrent(win);
112112
glfwGetWindowSize(win, &width, &height);
113113

@@ -149,6 +149,11 @@ int main(void)
149149
{
150150
/* Input */
151151
glfwPollEvents();
152+
if (glfwGetKey(win, GLFW_KEY_Q) == GLFW_PRESS &&
153+
(glfwGetKey(win, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS ||
154+
glfwGetKey(win, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS)) {
155+
glfwSetWindowShouldClose(win, nk_true);
156+
}
152157
nk_glfw3_new_frame();
153158

154159
/* GUI */

0 commit comments

Comments
 (0)