From 10e13dd6bb90d2afac906a42f000f9065e2465fa Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 3 Dec 2018 12:19:23 +0100 Subject: [PATCH 1/6] Version 1.67 WIP (again, this time IMGUI_VERSION_NUM has leeway for another hot-fix). --- docs/CHANGELOG.txt | 9 +++++++++ imgui.cpp | 2 +- imgui.h | 2 +- imgui_demo.cpp | 2 +- imgui_draw.cpp | 2 +- imgui_internal.h | 2 +- imgui_widgets.cpp | 2 +- 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index cc084e7c..92bc9aca 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -29,6 +29,15 @@ HOW TO UPDATE? - Please report any issue! +----------------------------------------------------------------------- + VERSION 1.67 (In Progress) +----------------------------------------------------------------------- + +Breaking Changes: + +Other Changes: + + ----------------------------------------------------------------------- VERSION 1.66b (Released 2018-12-01) ----------------------------------------------------------------------- diff --git a/imgui.cpp b/imgui.cpp index b1436391..d809cfb6 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.66b +// dear imgui, v1.67 WIP // (main code and documentation) // Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code. diff --git a/imgui.h b/imgui.h index 39fc616d..203eadf7 100644 --- a/imgui.h +++ b/imgui.h @@ -1,4 +1,4 @@ -// dear imgui, v1.66b +// dear imgui, v1.67 WIP // (headers) // See imgui.cpp file for documentation. diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 41483b38..b71d6262 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.66b +// dear imgui, v1.67 WIP // (demo code) // Message to the person tempted to delete this file when integrating Dear ImGui into their code base: diff --git a/imgui_draw.cpp b/imgui_draw.cpp index ef154306..5346ad51 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.66b +// dear imgui, v1.67 WIP // (drawing and font code) /* diff --git a/imgui_internal.h b/imgui_internal.h index b3f107df..0039d271 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1,4 +1,4 @@ -// dear imgui, v1.66b +// dear imgui, v1.67 WIP // (internal structures/api) // You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility! diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 95a30376..792d80f0 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.66b +// dear imgui, v1.67 WIP // (widgets code) /* From 8d58055a5433e1227ebb5e3b8dba80bb00cc239a Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 3 Dec 2018 17:47:10 +0100 Subject: [PATCH 2/6] Examples: DirectX10/11/12: Made imgui_impl_dx10/dx11/dx12.cpp link d3dcompiler.lib from the .cpp file to ease integration. --- docs/CHANGELOG.txt | 2 ++ examples/imgui_impl_dx10.cpp | 4 ++++ examples/imgui_impl_dx11.cpp | 4 ++++ examples/imgui_impl_dx12.cpp | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 92bc9aca..7ca7f6b8 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -36,6 +36,8 @@ HOW TO UPDATE? Breaking Changes: Other Changes: +- Examples: DirectX10/11/12: Made imgui_impl_dx10/dx11/dx12.cpp link d3dcompiler.lib from the .cpp file + to ease integration. ----------------------------------------------------------------------- diff --git a/examples/imgui_impl_dx10.cpp b/examples/imgui_impl_dx10.cpp index f394d61b..ed28f3de 100644 --- a/examples/imgui_impl_dx10.cpp +++ b/examples/imgui_impl_dx10.cpp @@ -10,6 +10,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile(). // 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. // 2018-07-13: DirectX10: Fixed unreleased resources in Init and Shutdown functions. // 2018-06-08: Misc: Extracted imgui_impl_dx10.cpp/.h away from the old combined DX10+Win32 example. @@ -27,6 +28,9 @@ #include #include #include +#ifdef _MSC_VER +#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below. +#endif // DirectX data static ID3D10Device* g_pd3dDevice = NULL; diff --git a/examples/imgui_impl_dx11.cpp b/examples/imgui_impl_dx11.cpp index eaef797b..6fd36d62 100644 --- a/examples/imgui_impl_dx11.cpp +++ b/examples/imgui_impl_dx11.cpp @@ -10,6 +10,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile(). // 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. // 2018-08-01: DirectX11: Querying for IDXGIFactory instead of IDXGIFactory1 to increase compatibility. // 2018-07-13: DirectX11: Fixed unreleased resources in Init and Shutdown functions. @@ -26,6 +27,9 @@ #include #include #include +#ifdef _MSC_VER +#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below. +#endif // DirectX data static ID3D11Device* g_pd3dDevice = NULL; diff --git a/examples/imgui_impl_dx12.cpp b/examples/imgui_impl_dx12.cpp index 46d0b8f3..490d9e65 100644 --- a/examples/imgui_impl_dx12.cpp +++ b/examples/imgui_impl_dx12.cpp @@ -12,6 +12,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile(). // 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. // 2018-06-12: DirectX12: Moved the ID3D12GraphicsCommandList* parameter from NewFrame() to RenderDrawData(). // 2018-06-08: Misc: Extracted imgui_impl_dx12.cpp/.h away from the old combined DX12+Win32 example. @@ -25,6 +26,9 @@ #include #include #include +#ifdef _MSC_VER +#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below. +#endif // DirectX data static ID3D12Device* g_pd3dDevice = NULL; From eb311abc92b3c4b18a6b680a5a87f5b53d960b08 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 3 Dec 2018 17:49:38 +0100 Subject: [PATCH 3/6] Fixed IMGUI_API tag on ImFontAtlas::IsBuilt() preventing to build as DLL on some setups. (#2226) --- imgui.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui.h b/imgui.h index 203eadf7..8e695c5f 100644 --- a/imgui.h +++ b/imgui.h @@ -1903,9 +1903,9 @@ struct ImFontAtlas // Building in RGBA32 format is provided for convenience and compatibility, but note that unless you manually manipulate or copy color data into // the texture (e.g. when using the AddCustomRect*** api), then the RGB pixels emitted will always be white (~75% of memory/bandwidth waste. IMGUI_API bool Build(); // Build pixels data. This is called automatically for you by the GetTexData*** functions. - IMGUI_API bool IsBuilt() { return Fonts.Size > 0 && (TexPixelsAlpha8 != NULL || TexPixelsRGBA32 != NULL); } IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel + bool IsBuilt() { return Fonts.Size > 0 && (TexPixelsAlpha8 != NULL || TexPixelsRGBA32 != NULL); } void SetTexID(ImTextureID id) { TexID = id; } //------------------------------------------- From 3e84f7cd1dc01e86794f3386510d9b6772028e4f Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 3 Dec 2018 18:16:35 +0100 Subject: [PATCH 4/6] Viewport: Fixed a viewport bug which led some popups to merge in underlying host viewport when they should be z-over their parent viewport. --- docs/TODO.txt | 2 +- imgui.cpp | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/TODO.txt b/docs/TODO.txt index edc053a9..c8d77637 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -287,7 +287,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - viewport: with platform decoration enabled, platform may force constraint (e.g. minimum size) - viewport: use getfocus/setfocus api to synchronize imgui<>platform focus better (e.g imgui-side ctrl-tab can focus os window, OS initial setup and alt-tab can focus imgui window etc.) - viewport: store per-viewport/monitor DPI in .ini file so an application reload or main window changing DPI on reload can be properly patched for. - - viewport: implicit Debug window can hog a zombie viewport (harmless, noisy?) > could at least clear out the reference on a per session basis? + - viewport: implicit/fallback Debug window can hog a zombie viewport (harmless, noisy?) > could at least clear out the reference on a per session basis? - viewport: need to clarify how to use GetMousePos() from a user point of view. - platform: glfw: no support for ImGuiBackendFlags_HasMouseHoveredViewport. - platform: sdl: no support for ImGuiBackendFlags_HasMouseHoveredViewport. maybe we could use SDL_GetMouseFocus() / SDL_WINDOW_MOUSE_FOCUS if imgui could fallback on its heuristic when NoInputs is set diff --git a/imgui.cpp b/imgui.cpp index 63104638..3c4c20fa 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7487,10 +7487,6 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window) return; } - // Merge into host viewport - bool try_to_merge_into_host_viewport = false; - if (window->ViewportOwned && g.ActiveId == 0) - try_to_merge_into_host_viewport = true; window->ViewportOwned = false; // Appearing popups reset their viewport so they can inherit again @@ -7541,6 +7537,9 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window) } else { + // Merge into host viewport? + // We cannot test window->ViewportOwned as it set lower in the function. + bool try_to_merge_into_host_viewport = (window->Viewport && window == window->Viewport->Window && g.ActiveId == 0); if (try_to_merge_into_host_viewport) UpdateTryMergeWindowIntoHostViewport(window, g.Viewports[0]); } @@ -7594,7 +7593,7 @@ void ImGui::UpdatePlatformWindows() { ImGuiViewportP* viewport = g.Viewports[i]; - // Destroy platform window if the viewport hasn't been submitted or if it is hosting a hidden window (the implicit Debug window will be registered its viewport then be disabled) + // Destroy platform window if the viewport hasn't been submitted or if it is hosting a hidden window (the implicit/fallback Debug window will be registered its viewport then be disabled) bool destroy_platform_window = false; destroy_platform_window |= (viewport->LastFrameActive < g.FrameCount - 1); destroy_platform_window |= (viewport->Window && !IsWindowActiveAndVisible(viewport->Window)); From f6b6ad1959b9478806333afd14071850fd61e0ad Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 3 Dec 2018 20:28:32 +0100 Subject: [PATCH 5/6] Viewport: Minor tweaks, better struct layout. --- imgui.cpp | 6 +++--- imgui.h | 4 ++-- imgui_internal.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 3c4c20fa..7d0351f1 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7165,7 +7165,7 @@ void ImGui::SetCurrentViewport(ImGuiWindow* current_window, ImGuiViewportP* view /* if (viewport->LastFrameActive < g.FrameCount && viewport->Window != current_window && viewport->Window != NULL && current_window != NULL) { - //printf("[%05d] Window '%s' steal Viewport %08X from Window '%s'\n", g.FrameCount, current_window->Name, viewport->ID, viewport->Window->Name); + //IMGUI_DEBUG_LOG("[%05d] Window '%s' steal Viewport %08X from Window '%s'\n", g.FrameCount, current_window->Name, viewport->ID, viewport->Window->Name); viewport->Window = current_window; viewport->ID = current_window->ID; } @@ -7327,7 +7327,7 @@ static void ImGui::UpdateViewports() } // Update monitor (we'll use this info to clamp windows and save windows lost in a removed monitor) - viewport->PlatformMonitor = FindPlatformMonitorForRect(viewport->GetRect()); + viewport->PlatformMonitor = (short)FindPlatformMonitorForRect(viewport->GetRect()); } // Reset alpha every frame. Users of transparency will need to request a lower alpha back. @@ -7446,7 +7446,7 @@ ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const viewport->Idx = g.Viewports.Size; viewport->Pos = viewport->LastPos = pos; viewport->Size = size; - viewport->PlatformMonitor = FindPlatformMonitorForRect(viewport->GetRect()); + viewport->PlatformMonitor = (short)FindPlatformMonitorForRect(viewport->GetRect()); g.Viewports.push_back(viewport); //IMGUI_DEBUG_LOG("Add Viewport %08X (%s)\n", id, window->Name); diff --git a/imgui.h b/imgui.h index 9db67ebf..ae7bac6e 100644 --- a/imgui.h +++ b/imgui.h @@ -2162,14 +2162,14 @@ struct ImGuiViewport float DpiScale; // 1.0f = 96 DPI = No extra scale ImDrawData* DrawData; // The ImDrawData corresponding to this viewport. Valid after Render() and until the next call to NewFrame(). + void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, frame-buffers etc.) void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context) void* PlatformHandle; // void* for FindViewportByPlatformHandle(). (e.g. suggested to use natural platform handle such as HWND, GlfwWindow*, SDL_Window*) bool PlatformRequestClose; // Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4) bool PlatformRequestMove; // Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position) bool PlatformRequestResize; // Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size) - void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, frame-buffers etc.) - ImGuiViewport() { ID = 0; Flags = 0; DpiScale = 0.0f; DrawData = NULL; PlatformUserData = PlatformHandle = NULL; PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; RendererUserData = NULL; } + ImGuiViewport() { ID = 0; Flags = 0; DpiScale = 0.0f; DrawData = NULL; RendererUserData = PlatformUserData = PlatformHandle = NULL; PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; } ~ImGuiViewport() { IM_ASSERT(PlatformUserData == NULL && RendererUserData == NULL); } }; diff --git a/imgui_internal.h b/imgui_internal.h index 6c158f70..a6ea650a 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -644,7 +644,7 @@ struct ImGuiViewportP : public ImGuiViewport ImVec2 LastPos; float Alpha; // Window opacity (when dragging dockable windows/viewports we make them transparent) float LastAlpha; - int PlatformMonitor; + short PlatformMonitor; bool PlatformWindowCreated; bool PlatformWindowMinimized; ImGuiWindow* Window; // Set when the viewport is owned by a window @@ -655,7 +655,7 @@ struct ImGuiViewportP : public ImGuiViewport ImVec2 LastPlatformSize; ImVec2 LastRendererSize; - ImGuiViewportP() { Idx = -1; LastFrameActive = LastFrameOverlayDrawList = LastFrontMostStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; PlatformMonitor = INT_MIN; PlatformWindowCreated = PlatformWindowMinimized = false; Window = NULL; OverlayDrawList = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); } + ImGuiViewportP() { Idx = -1; LastFrameActive = LastFrameOverlayDrawList = LastFrontMostStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; PlatformMonitor = -1; PlatformWindowCreated = PlatformWindowMinimized = false; Window = NULL; OverlayDrawList = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); } ~ImGuiViewportP() { if (OverlayDrawList) IM_DELETE(OverlayDrawList); } ImRect GetRect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); } ImVec2 GetCenter() const{ return ImVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); } From fb6ef8b1db8bb281195475743577b75225d00160 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 3 Dec 2018 18:17:50 +0100 Subject: [PATCH 6/6] Comments, tweak --- imgui.cpp | 5 +++-- imgui_demo.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index d809cfb6..76e66d6e 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3299,8 +3299,9 @@ void ImGui::NewFrame() g.CurrentPopupStack.resize(0); ClosePopupsOverWindow(g.NavWindow); - // Create implicit window - we will only render it if the user has added something to it. + // Create implicit/fallback window - which we will only render it if the user has added something to it. // We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags. + // This fallback is particularly important as it avoid ImGui:: calls from crashing. SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver); Begin("Debug##Default"); @@ -4455,7 +4456,7 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au ImGuiWindowFlags flags = window->Flags; if ((flags & ImGuiWindowFlags_NoResize) || (flags & ImGuiWindowFlags_AlwaysAutoResize) || window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) return; - if (window->WasActive == false) // Early out to avoid running this code for e.g. an hidden implicit Debug window. + if (window->WasActive == false) // Early out to avoid running this code for e.g. an hidden implicit/fallback Debug window. return; const int resize_border_count = g.IO.ConfigResizeWindowsFromEdges ? 4 : 0; diff --git a/imgui_demo.cpp b/imgui_demo.cpp index b71d6262..1571bda1 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -199,7 +199,7 @@ void ImGui::ShowDemoWindow(bool* p_open) if (show_app_metrics) { ImGui::ShowMetricsWindow(&show_app_metrics); } if (show_app_style_editor) { ImGui::Begin("Style Editor", &show_app_style_editor); ImGui::ShowStyleEditor(); ImGui::End(); } - if (show_app_about) { ShowAboutWindow(&show_app_about); } + if (show_app_about) { ImGui::ShowAboutWindow(&show_app_about); } // Demonstrate the various window flags. Typically you would just use the default! static bool no_titlebar = false; @@ -2459,7 +2459,7 @@ static void ShowDemoWindowMisc() void ImGui::ShowAboutWindow(bool* p_open) { ImGui::Begin("About Dear ImGui", p_open, ImGuiWindowFlags_AlwaysAutoResize); - ImGui::Text("Dear ImGui, %s", ImGui::GetVersion()); + ImGui::Text("Dear ImGui %s", ImGui::GetVersion()); ImGui::Separator(); ImGui::Text("By Omar Cornut and all dear imgui contributors."); ImGui::Text("Dear ImGui is licensed under the MIT License, see LICENSE for more information.");