From eeb403135d91edb84e67b25ad69565a6b15b0d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 9 Feb 2024 13:06:26 +0100 Subject: [PATCH] Add minor features and updates to window test - Button label reflects window mode - Window attention request button - Slightly less bad button layout possibly - Applicable button labels list expected delay - Less telegraphic message for positions being unsupported - Window size more likely to fit contents --- tests/window.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/tests/window.c b/tests/window.c index 83baff46..94c4f172 100644 --- a/tests/window.c +++ b/tests/window.c @@ -71,7 +71,7 @@ int main(int argc, char** argv) glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); - GLFWwindow* window = glfwCreateWindow(600, 600, "Window Features", NULL, NULL); + GLFWwindow* window = glfwCreateWindow(600, 630, "Window Features", NULL, NULL); if (!window) { glfwTerminate(); @@ -121,17 +121,20 @@ int main(int argc, char** argv) nk_glfw3_new_frame(); if (nk_begin(nk, "main", area, 0)) { - nk_layout_row_dynamic(nk, 30, 5); + nk_layout_row_dynamic(nk, 30, 4); - if (nk_button_label(nk, "Toggle Fullscreen")) + if (glfwGetWindowMonitor(window)) { - if (glfwGetWindowMonitor(window)) + if (nk_button_label(nk, "Make Windowed")) { glfwSetWindowMonitor(window, NULL, windowed_x, windowed_y, windowed_width, windowed_height, 0); } - else + } + else + { + if (nk_button_label(nk, "Make Fullscreen")) { GLFWmonitor* monitor = glfwGetPrimaryMonitor(); const GLFWvidmode* mode = glfwGetVideoMode(monitor); @@ -149,7 +152,10 @@ int main(int argc, char** argv) glfwIconifyWindow(window); if (nk_button_label(nk, "Restore")) glfwRestoreWindow(window); - if (nk_button_label(nk, "Hide (briefly)")) + + nk_layout_row_dynamic(nk, 30, 2); + + if (nk_button_label(nk, "Hide (for 3s)")) { glfwHideWindow(window); @@ -159,6 +165,16 @@ int main(int argc, char** argv) glfwShowWindow(window); } + if (nk_button_label(nk, "Request Attention (after 3s)")) + { + glfwIconifyWindow(window); + + const double time = glfwGetTime() + 3.0; + while (glfwGetTime() < time) + glfwWaitEventsTimeout(1.0); + + glfwRequestWindowAttention(window); + } nk_layout_row_dynamic(nk, 30, 1); @@ -211,7 +227,7 @@ int main(int argc, char** argv) last_ypos = ypos; } else - nk_label(nk, "Position not supported", NK_TEXT_LEFT); + nk_label(nk, "Platform does not support window position", NK_TEXT_LEFT); nk_layout_row_dynamic(nk, 30, 3); nk_label(nk, "Size", NK_TEXT_LEFT);