From de3a154f3801de22c8e0bd2aeabf663a70c05972 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 14 Apr 2015 12:00:12 +0100 Subject: [PATCH 01/10] Tweak date/credits --- LICENSE | 2 +- imgui.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index fa863007..b28ef225 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014 Omar Cornut +Copyright (c) 2014-2015 Omar Cornut and ImGui contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/imgui.cpp b/imgui.cpp index 7432156d..c33ba417 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2,7 +2,7 @@ // See ImGui::ShowTestWindow() for sample code. // Read 'Programmer guide' below for notes on how to setup ImGui in your codebase. // Get latest version at https://github.com/ocornut/imgui -// Developed by Omar Cornut and contributors. +// Developed by Omar Cornut and ImGui contributors. /* From ac518a1d3e36d0a7e47bc52de4b89fb14fdc9542 Mon Sep 17 00:00:00 2001 From: Dale Kim Date: Tue, 14 Apr 2015 14:09:26 -0500 Subject: [PATCH 02/10] Set modifier key state by inspecting imgui's io.KeysDown array. --- examples/opengl3_example/imgui_impl_glfw_gl3.cpp | 8 ++++---- examples/opengl_example/imgui_impl_glfw.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp index 9953a963..958854a6 100644 --- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp +++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp @@ -134,7 +134,7 @@ void ImGui_ImplGlfwGL3_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yo g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines. } -void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow* window, int key, int, int action, int mods) +void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow*, int key, int, int action, int mods) { ImGuiIO& io = ImGui::GetIO(); if (action == GLFW_PRESS) @@ -143,9 +143,9 @@ void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow* window, int key, int, int action, io.KeysDown[key] = false; (void)mods; // Modifiers are not reliable across systems - io.KeyCtrl = glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS; - io.KeyShift = glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS; - io.KeyAlt = glfwGetKey(window, GLFW_KEY_LEFT_ALT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_ALT) == GLFW_PRESS; + io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL]; + io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT]; + io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT]; } void ImGui_ImplGlfwGL3_CharCallback(GLFWwindow*, unsigned int c) diff --git a/examples/opengl_example/imgui_impl_glfw.cpp b/examples/opengl_example/imgui_impl_glfw.cpp index 341d418d..0a0ee3e6 100644 --- a/examples/opengl_example/imgui_impl_glfw.cpp +++ b/examples/opengl_example/imgui_impl_glfw.cpp @@ -116,7 +116,7 @@ void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffs g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines. } -void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int, int action, int mods) +void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods) { ImGuiIO& io = ImGui::GetIO(); if (action == GLFW_PRESS) @@ -125,9 +125,9 @@ void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int, int action, in io.KeysDown[key] = false; (void)mods; // Modifiers are not reliable across systems - io.KeyCtrl = glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS; - io.KeyShift = glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS; - io.KeyAlt = glfwGetKey(window, GLFW_KEY_LEFT_ALT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_ALT) == GLFW_PRESS; + io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL]; + io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT]; + io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT]; } void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c) From f400ea4ec8d07b1d040222d698ad60a496255b1b Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 15 Apr 2015 10:14:51 +0100 Subject: [PATCH 03/10] Examples: OpenGL3: backup/restore current program and texture #195 --- examples/opengl3_example/imgui_impl_glfw_gl3.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp index 958854a6..dba7e13a 100644 --- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp +++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp @@ -35,6 +35,9 @@ static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawList** const cmd_lists, int return; // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled + GLint last_program, last_texture; + glGetIntegerv(GL_CURRENT_PROGRAM, &last_program); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -108,9 +111,9 @@ static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawList** const cmd_lists, int // Restore modified state glBindVertexArray(0); - glUseProgram(0); + glUseProgram(last_program); glDisable(GL_SCISSOR_TEST); - glBindTexture(GL_TEXTURE_2D, 0); + glBindTexture(GL_TEXTURE_2D, last_texture); } static const char* ImGui_ImplGlfwGL3_GetClipboardText() From aca85dbea458bb4543394184d0d9cd65357eb6f8 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 16 Apr 2015 10:54:56 +0100 Subject: [PATCH 04/10] Fixed hovering over a popup's child (popups disable hovering on other windows but not their childs) #197 --- imgui.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index c33ba417..68d02d4e 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4356,9 +4356,11 @@ static inline bool IsWindowContentHoverable(ImGuiWindow* window) { ImGuiState& g = *GImGui; - ImGuiWindow* focused_window = g.FocusedWindow; - if (focused_window && (focused_window->Flags & ImGuiWindowFlags_Popup) != 0 && focused_window->WasVisible && focused_window != window) - return false; + // An active popup disable hovering on other windows (apart from its own children) + if (ImGuiWindow* focused_window = g.FocusedWindow) + if (ImGuiWindow* focused_root_window = focused_window->RootWindow) + if ((focused_root_window->Flags & ImGuiWindowFlags_Popup) != 0 && focused_root_window->WasVisible && focused_root_window != window->RootWindow) + return false; return true; } From 64db50ba461cf47bf2d39b572818fd7632dd811f Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 16 Apr 2015 10:58:30 +0100 Subject: [PATCH 05/10] TODO list --- imgui.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 68d02d4e..98748f75 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -327,16 +327,16 @@ - layout: horizontal layout helper (github issue #97) - layout: more generic alignment state (left/right/centered) for single items? - layout: clean up the InputFloatN/SliderFloatN/ColorEdit4 layout code. item width should include frame padding. - - columns: separator function or parameter that works within the column (currently Separator() bypass all columns) - - columns: declare column set (each column: fixed size, %, fill, distribute default size among fills) - - columns: columns header to act as button (~sort op) and allow resize/reorder - - columns: user specify columns size - - columns: tree node example, removing the last NextColumn() makes a padding difference (it should not) + - columns: separator function or parameter that works within the column (currently Separator() bypass all columns) (github issue #125) + - columns: declare column set (each column: fixed size, %, fill, distribute default size among fills) (github issue #125) + - columns: columns header to act as button (~sort op) and allow resize/reorder (github issue #125) + - columns: user specify columns size (github issue #125) + - popup: border options. richer api like BeginChild() perhaps? (github issue #197) - combo: turn child handling code into pop up helper - combo: contents should extends to fit label if combo widget is small - listbox: multiple selection - listbox: user may want to initial scroll to focus on the one selected value? - ! menubar, menus + ! menubar, menus (github issue #126) - tabs - gauge: various forms of gauge/loading bars widgets - color: better color editor. From d24474ea82e55ef4e465d613f1b2f2a004b59d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 16 Apr 2015 14:39:04 -0700 Subject: [PATCH 06/10] Fixed: warning: missing field 'w' initializer [-Wmissing-field-initializers] --- imgui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 98748f75..45fe9eef 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -8451,7 +8451,7 @@ void ImFontAtlas::RenderCustomTexData(int pass, void* p_rects) ImVector& rects = *(ImVector*)p_rects; if (pass == 0) { - stbrp_rect r = { 0 }; + stbrp_rect r = {}; r.w = (TEX_DATA_W*2)+1; r.h = TEX_DATA_H+1; rects.push_back(r); From b7b3df3c81790960f83cf246f2f78e18069199e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 16 Apr 2015 14:42:17 -0700 Subject: [PATCH 07/10] Fixed: warning: declaration shadows a local variable --- imgui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 45fe9eef..dee39f8c 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -10488,9 +10488,9 @@ void ImGui::ShowTestWindow(bool* opened) ImGui::End(); } -void ImGui::ShowMetricsWindow(bool* opened) +void ImGui::ShowMetricsWindow(bool* opened1) { - if (ImGui::Begin("ImGui Metrics", opened)) + if (ImGui::Begin("ImGui Metrics", opened1)) { ImGui::Text("ImGui %s", ImGui::GetVersion()); ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); From 508d05414a8bcd271df07efdf67370192f329bf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 16 Apr 2015 14:45:42 -0700 Subject: [PATCH 08/10] Fixed warning: missing initializer for member. --- imgui.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index dee39f8c..f99e4516 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -8451,7 +8451,8 @@ void ImFontAtlas::RenderCustomTexData(int pass, void* p_rects) ImVector& rects = *(ImVector*)p_rects; if (pass == 0) { - stbrp_rect r = {}; + stbrp_rect r; + memset(&r, 0, sizeof(r)); r.w = (TEX_DATA_W*2)+1; r.h = TEX_DATA_H+1; rects.push_back(r); From 7fde17e15a1ec732b419e17825739d216b618ef3 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 16 Apr 2015 23:30:48 +0100 Subject: [PATCH 09/10] ShowMetricsWindow(): renaming locals (not sure about the "shadows a local variable" warning?) --- imgui.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index f99e4516..9dbc5b56 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -10489,9 +10489,9 @@ void ImGui::ShowTestWindow(bool* opened) ImGui::End(); } -void ImGui::ShowMetricsWindow(bool* opened1) +void ImGui::ShowMetricsWindow(bool* opened) { - if (ImGui::Begin("ImGui Metrics", opened1)) + if (ImGui::Begin("ImGui Metrics", opened)) { ImGui::Text("ImGui %s", ImGui::GetVersion()); ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); @@ -10502,13 +10502,13 @@ void ImGui::ShowMetricsWindow(bool* opened1) { static void NodeDrawList(ImDrawList* draw_list, const char* label) { - bool opened = ImGui::TreeNode(draw_list, "%s: %d vtx, %d cmds", label, draw_list->vtx_buffer.size(), draw_list->commands.size()); + bool node_opened = ImGui::TreeNode(draw_list, "%s: %d vtx, %d cmds", label, draw_list->vtx_buffer.size(), draw_list->commands.size()); if (draw_list == ImGui::GetWindowDrawList()) { ImGui::SameLine(); ImGui::TextColored(ImColor(255,100,100), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered) } - if (!opened) + if (!node_opened) return; for (const ImDrawCmd* pcmd = draw_list->commands.begin(); pcmd < draw_list->commands.end(); pcmd++) if (pcmd->user_callback) From 6920e70e2ec0eed26f36b2cc36f4fac34d8ba311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 16 Apr 2015 15:52:35 -0700 Subject: [PATCH 10/10] Fixed C4267. --- imgui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index f99e4516..94b1c4eb 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -8198,7 +8198,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, return NULL; } - ImFont* font = AddFontFromMemoryTTF(data, data_size, size_pixels, glyph_ranges, font_no); + ImFont* font = AddFontFromMemoryTTF(data, (unsigned int)data_size, size_pixels, glyph_ranges, font_no); return font; } @@ -8235,7 +8235,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* in_compressed_tt stb_decompress(buf_decompressed, (unsigned char*)in_compressed_ttf_data, in_compressed_ttf_data_size); // Add - ImFont* font = AddFontFromMemoryTTF(buf_decompressed, buf_decompressed_size, size_pixels, glyph_ranges, font_no); + ImFont* font = AddFontFromMemoryTTF(buf_decompressed, (unsigned int)buf_decompressed_size, size_pixels, glyph_ranges, font_no); return font; }