From 42a919f303899fdaab961d3e68f400267442f432 Mon Sep 17 00:00:00 2001 From: Omar Cornut Date: Wed, 27 Jun 2018 09:32:03 +0200 Subject: [PATCH 01/12] Examples: Apple: Fixed paths of GLFW+GL2 example. (#1906) Update ignore list. --- examples/.gitignore | 5 +++ .../imguiex.xcodeproj/project.pbxproj | 43 +++++++++++-------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/examples/.gitignore b/examples/.gitignore index 2b8e1ead..33f184bc 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -16,6 +16,11 @@ build/* *.VC.db *.VC.VC.opendb +## Xcode cruft +.DS_Store +project.xcworkspace +xcuserdata + ## Unix executables example_glfw_opengl2/example_glfw_opengl2 example_glfw_opengl3/example_glfw_opengl3 diff --git a/examples/example_apple/imguiex.xcodeproj/project.pbxproj b/examples/example_apple/imguiex.xcodeproj/project.pbxproj index 3e5b0789..c41ba35a 100644 --- a/examples/example_apple/imguiex.xcodeproj/project.pbxproj +++ b/examples/example_apple/imguiex.xcodeproj/project.pbxproj @@ -7,6 +7,9 @@ objects = { /* Begin PBXBuildFile section */ + 07DB0B2E20E3767000FF57F1 /* imgui_impl_opengl2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07DB0B2B20E3767000FF57F1 /* imgui_impl_opengl2.cpp */; }; + 07DB0B2F20E3767000FF57F1 /* imgui_impl_glfw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07DB0B2D20E3767000FF57F1 /* imgui_impl_glfw.cpp */; }; + 07DB0B3120E3768400FF57F1 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07DB0B3020E3768400FF57F1 /* main.cpp */; }; 197E1E871B8943FE00E3FE6A /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 197E1E861B8943FE00E3FE6A /* imgui_draw.cpp */; }; 197E1E891B89443600E3FE6A /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 197E1E881B89443600E3FE6A /* imgui_demo.cpp */; }; 1A1A0F231CB39FB50090F036 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A1A0F221CB39FB50090F036 /* AppDelegate.m */; }; @@ -16,8 +19,6 @@ 1A1A0F321CB3A0DE0090F036 /* uSynergy.c in Sources */ = {isa = PBXBuildFile; fileRef = 6D1E39151B35EEF10017B40F /* uSynergy.c */; }; 1A1A0F331CB3A0E10090F036 /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 197E1E881B89443600E3FE6A /* imgui_demo.cpp */; }; 1A1A0F341CB3A0EC0090F036 /* debug_hud.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5891B2E6A5500C130BA /* debug_hud.cpp */; }; - 1A1A0F481CB3A2E50090F036 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1A0F391CB3A1B20090F036 /* main.cpp */; }; - 1A1A0F4A1CB3A5070090F036 /* imgui_impl_glfw_gl2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw_gl2.cpp */; }; 1A1A0F4E1CB3C54D0090F036 /* libglfw.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A1A0F4D1CB3C54D0090F036 /* libglfw.dylib */; }; 6D1E39171B35EEF10017B40F /* uSynergy.c in Sources */ = {isa = PBXBuildFile; fileRef = 6D1E39151B35EEF10017B40F /* uSynergy.c */; }; 6D2FC55A1B2E632000C130BA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5591B2E632000C130BA /* main.m */; }; @@ -36,6 +37,11 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 07DB0B2A20E3767000FF57F1 /* imgui_impl_glfw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_glfw.h; path = ../../imgui_impl_glfw.h; sourceTree = ""; }; + 07DB0B2B20E3767000FF57F1 /* imgui_impl_opengl2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_impl_opengl2.cpp; path = ../../imgui_impl_opengl2.cpp; sourceTree = ""; }; + 07DB0B2C20E3767000FF57F1 /* imgui_impl_opengl2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_opengl2.h; path = ../../imgui_impl_opengl2.h; sourceTree = ""; }; + 07DB0B2D20E3767000FF57F1 /* imgui_impl_glfw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_impl_glfw.cpp; path = ../../imgui_impl_glfw.cpp; sourceTree = ""; }; + 07DB0B3020E3768400FF57F1 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = ../../example_glfw_opengl2/main.cpp; sourceTree = ""; }; 197E1E861B8943FE00E3FE6A /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = ../../imgui_draw.cpp; sourceTree = ""; }; 197E1E881B89443600E3FE6A /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../../imgui_demo.cpp; sourceTree = ""; }; 1A1A0F1F1CB39FB50090F036 /* imguiex-osx.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "imguiex-osx.app"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -43,9 +49,6 @@ 1A1A0F221CB39FB50090F036 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 1A1A0F271CB39FB50090F036 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 1A1A0F2C1CB39FB50090F036 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw_gl2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = imgui_impl_glfw_gl2.cpp; sourceTree = ""; }; - 1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw_gl2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = imgui_impl_glfw_gl2.h; sourceTree = ""; }; - 1A1A0F391CB3A1B20090F036 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 1A1A0F4D1CB3C54D0090F036 /* libglfw.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libglfw.dylib; path = /usr/local/lib/libglfw.dylib; sourceTree = ""; }; 6D1E39151B35EEF10017B40F /* uSynergy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = uSynergy.c; sourceTree = ""; }; 6D1E39161B35EEF10017B40F /* uSynergy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uSynergy.h; sourceTree = ""; }; @@ -93,11 +96,23 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 07DB0B2920E3762C00FF57F1 /* example_glfw_gl2 */ = { + isa = PBXGroup; + children = ( + 07DB0B3020E3768400FF57F1 /* main.cpp */, + 07DB0B2D20E3767000FF57F1 /* imgui_impl_glfw.cpp */, + 07DB0B2A20E3767000FF57F1 /* imgui_impl_glfw.h */, + 07DB0B2B20E3767000FF57F1 /* imgui_impl_opengl2.cpp */, + 07DB0B2C20E3767000FF57F1 /* imgui_impl_opengl2.h */, + ); + name = example_glfw_gl2; + sourceTree = ""; + }; 1A1A0F201CB39FB50090F036 /* imguiex-osx */ = { isa = PBXGroup; children = ( + 07DB0B2920E3762C00FF57F1 /* example_glfw_gl2 */, 1A1A0F4D1CB3C54D0090F036 /* libglfw.dylib */, - 1A1A0F351CB3A1B20090F036 /* opengl2_example */, 1A1A0F211CB39FB50090F036 /* AppDelegate.h */, 1A1A0F221CB39FB50090F036 /* AppDelegate.m */, 1A1A0F271CB39FB50090F036 /* Assets.xcassets */, @@ -114,17 +129,6 @@ name = "Supporting Files"; sourceTree = ""; }; - 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = { - isa = PBXGroup; - children = ( - 1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw_gl2.cpp */, - 1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw_gl2.h */, - 1A1A0F391CB3A1B20090F036 /* main.cpp */, - ); - name = opengl2_example; - path = ../../opengl2_example; - sourceTree = ""; - }; 6D1E39141B35EEF10017B40F /* usynergy */ = { isa = PBXGroup; children = ( @@ -302,12 +306,13 @@ files = ( 1A1A0F301CB3A0DA0090F036 /* imgui_draw.cpp in Sources */, 1A1A0F311CB3A0DA0090F036 /* imgui.cpp in Sources */, + 07DB0B3120E3768400FF57F1 /* main.cpp in Sources */, 1A1A0F331CB3A0E10090F036 /* imgui_demo.cpp in Sources */, 1A1A0F341CB3A0EC0090F036 /* debug_hud.cpp in Sources */, - 1A1A0F481CB3A2E50090F036 /* main.cpp in Sources */, + 07DB0B2E20E3767000FF57F1 /* imgui_impl_opengl2.cpp in Sources */, 1A1A0F321CB3A0DE0090F036 /* uSynergy.c in Sources */, 1A1A0F231CB39FB50090F036 /* AppDelegate.m in Sources */, - 1A1A0F4A1CB3A5070090F036 /* imgui_impl_glfw_gl2.cpp in Sources */, + 07DB0B2F20E3767000FF57F1 /* imgui_impl_glfw.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 7adae3299edecdd278f98ac543896522b033a667 Mon Sep 17 00:00:00 2001 From: omar Date: Sat, 23 Jun 2018 12:00:12 +0200 Subject: [PATCH 02/12] Double-click on resize grip doesn't need to test HoveredWindow (as button has the flattenchild flag anyway) + double-click on title bar verify that we don't have overlapping items to allow contents in title bar. + Comments --- imgui.cpp | 7 +++++-- imgui.h | 4 ++-- imgui_internal.h | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 77a66f64..066a112b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5905,7 +5905,7 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au if (hovered || held) g.MouseCursor = (resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE; - if (g.HoveredWindow == window && held && g.IO.MouseDoubleClicked[0] && resize_grip_n == 0) + if (held && g.IO.MouseDoubleClicked[0] && resize_grip_n == 0) { // Manual auto-fit when double-clicking size_target = CalcSizeAfterConstraint(window, size_auto_fit); @@ -6159,8 +6159,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) // At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing if (!(flags & ImGuiWindowFlags_NoTitleBar) && !(flags & ImGuiWindowFlags_NoCollapse)) { + // We don't use a regular button+id to test for double-click on title bar (mostly due to legacy reason, could be fixed), so verify that we don't have items over the title bar. ImRect title_bar_rect = window->TitleBarRect(); - if (window->CollapseToggleWanted || (g.HoveredWindow == window && IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max) && g.IO.MouseDoubleClicked[0])) + if (g.HoveredWindow == window && g.HoveredId == 0 && g.HoveredIdPreviousFrame == 0 && IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max) && g.IO.MouseDoubleClicked[0]) + window->CollapseToggleWanted = true; + if (window->CollapseToggleWanted) { window->Collapsed = !window->Collapsed; MarkIniSettingsDirty(window); diff --git a/imgui.h b/imgui.h index 2f8f40f6..1ec1acc0 100644 --- a/imgui.h +++ b/imgui.h @@ -328,8 +328,8 @@ namespace ImGui IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding IMGUI_API bool Checkbox(const char* label, bool* v); IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value); - IMGUI_API bool RadioButton(const char* label, bool active); - IMGUI_API bool RadioButton(const char* label, int* v, int v_button); + IMGUI_API bool RadioButton(const char* label, bool active); // use with e.g. if (RadioButton("one", my_value==1)) { my_value = 1; } + IMGUI_API bool RadioButton(const char* label, int* v, int v_button); // shortcut to handle the above pattern when value is an integer IMGUI_API void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float)); IMGUI_API void PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0)); IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float)); diff --git a/imgui_internal.h b/imgui_internal.h index 16674ee2..04985143 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -953,7 +953,7 @@ struct IMGUI_API ImGuiWindow float WindowRounding; // Window rounding at the time of begin. float WindowBorderSize; // Window border size at the time of begin. ImGuiID MoveId; // == window->GetID("#MOVE") - ImGuiID ChildId; // Id of corresponding item in parent window (for child windows) + ImGuiID ChildId; // ID of corresponding item in parent window (for navigation to return from child window to parent window) ImVec2 Scroll; ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change) ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered From b16603745c9c8c0f8f4a1c5721f221e01aa7bcce Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 28 Jun 2018 11:33:03 +0200 Subject: [PATCH 03/12] Allow menu windows from ignoring the style.WindowMinSize values so short menus are not padded. (#1909) --- CHANGELOG.txt | 2 ++ imgui.cpp | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 32e9bdfe..ee623060 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -34,8 +34,10 @@ HOW TO UPDATE? ----------------------------------------------------------------------- Other Changes: + - ArrowButton: Fixed to honor PushButtonRepeat() setting (and internals' ImGuiItemFlags_ButtonRepeat). - ArrowButton: Setup current line text baseline so that ArrowButton() + SameLine() + Text() are aligned properly. + - Window: Allow menu windows from ignoring the style.WindowMinSize values so short menus are not padded. (#1909) ----------------------------------------------------------------------- diff --git a/imgui.cpp b/imgui.cpp index 066a112b..f08c73ef 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5775,7 +5775,10 @@ static ImVec2 CalcSizeAutoFit(ImGuiWindow* window, const ImVec2& size_contents) else { // When the window cannot fit all contents (either because of constraints, either because screen is too small): we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than DisplaySize-WindowPadding. - ImVec2 size_auto_fit = ImClamp(size_contents, style.WindowMinSize, ImMax(style.WindowMinSize, g.IO.DisplaySize - g.Style.DisplaySafeAreaPadding * 2.0f)); + ImVec2 size_min(0.0f, 0.0f); + if (!(window->Flags & ImGuiWindowFlags_ChildMenu)) + size_min = style.WindowMinSize; + ImVec2 size_auto_fit = ImClamp(size_contents, size_min, ImMax(size_min, g.IO.DisplaySize - style.DisplaySafeAreaPadding * 2.0f)); ImVec2 size_auto_fit_after_constraint = CalcSizeAfterConstraint(window, size_auto_fit); if (size_auto_fit_after_constraint.x < size_contents.x && !(window->Flags & ImGuiWindowFlags_NoScrollbar) && (window->Flags & ImGuiWindowFlags_HorizontalScrollbar)) size_auto_fit.y += style.ScrollbarSize; @@ -13877,9 +13880,10 @@ void ImGui::ShowMetricsWindow(bool* p_open) ImGuiWindowFlags flags = window->Flags; NodeDrawList(window, window->DrawList, "DrawList"); ImGui::BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), SizeContents (%.1f,%.1f)", window->Pos.x, window->Pos.y, window->Size.x, window->Size.y, window->SizeContents.x, window->SizeContents.y); - ImGui::BulletText("Flags: 0x%08X (%s%s%s%s%s%s..)", flags, + ImGui::BulletText("Flags: 0x%08X (%s%s%s%s%s%s%s..)", flags, (flags & ImGuiWindowFlags_ChildWindow) ? "Child " : "", (flags & ImGuiWindowFlags_Tooltip) ? "Tooltip " : "", (flags & ImGuiWindowFlags_Popup) ? "Popup " : "", - (flags & ImGuiWindowFlags_Modal) ? "Modal " : "", (flags & ImGuiWindowFlags_ChildMenu) ? "ChildMenu " : "", (flags & ImGuiWindowFlags_NoSavedSettings) ? "NoSavedSettings " : ""); + (flags & ImGuiWindowFlags_Modal) ? "Modal " : "", (flags & ImGuiWindowFlags_ChildMenu) ? "ChildMenu " : "", (flags & ImGuiWindowFlags_NoSavedSettings) ? "NoSavedSettings " : "", + (flags & ImGuiWindowFlags_AlwaysAutoResize) ? "AlwaysAutoResize" : ""); ImGui::BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f)", window->Scroll.x, GetScrollMaxX(window), window->Scroll.y, GetScrollMaxY(window)); ImGui::BulletText("Active: %d, WriteAccessed: %d", window->Active, window->WriteAccessed); ImGui::BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask); From 242d7e0b0bd7130c77afad1811833b9cc9bdee90 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 28 Jun 2018 18:37:38 +0200 Subject: [PATCH 04/12] ImVector: Added index_from_pointer() helper. --- imgui.h | 1 + 1 file changed, 1 insertion(+) diff --git a/imgui.h b/imgui.h index 1ec1acc0..12a2515b 100644 --- a/imgui.h +++ b/imgui.h @@ -1271,6 +1271,7 @@ public: inline iterator erase_unsorted(const_iterator it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; if (it < Data+Size-1) memcpy(Data + off, Data + Size - 1, sizeof(value_type)); Size--; return Data + off; } inline iterator insert(const_iterator it, const value_type& v) { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(value_type)); memcpy(&Data[off], &v, sizeof(v)); Size++; return Data + off; } inline bool contains(const value_type& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; } + inline int index_from_pointer(const_iterator it) const { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; return (int)off; } }; // Helper: IM_NEW(), IM_PLACEMENT_NEW(), IM_DELETE() macros to call MemAlloc + Placement New, Placement Delete + MemFree From 004fe8916a031c32daeb423532e2d8effeda18c4 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 28 Jun 2018 18:41:30 +0200 Subject: [PATCH 05/12] Internals: Settings: Simple optimization caching index into the settings buffer, to remove an unnecessary O(N*M) search during saving. (with N=active root windows during the session, M=stored settings which grows over time) --- imgui.cpp | 13 ++++++++++--- imgui_internal.h | 5 +++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index f08c73ef..60b60149 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2085,6 +2085,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name) LastFrameActive = -1; ItemWidthDefault = 0.0f; FontWindowScale = 1.0f; + SettingsIdx = -1; DrawList = &DrawListInst; DrawList->_OwnerName = Name; @@ -3876,9 +3877,14 @@ static void SettingsHandlerWindow_WriteAll(ImGuiContext* imgui_ctx, ImGuiSetting ImGuiWindow* window = g.Windows[i]; if (window->Flags & ImGuiWindowFlags_NoSavedSettings) continue; - ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID); + + ImGuiWindowSettings* settings = (window->SettingsIdx != -1) ? &g.SettingsWindows[window->SettingsIdx] : ImGui::FindWindowSettings(window->ID); if (!settings) + { settings = AddWindowSettings(window->Name); + window->SettingsIdx = g.SettingsWindows.index_from_pointer(settings); + } + IM_ASSERT(settings->ID == window->ID); settings->Pos = window->Pos; settings->Size = window->SizeFull; settings->Collapsed = window->Collapsed; @@ -3981,7 +3987,7 @@ ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id) { ImGuiContext& g = *GImGui; for (int i = 0; i != g.SettingsWindows.Size; i++) - if (g.SettingsWindows[i].Id == id) + if (g.SettingsWindows[i].ID == id) return &g.SettingsWindows[i]; return NULL; } @@ -3992,7 +3998,7 @@ static ImGuiWindowSettings* AddWindowSettings(const char* name) g.SettingsWindows.push_back(ImGuiWindowSettings()); ImGuiWindowSettings* settings = &g.SettingsWindows.back(); settings->Name = ImStrdup(name); - settings->Id = ImHash(name, 0); + settings->ID = ImHash(name, 0); return settings; } @@ -5695,6 +5701,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl // Retrieve settings from .ini file if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID)) { + window->SettingsIdx = g.SettingsWindows.index_from_pointer(settings); SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false); window->Pos = ImFloor(settings->Pos); window->Collapsed = settings->Collapsed; diff --git a/imgui_internal.h b/imgui_internal.h index 04985143..cc5c77c0 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -440,12 +440,12 @@ struct IMGUI_API ImGuiTextEditState struct ImGuiWindowSettings { char* Name; - ImGuiID Id; + ImGuiID ID; ImVec2 Pos; ImVec2 Size; bool Collapsed; - ImGuiWindowSettings() { Name = NULL; Id = 0; Pos = Size = ImVec2(0,0); Collapsed = false; } + ImGuiWindowSettings() { Name = NULL; ID = 0; Pos = Size = ImVec2(0,0); Collapsed = false; } }; struct ImGuiSettingsHandler @@ -994,6 +994,7 @@ struct IMGUI_API ImGuiWindow ImGuiStorage StateStorage; ImVector ColumnsStorage; float FontWindowScale; // User scale multiplier per-window + int SettingsIdx; // Index into SettingsWindow[] (indices are always valid as we only grow the array from the back) ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer) ImDrawList DrawListInst; From ecd9a223e3007cfd9b32f6a773d7796a1e1379c2 Mon Sep 17 00:00:00 2001 From: Aiekick Date: Fri, 29 Jun 2018 12:16:17 +0200 Subject: [PATCH 06/12] add hand cursor support (+11 squashed commit) --- examples/imgui_impl_glfw.cpp | 3 +- examples/imgui_impl_sdl.cpp | 1 + examples/imgui_impl_win32.cpp | 1 + imgui.h | 3 +- imgui_draw.cpp | 57 ++++++++++++++++++----------------- 5 files changed, 35 insertions(+), 30 deletions(-) diff --git a/examples/imgui_impl_glfw.cpp b/examples/imgui_impl_glfw.cpp index 39134383..bb9c66d9 100644 --- a/examples/imgui_impl_glfw.cpp +++ b/examples/imgui_impl_glfw.cpp @@ -155,7 +155,8 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw g_MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR); g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); // FIXME: GLFW doesn't have this. g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); // FIXME: GLFW doesn't have this. - + g_MouseCursors[ImGuiMouseCursor_Hand] = glfwCreateStandardCursor(GLFW_HAND_CURSOR); + if (install_callbacks) ImGui_ImplGlfw_InstallCallbacks(window); diff --git a/examples/imgui_impl_sdl.cpp b/examples/imgui_impl_sdl.cpp index 3fae6c7b..25dabe85 100644 --- a/examples/imgui_impl_sdl.cpp +++ b/examples/imgui_impl_sdl.cpp @@ -156,6 +156,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window) g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE); g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW); g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE); + g_MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND); #ifdef _WIN32 SDL_SysWMinfo wmInfo; diff --git a/examples/imgui_impl_win32.cpp b/examples/imgui_impl_win32.cpp index b966ea32..eb5de13e 100644 --- a/examples/imgui_impl_win32.cpp +++ b/examples/imgui_impl_win32.cpp @@ -104,6 +104,7 @@ static bool ImGui_ImplWin32_UpdateMouseCursor() case ImGuiMouseCursor_ResizeNS: win32_cursor = IDC_SIZENS; break; case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break; case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break; + case ImGuiMouseCursor_Hand: win32_cursor = IDC_HAND; break; } ::SetCursor(::LoadCursor(NULL, win32_cursor)); } diff --git a/imgui.h b/imgui.h index 12a2515b..900bedc4 100644 --- a/imgui.h +++ b/imgui.h @@ -336,7 +336,7 @@ namespace ImGui IMGUI_API void PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0)); IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-1,0), const char* overlay = NULL); IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses - + // Widgets: Combo Box // The new BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it. // The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. @@ -985,6 +985,7 @@ enum ImGuiMouseCursor_ ImGuiMouseCursor_ResizeEW, // When hovering over a vertical border or a column ImGuiMouseCursor_ResizeNESW, // When hovering over the bottom-left corner of a window ImGuiMouseCursor_ResizeNWSE, // When hovering over the bottom-right corner of a window + ImGuiMouseCursor_Hand, // When hoverinf over the HyperLink ImGuiMouseCursor_COUNT // Obsolete names (will be removed) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index cb1ed9d7..26002ca3 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1340,38 +1340,38 @@ ImFontConfig::ImFontConfig() // A work of art lies ahead! (. = white layer, X = black layer, others are blank) // The white texels on the top left are the ones we'll use everywhere in ImGui to render filled shapes. -const int FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF = 90; +const int FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF = 108; const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27; const unsigned int FONT_ATLAS_DEFAULT_TEX_DATA_ID = 0x80000000; static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] = { - "..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX" - "..- -X.....X- X.X - X.X -X.....X - X.....X" - "--- -XXX.XXX- X...X - X...X -X....X - X....X" - "X - X.X - X.....X - X.....X -X...X - X...X" - "XX - X.X -X.......X- X.......X -X..X.X - X.X..X" - "X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X" - "X..X - X.X - X.X - X.X -XX X.X - X.X XX" - "X...X - X.X - X.X - XX X.X XX - X.X - X.X " - "X....X - X.X - X.X - X.X X.X X.X - X.X - X.X " - "X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X " - "X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X " - "X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X " - "X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X " - "X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X " - "X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X " - "X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X " - "X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX " - "X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------" - "X.X X..X - -X.......X- X.......X - XX XX - " - "XX X..X - - X.....X - X.....X - X.X X.X - " - " X..X - X...X - X...X - X..X X..X - " - " XX - X.X - X.X - X...XXXXXXXXXXXXX...X - " - "------------ - X - X -X.....................X- " - " ----------------------------------- X...XXXXXXXXXXXXX...X - " - " - X..X X..X - " - " - X.X X.X - " - " - XX XX - " + "..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX- xx " + "..- -X.....X- X.X - X.X -X.....X - X.....X- x x " + "--- -XXX.XXX- X...X - X...X -X....X - X....X- x x " + "X - X.X - X.....X - X.....X -X...X - X...X- x x " + "XX - X.X -X.......X- X.......X -X..X.X - X.X..X- x x " + "X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X- x xxx " + "X..X - X.X - X.X - X.X -XX X.X - X.X XX- x x xxx " + "X...X - X.X - X.X - XX X.X XX - X.X - X.X - x x x xx " + "X....X - X.X - X.X - X.X X.X X.X - X.X - X.X - x x x x x " + "X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X -xxx x x x x x" + "X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X -x xx x x" + "X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X -x x x" + "X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X - x x" + "X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X - x x" + "X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X - x x" + "X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X - x x" + "X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX - x x " + "X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------- x x " + "X.X X..X - -X.......X- X.......X - XX XX - - x x " + "XX X..X - - X.....X - X.....X - X.X X.X - - x x " + " X..X - X...X - X...X - X..X X..X - - x x " + " XX - X.X - X.X - X...XXXXXXXXXXXXX...X - - xxxxxxxxxx " + "------------ - X - X -X.....................X- ------------------" + " ----------------------------------- X...XXXXXXXXXXXXX...X - " + " - X..X X..X - " + " - X.X X.X - " + " - XX XX - " }; static const ImVec2 FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[ImGuiMouseCursor_COUNT][3] = @@ -1384,6 +1384,7 @@ static const ImVec2 FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[ImGuiMouseCursor_COUNT][3 { ImVec2(55,18),ImVec2(23, 9), ImVec2(11, 5) }, // ImGuiMouseCursor_ResizeEW { ImVec2(73,0), ImVec2(17,17), ImVec2( 9, 9) }, // ImGuiMouseCursor_ResizeNESW { ImVec2(55,0), ImVec2(17,17), ImVec2( 9, 9) }, // ImGuiMouseCursor_ResizeNWSE + { ImVec2(91,0), ImVec2(17,22), ImVec2( 5, 0) }, // ImGuiMouseCursor_Hand }; ImFontAtlas::ImFontAtlas() From 62b3d7c51e87be48aa08d931453223f9348ccbf7 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 29 Jun 2018 16:30:41 +0200 Subject: [PATCH 07/12] Fixed software Hand cursor from not actually working. Fixed demo from crashing. Fixed typo and extraneous trailing space. Added Changelogs. (#1913, #1914) --- CHANGELOG.txt | 3 ++- examples/imgui_impl_glfw.cpp | 1 + examples/imgui_impl_sdl.cpp | 1 + examples/imgui_impl_win32.cpp | 1 + imgui.h | 6 ++--- imgui_demo.cpp | 2 +- imgui_draw.cpp | 44 +++++++++++++++++------------------ 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ee623060..9351713b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -38,7 +38,8 @@ Other Changes: - ArrowButton: Fixed to honor PushButtonRepeat() setting (and internals' ImGuiItemFlags_ButtonRepeat). - ArrowButton: Setup current line text baseline so that ArrowButton() + SameLine() + Text() are aligned properly. - Window: Allow menu windows from ignoring the style.WindowMinSize values so short menus are not padded. (#1909) - + - Misc: Added ImGuiMouseCursor_Hand cursor enum + corresponding software cursor. (#1913, 1914) [@aiekick, @ocornut] + - Examples: Win32, Glfw, SDL: Added support for the ImGuiMouseCursor_Hand cursor. ----------------------------------------------------------------------- VERSION 1.62 (Released 2018-06-22) diff --git a/examples/imgui_impl_glfw.cpp b/examples/imgui_impl_glfw.cpp index bb9c66d9..a51e5db9 100644 --- a/examples/imgui_impl_glfw.cpp +++ b/examples/imgui_impl_glfw.cpp @@ -14,6 +14,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor. // 2018-06-08: Misc: Extracted imgui_impl_glfw.cpp/.h away from the old combined GLFW+OpenGL/Vulkan examples. // 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag. // 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value, passed to glfwSetCursor()). diff --git a/examples/imgui_impl_sdl.cpp b/examples/imgui_impl_sdl.cpp index 25dabe85..19d67e34 100644 --- a/examples/imgui_impl_sdl.cpp +++ b/examples/imgui_impl_sdl.cpp @@ -15,6 +15,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor. // 2018-06-08: Misc: Extracted imgui_impl_sdl.cpp/.h away from the old combined SDL2+OpenGL/Vulkan examples. // 2018-06-08: Misc: ImGui_ImplSDL2_InitForOpenGL() now takes a SDL_GLContext parameter. // 2018-05-09: Misc: Fixed clipboard paste memory leak (we didn't call SDL_FreeMemory on the data returned by SDL_GetClipboardText). diff --git a/examples/imgui_impl_win32.cpp b/examples/imgui_impl_win32.cpp index eb5de13e..bfbc5db4 100644 --- a/examples/imgui_impl_win32.cpp +++ b/examples/imgui_impl_win32.cpp @@ -13,6 +13,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor. // 2018-06-10: Inputs: Fixed handling of mouse wheel messages to support fine position messages (typically sent by track-pads). // 2018-06-08: Misc: Extracted imgui_impl_win32.cpp/.h away from the old combined DX9/DX10/DX11/DX12 examples. // 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors and ImGuiBackendFlags_HasSetMousePos flags + honor ImGuiConfigFlags_NoMouseCursorChange flag. diff --git a/imgui.h b/imgui.h index 900bedc4..6463ec2e 100644 --- a/imgui.h +++ b/imgui.h @@ -336,7 +336,7 @@ namespace ImGui IMGUI_API void PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0)); IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-1,0), const char* overlay = NULL); IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses - + // Widgets: Combo Box // The new BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it. // The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. @@ -980,12 +980,12 @@ enum ImGuiMouseCursor_ ImGuiMouseCursor_None = -1, ImGuiMouseCursor_Arrow = 0, ImGuiMouseCursor_TextInput, // When hovering over InputText, etc. - ImGuiMouseCursor_ResizeAll, // Unused by imgui functions + ImGuiMouseCursor_ResizeAll, // (Unused by imgui functions) ImGuiMouseCursor_ResizeNS, // When hovering over an horizontal border ImGuiMouseCursor_ResizeEW, // When hovering over a vertical border or a column ImGuiMouseCursor_ResizeNESW, // When hovering over the bottom-left corner of a window ImGuiMouseCursor_ResizeNWSE, // When hovering over the bottom-right corner of a window - ImGuiMouseCursor_Hand, // When hoverinf over the HyperLink + ImGuiMouseCursor_Hand, // (Unused by imgui functions. Use for e.g. hyperlinks) ImGuiMouseCursor_COUNT // Obsolete names (will be removed) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index a8c41dce..04c6dcea 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -2157,7 +2157,7 @@ void ImGui::ShowDemoWindow(bool* p_open) if (ImGui::TreeNode("Mouse cursors")) { - const char* mouse_cursors_names[] = { "Arrow", "TextInput", "Move", "ResizeNS", "ResizeEW", "ResizeNESW", "ResizeNWSE" }; + const char* mouse_cursors_names[] = { "Arrow", "TextInput", "Move", "ResizeNS", "ResizeEW", "ResizeNESW", "ResizeNWSE", "Hand" }; IM_ASSERT(IM_ARRAYSIZE(mouse_cursors_names) == ImGuiMouseCursor_COUNT); ImGui::Text("Current mouse cursor = %d: %s", ImGui::GetMouseCursor(), mouse_cursors_names[ImGui::GetMouseCursor()]); diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 26002ca3..131e48d5 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1345,28 +1345,28 @@ const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27; const unsigned int FONT_ATLAS_DEFAULT_TEX_DATA_ID = 0x80000000; static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] = { - "..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX- xx " - "..- -X.....X- X.X - X.X -X.....X - X.....X- x x " - "--- -XXX.XXX- X...X - X...X -X....X - X....X- x x " - "X - X.X - X.....X - X.....X -X...X - X...X- x x " - "XX - X.X -X.......X- X.......X -X..X.X - X.X..X- x x " - "X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X- x xxx " - "X..X - X.X - X.X - X.X -XX X.X - X.X XX- x x xxx " - "X...X - X.X - X.X - XX X.X XX - X.X - X.X - x x x xx " - "X....X - X.X - X.X - X.X X.X X.X - X.X - X.X - x x x x x " - "X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X -xxx x x x x x" - "X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X -x xx x x" - "X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X -x x x" - "X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X - x x" - "X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X - x x" - "X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X - x x" - "X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X - x x" - "X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX - x x " - "X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------- x x " - "X.X X..X - -X.......X- X.......X - XX XX - - x x " - "XX X..X - - X.....X - X.....X - X.X X.X - - x x " - " X..X - X...X - X...X - X..X X..X - - x x " - " XX - X.X - X.X - X...XXXXXXXXXXXXX...X - - xxxxxxxxxx " + "..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX- XX " + "..- -X.....X- X.X - X.X -X.....X - X.....X- X..X " + "--- -XXX.XXX- X...X - X...X -X....X - X....X- X..X " + "X - X.X - X.....X - X.....X -X...X - X...X- X..X " + "XX - X.X -X.......X- X.......X -X..X.X - X.X..X- X..X " + "X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X- X..XXX " + "X..X - X.X - X.X - X.X -XX X.X - X.X XX- X..X..XXX " + "X...X - X.X - X.X - XX X.X XX - X.X - X.X - X..X..X..XX " + "X....X - X.X - X.X - X.X X.X X.X - X.X - X.X - X..X..X..X.X " + "X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X -XXX X..X..X..X..X" + "X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X -X..XX........X..X" + "X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X -X...X...........X" + "X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X - X..............X" + "X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X - X.............X" + "X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X - X.............X" + "X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X - X............X" + "X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX - X...........X " + "X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------- X..........X " + "X.X X..X - -X.......X- X.......X - XX XX - - X..........X " + "XX X..X - - X.....X - X.....X - X.X X.X - - X........X " + " X..X - X...X - X...X - X..X X..X - - X........X " + " XX - X.X - X.X - X...XXXXXXXXXXXXX...X - - XXXXXXXXXX " "------------ - X - X -X.....................X- ------------------" " ----------------------------------- X...XXXXXXXXXXXXX...X - " " - X..X X..X - " From 6e67afc50006aa2f4759d819399537493c549fd6 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 29 Jun 2018 16:32:52 +0200 Subject: [PATCH 08/12] Tweaked software mouse cursor offset to match the offset of the corresponding Windows 10 cursors. (followup to #1914) --- CHANGELOG.txt | 1 + imgui_draw.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 9351713b..636adce5 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -39,6 +39,7 @@ Other Changes: - ArrowButton: Setup current line text baseline so that ArrowButton() + SameLine() + Text() are aligned properly. - Window: Allow menu windows from ignoring the style.WindowMinSize values so short menus are not padded. (#1909) - Misc: Added ImGuiMouseCursor_Hand cursor enum + corresponding software cursor. (#1913, 1914) [@aiekick, @ocornut] + - Misc: Tweaked software mouse cursor offset to match the offset of the corresponding Windows 10 cursors. - Examples: Win32, Glfw, SDL: Added support for the ImGuiMouseCursor_Hand cursor. ----------------------------------------------------------------------- diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 131e48d5..74330e4b 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1377,13 +1377,13 @@ static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA static const ImVec2 FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[ImGuiMouseCursor_COUNT][3] = { // Pos ........ Size ......... Offset ...... - { ImVec2(0,3), ImVec2(12,19), ImVec2( 0, 0) }, // ImGuiMouseCursor_Arrow - { ImVec2(13,0), ImVec2(7,16), ImVec2( 4, 8) }, // ImGuiMouseCursor_TextInput + { ImVec2( 0,3), ImVec2(12,19), ImVec2( 0, 0) }, // ImGuiMouseCursor_Arrow + { ImVec2(13,0), ImVec2( 7,16), ImVec2( 1, 8) }, // ImGuiMouseCursor_TextInput { ImVec2(31,0), ImVec2(23,23), ImVec2(11,11) }, // ImGuiMouseCursor_ResizeAll - { ImVec2(21,0), ImVec2( 9,23), ImVec2( 5,11) }, // ImGuiMouseCursor_ResizeNS - { ImVec2(55,18),ImVec2(23, 9), ImVec2(11, 5) }, // ImGuiMouseCursor_ResizeEW - { ImVec2(73,0), ImVec2(17,17), ImVec2( 9, 9) }, // ImGuiMouseCursor_ResizeNESW - { ImVec2(55,0), ImVec2(17,17), ImVec2( 9, 9) }, // ImGuiMouseCursor_ResizeNWSE + { ImVec2(21,0), ImVec2( 9,23), ImVec2( 4,11) }, // ImGuiMouseCursor_ResizeNS + { ImVec2(55,18),ImVec2(23, 9), ImVec2(11, 4) }, // ImGuiMouseCursor_ResizeEW + { ImVec2(73,0), ImVec2(17,17), ImVec2( 8, 8) }, // ImGuiMouseCursor_ResizeNESW + { ImVec2(55,0), ImVec2(17,17), ImVec2( 8, 8) }, // ImGuiMouseCursor_ResizeNWSE { ImVec2(91,0), ImVec2(17,22), ImVec2( 5, 0) }, // ImGuiMouseCursor_Hand }; From b62cc5c150bed6f8958789d73286efe093c3b730 Mon Sep 17 00:00:00 2001 From: codecnotsupported Date: Sat, 30 Jun 2018 10:53:36 +0200 Subject: [PATCH 09/12] Fix include Example_glfw_vulkan cmake (#1916) Probably got broken because of the refactor. --- examples/example_glfw_vulkan/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_glfw_vulkan/CMakeLists.txt b/examples/example_glfw_vulkan/CMakeLists.txt index f9adc77e..60fe5718 100644 --- a/examples/example_glfw_vulkan/CMakeLists.txt +++ b/examples/example_glfw_vulkan/CMakeLists.txt @@ -20,7 +20,7 @@ include_directories(${GLFW_DIR}/include) # ImGui set(IMGUI_DIR ../../) -include_directories(${IMGUI_DIR}) +include_directories(${IMGUI_DIR} ..) # Libraries find_library(VULKAN_LIBRARY From c4e34aaace0de2112031b626350279f75c311c90 Mon Sep 17 00:00:00 2001 From: omar Date: Sat, 30 Jun 2018 14:33:45 +0200 Subject: [PATCH 10/12] Examples: Comments to clarify how the keyboard data is indexed. --- examples/imgui_impl_glfw.cpp | 1 + examples/imgui_impl_glfw.h | 1 + examples/imgui_impl_sdl.cpp | 1 + examples/imgui_impl_sdl.h | 1 + examples/imgui_impl_win32.cpp | 1 + examples/imgui_impl_win32.h | 1 + 6 files changed, 6 insertions(+) diff --git a/examples/imgui_impl_glfw.cpp b/examples/imgui_impl_glfw.cpp index a51e5db9..c7ec4beb 100644 --- a/examples/imgui_impl_glfw.cpp +++ b/examples/imgui_impl_glfw.cpp @@ -6,6 +6,7 @@ // [X] Platform: Clipboard support. // [X] Platform: Gamepad navigation mapping. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW. +// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE). // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. // If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). diff --git a/examples/imgui_impl_glfw.h b/examples/imgui_impl_glfw.h index b1e3617d..229df383 100644 --- a/examples/imgui_impl_glfw.h +++ b/examples/imgui_impl_glfw.h @@ -6,6 +6,7 @@ // [X] Platform: Clipboard support. // [X] Platform: Gamepad navigation mapping. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW. +// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE). // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. // If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). diff --git a/examples/imgui_impl_sdl.cpp b/examples/imgui_impl_sdl.cpp index 19d67e34..4fdb1c9c 100644 --- a/examples/imgui_impl_sdl.cpp +++ b/examples/imgui_impl_sdl.cpp @@ -5,6 +5,7 @@ // Implemented features: // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. // [X] Platform: Clipboard support. +// [X] Platform: Keyboard arrays indexed using SDL_SCANCODE_* codes, e.g. ImGui::IsKeyPressed(SDL_SCANCODE_SPACE). // Missing features: // [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME. diff --git a/examples/imgui_impl_sdl.h b/examples/imgui_impl_sdl.h index f0bc4e9a..367697d7 100644 --- a/examples/imgui_impl_sdl.h +++ b/examples/imgui_impl_sdl.h @@ -5,6 +5,7 @@ // Implemented features: // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. // [X] Platform: Clipboard support. +// [X] Platform: Keyboard arrays indexed using SDL_SCANCODE_* codes, e.g. ImGui::IsKeyPressed(SDL_SCANCODE_SPACE). // Missing features: // [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME. diff --git a/examples/imgui_impl_win32.cpp b/examples/imgui_impl_win32.cpp index bfbc5db4..86873084 100644 --- a/examples/imgui_impl_win32.cpp +++ b/examples/imgui_impl_win32.cpp @@ -4,6 +4,7 @@ // Implemented features: // [X] Platform: Clipboard support (for Win32 this is actually part of core imgui) // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. +// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). #include "imgui.h" #include "imgui_impl_win32.h" diff --git a/examples/imgui_impl_win32.h b/examples/imgui_impl_win32.h index 98c97d89..f50e6542 100644 --- a/examples/imgui_impl_win32.h +++ b/examples/imgui_impl_win32.h @@ -4,6 +4,7 @@ // Implemented features: // [X] Platform: Clipboard support (for Win32 this is actually part of core imgui) // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. +// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd); IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown(); From 645ab6633c10b34313f733c910765f03610ee258 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 1 Jul 2018 12:25:37 +0200 Subject: [PATCH 11/12] Fixed a include build issue for Cygwin in non-POSIX (Win32) mode. (#1917, #1319, #276) --- CHANGELOG.txt | 1 + imgui_draw.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 636adce5..64f399ca 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -40,6 +40,7 @@ Other Changes: - Window: Allow menu windows from ignoring the style.WindowMinSize values so short menus are not padded. (#1909) - Misc: Added ImGuiMouseCursor_Hand cursor enum + corresponding software cursor. (#1913, 1914) [@aiekick, @ocornut] - Misc: Tweaked software mouse cursor offset to match the offset of the corresponding Windows 10 cursors. + - Fixed a include build issue for Cygwin in non-POSIX (Win32) mode. (#1917, #1319, #276) - Examples: Win32, Glfw, SDL: Added support for the ImGuiMouseCursor_Hand cursor. ----------------------------------------------------------------------- diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 74330e4b..5ab40ac9 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -19,13 +19,13 @@ #include // vsnprintf, sscanf, printf #if !defined(alloca) -#ifdef _WIN32 +#if defined(__GLIBC__) || defined(__sun) || defined(__CYGWIN__) +#include // alloca (glibc uses . Note that Cygwin may have _WIN32 defined, so the order matters here) +#elif defined(_WIN32) #include // alloca #if !defined(alloca) #define alloca _alloca // for clang with MS Codegen #endif -#elif defined(__GLIBC__) || defined(__sun) -#include // alloca #else #include // alloca #endif From ddb09c6011665fab66bc0d5540346eb1bb68db73 Mon Sep 17 00:00:00 2001 From: Konstantin Podsvirov Date: Mon, 2 Jul 2018 20:43:33 +0300 Subject: [PATCH 12/12] Examples: Ignore all *.user files (#1919) For example `Qt Creator` create `CMakeLists.txt.user` file with user settings. --- examples/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/.gitignore b/examples/.gitignore index 33f184bc..d5786ab8 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -6,7 +6,7 @@ build/* *.opensdf *.sdf *.suo -*.vcxproj.user +*.user *.o *.obj *.exe