From 7c6fa8f8f71007d2dfed4e2be66af9ff9c7edcec Mon Sep 17 00:00:00 2001 From: PTSVU Date: Tue, 19 Aug 2025 12:48:59 +0300 Subject: [PATCH 01/13] Backends: SDL_GPU: add swapchain parameters to ImGui_ImplSDLGPU3_InitInfo. (#8892) (master branch commit, values are not used) --- backends/imgui_impl_sdlgpu3.cpp | 1 + backends/imgui_impl_sdlgpu3.h | 10 ++++++---- examples/example_sdl3_sdlgpu3/main.cpp | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/backends/imgui_impl_sdlgpu3.cpp b/backends/imgui_impl_sdlgpu3.cpp index c2f465136..61056718d 100644 --- a/backends/imgui_impl_sdlgpu3.cpp +++ b/backends/imgui_impl_sdlgpu3.cpp @@ -22,6 +22,7 @@ // Calling the function is MANDATORY, otherwise the ImGui will not upload neither the vertex nor the index buffer for the GPU. See imgui_impl_sdlgpu3.cpp for more info. // CHANGELOG +// 2025-08-20: Added SwapchainComposition::SwapchainComposition and SwapchainComposition::PresentMode to configure how secondary viewports are created. // 2025-08-08: *BREAKING* Changed ImTextureID type from SDL_GPUTextureSamplerBinding* to SDL_GPUTexture*, which is more natural and easier for user to manage. If you need to change the current sampler, you can access the ImGui_ImplSDLGPU3_RenderState struct. (#8866, #8163, #7998, #7988) // 2025-08-08: Expose SamplerDefault and SamplerCurrent in ImGui_ImplSDLGPU3_RenderState. Allow callback to change sampler. // 2025-06-25: Mapping transfer buffer for texture update use cycle=true. Fixes artifacts e.g. on Metal backend. diff --git a/backends/imgui_impl_sdlgpu3.h b/backends/imgui_impl_sdlgpu3.h index 1ab3a5a84..cde9c5fe7 100644 --- a/backends/imgui_impl_sdlgpu3.h +++ b/backends/imgui_impl_sdlgpu3.h @@ -27,12 +27,14 @@ #include // Initialization data, for ImGui_ImplSDLGPU_Init() -// - Remember to set ColorTargetFormat to the correct format. If you're rendering to the swapchain, call SDL_GetGPUSwapchainTextureFormat to query the right value +// - Remember to set ColorTargetFormat to the correct format. If you're rendering to the swapchain, call SDL_GetGPUSwapchainTextureFormat() to query the right value struct ImGui_ImplSDLGPU3_InitInfo { - SDL_GPUDevice* Device = nullptr; - SDL_GPUTextureFormat ColorTargetFormat = SDL_GPU_TEXTUREFORMAT_INVALID; - SDL_GPUSampleCount MSAASamples = SDL_GPU_SAMPLECOUNT_1; + SDL_GPUDevice* Device = nullptr; + SDL_GPUTextureFormat ColorTargetFormat = SDL_GPU_TEXTUREFORMAT_INVALID; + SDL_GPUSampleCount MSAASamples = SDL_GPU_SAMPLECOUNT_1; + SDL_GPUSwapchainComposition SwapchainComposition = SDL_GPU_SWAPCHAINCOMPOSITION_SDR; // Only used in multi-viewports mode. + SDL_GPUPresentMode PresentMode = SDL_GPU_PRESENTMODE_VSYNC; // Only used in multi-viewports mode. }; // Follow "Getting Started" link and check examples/ folder to learn about using backends! diff --git a/examples/example_sdl3_sdlgpu3/main.cpp b/examples/example_sdl3_sdlgpu3/main.cpp index 380b8c574..1566cf368 100644 --- a/examples/example_sdl3_sdlgpu3/main.cpp +++ b/examples/example_sdl3_sdlgpu3/main.cpp @@ -83,7 +83,9 @@ int main(int, char**) ImGui_ImplSDLGPU3_InitInfo init_info = {}; init_info.Device = gpu_device; init_info.ColorTargetFormat = SDL_GetGPUSwapchainTextureFormat(gpu_device, window); - init_info.MSAASamples = SDL_GPU_SAMPLECOUNT_1; + init_info.MSAASamples = SDL_GPU_SAMPLECOUNT_1; // Only used in multi-viewports mode. + init_info.SwapchainComposition = SDL_GPU_SWAPCHAINCOMPOSITION_SDR; // Only used in multi-viewports mode. + init_info.PresentMode = SDL_GPU_PRESENTMODE_VSYNC; ImGui_ImplSDLGPU3_Init(&init_info); // Load Fonts From 515c0b526f144f72d00e60a3c1decb7912b226a6 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 20 Aug 2025 18:53:25 +0200 Subject: [PATCH 02/13] Backends: SDL_GPU: typo + changelog. (#8892) --- backends/imgui_impl_sdlgpu3.cpp | 2 +- docs/CHANGELOG.txt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backends/imgui_impl_sdlgpu3.cpp b/backends/imgui_impl_sdlgpu3.cpp index 61056718d..8420da4c5 100644 --- a/backends/imgui_impl_sdlgpu3.cpp +++ b/backends/imgui_impl_sdlgpu3.cpp @@ -22,7 +22,7 @@ // Calling the function is MANDATORY, otherwise the ImGui will not upload neither the vertex nor the index buffer for the GPU. See imgui_impl_sdlgpu3.cpp for more info. // CHANGELOG -// 2025-08-20: Added SwapchainComposition::SwapchainComposition and SwapchainComposition::PresentMode to configure how secondary viewports are created. +// 2025-08-20: Added ImGui_ImplSDLGPU3_InitInfo::SwapchainComposition and ImGui_ImplSDLGPU3_InitInfo::PresentMode to configure how secondary viewports are created. // 2025-08-08: *BREAKING* Changed ImTextureID type from SDL_GPUTextureSamplerBinding* to SDL_GPUTexture*, which is more natural and easier for user to manage. If you need to change the current sampler, you can access the ImGui_ImplSDLGPU3_RenderState struct. (#8866, #8163, #7998, #7988) // 2025-08-08: Expose SamplerDefault and SamplerCurrent in ImGui_ImplSDLGPU3_RenderState. Allow callback to change sampler. // 2025-06-25: Mapping transfer buffer for texture update use cycle=true. Fixes artifacts e.g. on Metal backend. diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index b126e5f15..073a37b6b 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -48,6 +48,9 @@ Other Changes: - DrawList: Fixed CloneOutput() unnecessarily taking a copy of the ImDrawListSharedData pointer, which could to issue when deleting the cloned list. (#8894, #1860) - Examples: Android: Android+OpenGL3: update Gradle project (#8888, #8878) [@scribam] +- Backends: SDL_GPU: Added ImGui_ImplSDLGPU3_InitInfo::SwapchainComposition and + PresentMode to configure how secondary viewports are created. Currently only used + in multi-viewport mode. (#8892) ----------------------------------------------------------------------- From fe0303511292491e9ec1802b7eadfc5f805c9d86 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 20 Aug 2025 19:58:19 +0200 Subject: [PATCH 03/13] Docs: advertise ProggyVector font as an alternative. --- docs/FONTS.md | 11 +++++++---- examples/example_allegro5/main.cpp | 2 +- examples/example_android_opengl3/main.cpp | 2 +- examples/example_apple_metal/main.mm | 2 +- examples/example_apple_opengl2/main.mm | 2 +- examples/example_glfw_metal/main.mm | 2 +- examples/example_glfw_opengl2/main.cpp | 2 +- examples/example_glfw_opengl3/main.cpp | 2 +- examples/example_glfw_vulkan/main.cpp | 2 +- examples/example_glfw_wgpu/main.cpp | 2 +- examples/example_glut_opengl2/main.cpp | 2 +- examples/example_sdl2_directx11/main.cpp | 2 +- examples/example_sdl2_metal/main.mm | 2 +- examples/example_sdl2_opengl2/main.cpp | 2 +- examples/example_sdl2_opengl3/main.cpp | 2 +- examples/example_sdl2_sdlrenderer2/main.cpp | 2 +- examples/example_sdl2_vulkan/main.cpp | 2 +- examples/example_sdl3_metal/main.mm | 2 +- examples/example_sdl3_opengl3/main.cpp | 2 +- examples/example_sdl3_sdlgpu3/main.cpp | 2 +- examples/example_sdl3_sdlrenderer3/main.cpp | 2 +- examples/example_sdl3_vulkan/main.cpp | 2 +- examples/example_win32_directx10/main.cpp | 2 +- examples/example_win32_directx11/main.cpp | 2 +- examples/example_win32_directx12/main.cpp | 2 +- examples/example_win32_directx9/main.cpp | 2 +- examples/example_win32_opengl3/main.cpp | 2 +- examples/example_win32_vulkan/main.cpp | 2 +- imgui_draw.cpp | 2 ++ 29 files changed, 36 insertions(+), 31 deletions(-) diff --git a/docs/FONTS.md b/docs/FONTS.md index 3fa7fd19c..072ca9762 100644 --- a/docs/FONTS.md +++ b/docs/FONTS.md @@ -587,15 +587,18 @@ Some fonts files are available in the `misc/fonts/` folder: #### MONOSPACE FONTS +image + Pixel Perfect: - Proggy Fonts, by Tristan Grimmer http://www.proggyfonts.net or http://upperboundsinteractive.com/fonts.php - Sweet16, Sweet16 Mono, by Martin Sedlak (Latin + Supplemental + Extended A) https://github.com/kmar/Sweet16Font (also include an .inl file to use directly in dear imgui.) Regular: -- Google Noto Mono Fonts https://www.google.com/get/noto/ -- Typefaces for source code beautification https://github.com/chrissimpkins/codeface -- Programmation fonts http://s9w.github.io/font_compare/ -- Inconsolata http://www.levien.com/type/myfonts/inconsolata.html +- ProggyVector if you want the old school Dear ImGui font to scale: https://github.com/bluescan/proggyfonts +- Google Noto Mono Fonts: https://www.google.com/get/noto/ +- Typefaces for source code beautification: https://github.com/chrissimpkins/codeface +- Programmation fonts: http://s9w.github.io/font_compare/ +- Inconsolata: http://www.levien.com/type/myfonts/inconsolata.html - Adobe Source Code Pro: Monospaced font family for ui & coding environments https://github.com/adobe-fonts/source-code-pro - Monospace/Fixed Width Programmer's Fonts http://www.lowing.org/fonts/ diff --git a/examples/example_allegro5/main.cpp b/examples/example_allegro5/main.cpp index 02db84a48..cde2c676a 100644 --- a/examples/example_allegro5/main.cpp +++ b/examples/example_allegro5/main.cpp @@ -53,7 +53,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_android_opengl3/main.cpp b/examples/example_android_opengl3/main.cpp index 452cb77d9..568d6f02b 100644 --- a/examples/example_android_opengl3/main.cpp +++ b/examples/example_android_opengl3/main.cpp @@ -154,7 +154,7 @@ void Init(struct android_app* app) // Load Fonts // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! // - Android: The TTF files have to be placed into the assets/ directory (android/app/src/main/assets), we use our GetAssetData() helper to retrieve them. diff --git a/examples/example_apple_metal/main.mm b/examples/example_apple_metal/main.mm index 301a2b4ad..0349dfbdc 100644 --- a/examples/example_apple_metal/main.mm +++ b/examples/example_apple_metal/main.mm @@ -73,7 +73,7 @@ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_apple_opengl2/main.mm b/examples/example_apple_opengl2/main.mm index c3f0c313b..9b4fa1860 100644 --- a/examples/example_apple_opengl2/main.mm +++ b/examples/example_apple_opengl2/main.mm @@ -61,7 +61,7 @@ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_glfw_metal/main.mm b/examples/example_glfw_metal/main.mm index ef314702a..9f4b82c4f 100644 --- a/examples/example_glfw_metal/main.mm +++ b/examples/example_glfw_metal/main.mm @@ -43,7 +43,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_glfw_opengl2/main.cpp b/examples/example_glfw_opengl2/main.cpp index 83fcab65f..411a5891d 100644 --- a/examples/example_glfw_opengl2/main.cpp +++ b/examples/example_glfw_opengl2/main.cpp @@ -66,7 +66,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_glfw_opengl3/main.cpp b/examples/example_glfw_opengl3/main.cpp index 4bd7bc591..6dfeacb96 100644 --- a/examples/example_glfw_opengl3/main.cpp +++ b/examples/example_glfw_opengl3/main.cpp @@ -106,7 +106,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! // - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details. //style.FontSizeBase = 20.0f; diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp index 19766b9f3..7ad9778f1 100644 --- a/examples/example_glfw_vulkan/main.cpp +++ b/examples/example_glfw_vulkan/main.cpp @@ -418,7 +418,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_glfw_wgpu/main.cpp b/examples/example_glfw_wgpu/main.cpp index c150b5961..e30df5662 100644 --- a/examples/example_glfw_wgpu/main.cpp +++ b/examples/example_glfw_wgpu/main.cpp @@ -115,7 +115,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! // - Emscripten allows preloading a file or folder to be accessible at runtime. See Makefile for details. //io.Fonts->AddFontDefault(); diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp index 69f85a245..e72b94830 100644 --- a/examples/example_glut_opengl2/main.cpp +++ b/examples/example_glut_opengl2/main.cpp @@ -84,7 +84,7 @@ int main(int argc, char** argv) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_sdl2_directx11/main.cpp b/examples/example_sdl2_directx11/main.cpp index 194dd0e03..2e347752f 100644 --- a/examples/example_sdl2_directx11/main.cpp +++ b/examples/example_sdl2_directx11/main.cpp @@ -94,7 +94,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_sdl2_metal/main.mm b/examples/example_sdl2_metal/main.mm index c1750b16b..97a643759 100644 --- a/examples/example_sdl2_metal/main.mm +++ b/examples/example_sdl2_metal/main.mm @@ -34,7 +34,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_sdl2_opengl2/main.cpp b/examples/example_sdl2_opengl2/main.cpp index c8363fece..7385f4cd1 100644 --- a/examples/example_sdl2_opengl2/main.cpp +++ b/examples/example_sdl2_opengl2/main.cpp @@ -83,7 +83,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_sdl2_opengl3/main.cpp b/examples/example_sdl2_opengl3/main.cpp index 16a73deb6..c59836f6e 100644 --- a/examples/example_sdl2_opengl3/main.cpp +++ b/examples/example_sdl2_opengl3/main.cpp @@ -123,7 +123,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! // - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details. //style.FontSizeBase = 20.0f; diff --git a/examples/example_sdl2_sdlrenderer2/main.cpp b/examples/example_sdl2_sdlrenderer2/main.cpp index e456b2e9e..76f17d3f6 100644 --- a/examples/example_sdl2_sdlrenderer2/main.cpp +++ b/examples/example_sdl2_sdlrenderer2/main.cpp @@ -85,7 +85,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_sdl2_vulkan/main.cpp b/examples/example_sdl2_vulkan/main.cpp index 300543fba..de6745623 100644 --- a/examples/example_sdl2_vulkan/main.cpp +++ b/examples/example_sdl2_vulkan/main.cpp @@ -430,7 +430,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_sdl3_metal/main.mm b/examples/example_sdl3_metal/main.mm index 50c33c82d..98c4a9490 100644 --- a/examples/example_sdl3_metal/main.mm +++ b/examples/example_sdl3_metal/main.mm @@ -81,7 +81,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_sdl3_opengl3/main.cpp b/examples/example_sdl3_opengl3/main.cpp index cfd6f6a1a..25b6b1937 100644 --- a/examples/example_sdl3_opengl3/main.cpp +++ b/examples/example_sdl3_opengl3/main.cpp @@ -113,7 +113,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! // - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details. //style.FontSizeBase = 20.0f; diff --git a/examples/example_sdl3_sdlgpu3/main.cpp b/examples/example_sdl3_sdlgpu3/main.cpp index 1566cf368..bef16fe5b 100644 --- a/examples/example_sdl3_sdlgpu3/main.cpp +++ b/examples/example_sdl3_sdlgpu3/main.cpp @@ -93,7 +93,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_sdl3_sdlrenderer3/main.cpp b/examples/example_sdl3_sdlrenderer3/main.cpp index 6e39429d2..f98986943 100644 --- a/examples/example_sdl3_sdlrenderer3/main.cpp +++ b/examples/example_sdl3_sdlrenderer3/main.cpp @@ -75,7 +75,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! // - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details. //style.FontSizeBase = 20.0f; diff --git a/examples/example_sdl3_vulkan/main.cpp b/examples/example_sdl3_vulkan/main.cpp index df7f5efbd..743e68dba 100644 --- a/examples/example_sdl3_vulkan/main.cpp +++ b/examples/example_sdl3_vulkan/main.cpp @@ -429,7 +429,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_win32_directx10/main.cpp b/examples/example_win32_directx10/main.cpp index 23033d6c1..12f10ab4d 100644 --- a/examples/example_win32_directx10/main.cpp +++ b/examples/example_win32_directx10/main.cpp @@ -76,7 +76,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_win32_directx11/main.cpp b/examples/example_win32_directx11/main.cpp index c80114cfb..2b85895f7 100644 --- a/examples/example_win32_directx11/main.cpp +++ b/examples/example_win32_directx11/main.cpp @@ -76,7 +76,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_win32_directx12/main.cpp b/examples/example_win32_directx12/main.cpp index 3a9ba4fb4..4ff7c54e5 100644 --- a/examples/example_win32_directx12/main.cpp +++ b/examples/example_win32_directx12/main.cpp @@ -170,7 +170,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_win32_directx9/main.cpp b/examples/example_win32_directx9/main.cpp index 430a2b448..66369d242 100644 --- a/examples/example_win32_directx9/main.cpp +++ b/examples/example_win32_directx9/main.cpp @@ -74,7 +74,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_win32_opengl3/main.cpp b/examples/example_win32_opengl3/main.cpp index 6b88497c0..8748ab777 100644 --- a/examples/example_win32_opengl3/main.cpp +++ b/examples/example_win32_opengl3/main.cpp @@ -76,7 +76,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/examples/example_win32_vulkan/main.cpp b/examples/example_win32_vulkan/main.cpp index a98f16fe2..aa80e8696 100644 --- a/examples/example_win32_vulkan/main.cpp +++ b/examples/example_win32_vulkan/main.cpp @@ -409,7 +409,7 @@ int main(int, char**) // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. - // - Read 'docs/FONTS.md' for more instructions and details. + // - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 0426d4a2e..3ef76efec 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3097,6 +3097,7 @@ static const char* GetDefaultCompressedFontDataTTF(int* out_size); #endif // Load embedded ProggyClean.ttf at size 13, disable oversampling +// If you want a similar font which may be better scaled, consider using ProggyVector from the same author! ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template) { #ifndef IMGUI_DISABLE_DEFAULT_FONT @@ -6118,6 +6119,7 @@ static unsigned int stb_decompress(unsigned char *output, const unsigned char *i // Copyright (c) 2004, 2005 Tristan Grimmer // MIT license (see License.txt in http://www.proggyfonts.net/index.php?menu=download) // Download and more information at http://www.proggyfonts.net or http://upperboundsinteractive.com/fonts.php +// If you want a similar font which may be better scaled, consider using ProggyVector from the same author! //----------------------------------------------------------------------------- #ifndef IMGUI_DISABLE_DEFAULT_FONT From e728b966003104c7fc21a007237bca10abf39b19 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 20 Aug 2025 20:22:31 +0200 Subject: [PATCH 04/13] Fixed Bullet() fixed tesselation amount which looked out of place in very large sizes. --- docs/CHANGELOG.txt | 3 ++- imgui_draw.cpp | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 073a37b6b..e053076f8 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -45,12 +45,13 @@ Other Changes: - Scrollbar, Style: added configurable style.ScrollbarPadding value and corresponding ImGuiStyleVar_ScrollbarPadding enum, instead of hardcoded computed default. (#8895) +- Fixed Bullet() fixed tesselation amount which looked out of place in very large sizes. - DrawList: Fixed CloneOutput() unnecessarily taking a copy of the ImDrawListSharedData pointer, which could to issue when deleting the cloned list. (#8894, #1860) - Examples: Android: Android+OpenGL3: update Gradle project (#8888, #8878) [@scribam] - Backends: SDL_GPU: Added ImGui_ImplSDLGPU3_InitInfo::SwapchainComposition and PresentMode to configure how secondary viewports are created. Currently only used - in multi-viewport mode. (#8892) + multi-viewport mode. (#8892) [@PTSVU] ----------------------------------------------------------------------- diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 3ef76efec..31beb4133 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -5835,8 +5835,9 @@ void ImGui::RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir d void ImGui::RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col) { - // FIXME-OPT: This should be baked in font. - draw_list->AddCircleFilled(pos, draw_list->_Data->FontSize * 0.20f, col, 8); + // FIXME-OPT: This should be baked in font now that it's easier. + float font_size = draw_list->_Data->FontSize; + draw_list->AddCircleFilled(pos, font_size * 0.20f, col, (font_size < 22) ? 8 : (font_size < 40) ? 12 : 0); // Hardcode optimal/nice tessellation threshold } void ImGui::RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz) From 783f1e62cc122f8bc5a76b068e366c38b9dca71c Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 26 Aug 2025 15:36:56 +0200 Subject: [PATCH 05/13] Debug Tools: ID Stack Tool: fixed using fixed-size buffers preventing long identifiers from being displayed in the tool. (#8905, #4631) --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 59 ++++++++++++++++++++++++++-------------------- imgui_internal.h | 9 +++---- 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index e053076f8..1e52af5fd 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -48,6 +48,8 @@ Other Changes: - Fixed Bullet() fixed tesselation amount which looked out of place in very large sizes. - DrawList: Fixed CloneOutput() unnecessarily taking a copy of the ImDrawListSharedData pointer, which could to issue when deleting the cloned list. (#8894, #1860) +- Debug Tools: ID Stack Tool: fixed using fixed-size buffers preventing long identifiers + from being displayed in the tool. (#8905, #4631) - Examples: Android: Android+OpenGL3: update Gradle project (#8888, #8878) [@scribam] - Backends: SDL_GPU: Added ImGui_ImplSDLGPU3_InitInfo::SwapchainComposition and PresentMode to configure how secondary viewports are created. Currently only used diff --git a/imgui.cpp b/imgui.cpp index 8b201ee76..5a16e5d08 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -17645,6 +17645,7 @@ void ImGui::UpdateDebugToolStackQueries() tool->QueryId = query_id; tool->StackLevel = -1; tool->Results.resize(0); + tool->ResultPathsBuf.resize(0); } if (query_id == 0) return; @@ -17691,37 +17692,43 @@ void ImGui::DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* dat ImGuiStackLevelInfo* info = &tool->Results[tool->StackLevel]; IM_ASSERT(info->ID == id && info->QueryFrameCount > 0); - switch (data_type) + if (info->DescOffset == -1) { - case ImGuiDataType_S32: - ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "%d", (int)(intptr_t)data_id); - break; - case ImGuiDataType_String: - ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "%.*s", data_id_end ? (int)((const char*)data_id_end - (const char*)data_id) : (int)ImStrlen((const char*)data_id), (const char*)data_id); - break; - case ImGuiDataType_Pointer: - ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "(void*)0x%p", data_id); - break; - case ImGuiDataType_ID: - if (info->Desc[0] != 0) // PushOverrideID() is often used to avoid hashing twice, which would lead to 2 calls to DebugHookIdInfo(). We prioritize the first one. - return; - ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "0x%08X [override]", id); - break; - default: - IM_ASSERT(0); + const char* result = NULL; + const char* result_end = NULL; + switch (data_type) + { + case ImGuiDataType_S32: + ImFormatStringToTempBuffer(&result, &result_end, "%d", (int)(intptr_t)data_id); + break; + case ImGuiDataType_String: + ImFormatStringToTempBuffer(&result, &result_end, "%.*s", data_id_end ? (int)((const char*)data_id_end - (const char*)data_id) : (int)ImStrlen((const char*)data_id), (const char*)data_id); + break; + case ImGuiDataType_Pointer: + ImFormatStringToTempBuffer(&result, &result_end, "(void*)0x%p", data_id); + break; + case ImGuiDataType_ID: + // PushOverrideID() is often used to avoid hashing twice, which would lead to 2 calls to DebugHookIdInfo(). We prioritize the first one. + ImFormatStringToTempBuffer(&result, &result_end, "0x%08X [override]", id); + break; + default: + IM_ASSERT(0); + } + info->DescOffset = tool->ResultPathsBuf.size(); + tool->ResultPathsBuf.append(result, result_end + 1); // Include zero terminator } info->QuerySuccess = true; - info->DataType = data_type; + info->DataType = (ImS8)data_type; } static int StackToolFormatLevelInfo(ImGuiIDStackTool* tool, int n, bool format_for_ui, char* buf, size_t buf_size) { ImGuiStackLevelInfo* info = &tool->Results[n]; - ImGuiWindow* window = (info->Desc[0] == 0 && n == 0) ? ImGui::FindWindowByID(info->ID) : NULL; + ImGuiWindow* window = (info->DescOffset == -1 && n == 0) ? ImGui::FindWindowByID(info->ID) : NULL; if (window) // Source: window name (because the root ID don't call GetID() and so doesn't get hooked) return ImFormatString(buf, buf_size, format_for_ui ? "\"%s\" [window]" : "%s", window->Name); if (info->QuerySuccess) // Source: GetID() hooks (prioritize over ItemInfo() because we frequently use patterns like: PushID(str), Button("") where they both have same id) - return ImFormatString(buf, buf_size, (format_for_ui && info->DataType == ImGuiDataType_String) ? "\"%s\"" : "%s", info->Desc); + return ImFormatString(buf, buf_size, (format_for_ui && info->DataType == ImGuiDataType_String) ? "\"%s\"" : "%s", &tool->ResultPathsBuf.Buf[info->DescOffset]); if (tool->StackLevel < tool->Results.Size) // Only start using fallback below when all queries are done, so during queries we don't flickering ??? markers. return (*buf = 0); #ifdef IMGUI_ENABLE_TEST_ENGINE @@ -17747,17 +17754,17 @@ void ImGui::ShowIDStackToolWindow(bool* p_open) ImGuiIDStackTool* tool = &g.DebugIDStackTool; // Build and display path - tool->ResultPathBuf.resize(0); + tool->ResultTempBuf.resize(0); for (int stack_n = 0; stack_n < tool->Results.Size; stack_n++) { char level_desc[256]; StackToolFormatLevelInfo(tool, stack_n, false, level_desc, IM_ARRAYSIZE(level_desc)); - tool->ResultPathBuf.append(stack_n == 0 ? "//" : "/"); + tool->ResultTempBuf.append(stack_n == 0 ? "//" : "/"); for (int n = 0; level_desc[n]; n++) { if (level_desc[n] == '/') - tool->ResultPathBuf.append("\\"); - tool->ResultPathBuf.append(level_desc + n, level_desc + n + 1); + tool->ResultTempBuf.append("\\"); + tool->ResultTempBuf.append(level_desc + n, level_desc + n + 1); } } Text("0x%08X", tool->QueryId); @@ -17773,10 +17780,10 @@ void ImGui::ShowIDStackToolWindow(bool* p_open) if (tool->CopyToClipboardOnCtrlC && Shortcut(ImGuiMod_Ctrl | ImGuiKey_C, ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused)) { tool->CopyToClipboardLastTime = (float)g.Time; - SetClipboardText(tool->ResultPathBuf.c_str()); + SetClipboardText(tool->ResultTempBuf.c_str()); } - Text("- Path \"%s\"", tool->ResultPathBuf.c_str()); + Text("- Path \"%s\"", tool->ResultTempBuf.c_str()); #ifdef IMGUI_ENABLE_TEST_ENGINE Text("- Label \"%s\"", tool->QueryId ? ImGuiTestEngine_FindItemDebugLabel(&g, tool->QueryId) : ""); #endif diff --git a/imgui_internal.h b/imgui_internal.h index b2a675e8d..ee4c75d18 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -2095,10 +2095,10 @@ struct ImGuiStackLevelInfo ImGuiID ID; ImS8 QueryFrameCount; // >= 1: Query in progress bool QuerySuccess; // Obtained result from DebugHookIdInfo() - ImGuiDataType DataType : 8; - char Desc[57]; // Arbitrarily sized buffer to hold a result (FIXME: could replace Results[] with a chunk stream?) FIXME: Now that we added CTRL+C this should be fixed. + ImS8 DataType; // ImGuiDataType + int DescOffset; // -1 or offset into parent's ResultPathsBuf - ImGuiStackLevelInfo() { memset(this, 0, sizeof(*this)); } + ImGuiStackLevelInfo() { memset(this, 0, sizeof(*this)); DescOffset = -1; } }; // State for ID Stack tool queries @@ -2110,7 +2110,8 @@ struct ImGuiIDStackTool ImVector Results; bool CopyToClipboardOnCtrlC; float CopyToClipboardLastTime; - ImGuiTextBuffer ResultPathBuf; + ImGuiTextBuffer ResultPathsBuf; + ImGuiTextBuffer ResultTempBuf; ImGuiIDStackTool() { memset(this, 0, sizeof(*this)); CopyToClipboardLastTime = -FLT_MAX; } }; From 9e864012ae15568877f7157da2be552fb26ed7c8 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 26 Aug 2025 15:58:59 +0200 Subject: [PATCH 06/13] Debug Tools: ID Stack Tool: added option to hex-encode non-ASCII characters in output path. (#8904, #4631) --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 19 ++++++++++++++----- imgui_internal.h | 5 +++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 1e52af5fd..28e4ab272 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -50,6 +50,8 @@ Other Changes: pointer, which could to issue when deleting the cloned list. (#8894, #1860) - Debug Tools: ID Stack Tool: fixed using fixed-size buffers preventing long identifiers from being displayed in the tool. (#8905, #4631) +- Debug Tools: ID Stack Tool: added option to hex-encode non-ASCII characters in + output path. (#8904, #4631) - Examples: Android: Android+OpenGL3: update Gradle project (#8888, #8878) [@scribam] - Backends: SDL_GPU: Added ImGui_ImplSDLGPU3_InitInfo::SwapchainComposition and PresentMode to configure how secondary viewports are created. Currently only used diff --git a/imgui.cpp b/imgui.cpp index 5a16e5d08..0d4bd99a9 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -17760,11 +17760,17 @@ void ImGui::ShowIDStackToolWindow(bool* p_open) char level_desc[256]; StackToolFormatLevelInfo(tool, stack_n, false, level_desc, IM_ARRAYSIZE(level_desc)); tool->ResultTempBuf.append(stack_n == 0 ? "//" : "/"); - for (int n = 0; level_desc[n]; n++) + for (const char* p = level_desc; *p != 0; ) { - if (level_desc[n] == '/') + unsigned int c; + const char* p_next = p + ImTextCharFromUtf8(&c, p, NULL); + if (c == '/') tool->ResultTempBuf.append("\\"); - tool->ResultTempBuf.append(level_desc + n, level_desc + n + 1); + if (c < 256 || !tool->OptHexEncodeNonAsciiChars) + tool->ResultTempBuf.append(p, p_next); + else for (; p < p_next; p++) + tool->ResultTempBuf.appendf("\\x%02x", (unsigned char)*p); + p = p_next; } } Text("0x%08X", tool->QueryId); @@ -17773,11 +17779,14 @@ void ImGui::ShowIDStackToolWindow(bool* p_open) // CTRL+C to copy path const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime; + PushStyleVarY(ImGuiStyleVar_FramePadding, 0.0f); + Checkbox("Hex-encode non-ASCII", &tool->OptHexEncodeNonAsciiChars); SameLine(); - PushStyleVarY(ImGuiStyleVar_FramePadding, 0.0f); Checkbox("Ctrl+C: copy path", &tool->CopyToClipboardOnCtrlC); PopStyleVar(); + Checkbox("Ctrl+C: copy path", &tool->OptCopyToClipboardOnCtrlC); + PopStyleVar(); SameLine(); TextColored((time_since_copy >= 0.0f && time_since_copy < 0.75f && ImFmod(time_since_copy, 0.25f) < 0.25f * 0.5f) ? ImVec4(1.f, 1.f, 0.3f, 1.f) : ImVec4(), "*COPIED*"); - if (tool->CopyToClipboardOnCtrlC && Shortcut(ImGuiMod_Ctrl | ImGuiKey_C, ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused)) + if (tool->OptCopyToClipboardOnCtrlC && Shortcut(ImGuiMod_Ctrl | ImGuiKey_C, ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused)) { tool->CopyToClipboardLastTime = (float)g.Time; SetClipboardText(tool->ResultTempBuf.c_str()); diff --git a/imgui_internal.h b/imgui_internal.h index ee4c75d18..1b21a8fcd 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -2108,12 +2108,13 @@ struct ImGuiIDStackTool int StackLevel; // -1: query stack and resize Results, >= 0: individual stack level ImGuiID QueryId; // ID to query details for ImVector Results; - bool CopyToClipboardOnCtrlC; + bool OptHexEncodeNonAsciiChars; + bool OptCopyToClipboardOnCtrlC; float CopyToClipboardLastTime; ImGuiTextBuffer ResultPathsBuf; ImGuiTextBuffer ResultTempBuf; - ImGuiIDStackTool() { memset(this, 0, sizeof(*this)); CopyToClipboardLastTime = -FLT_MAX; } + ImGuiIDStackTool() { memset(this, 0, sizeof(*this)); OptHexEncodeNonAsciiChars = true; CopyToClipboardLastTime = -FLT_MAX; } }; //----------------------------------------------------------------------------- From 75a4a48d1fdb5fb80045b4be6ea81a505e02af84 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 26 Aug 2025 16:19:08 +0200 Subject: [PATCH 07/13] Internals: extracted ImHashSkipUncontributingPrefix() out of CreateNewWindowSettings() and added note about it. --- imgui.cpp | 16 ++++++++++------ imgui_internal.h | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 0d4bd99a9..4207012ed 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2387,6 +2387,14 @@ ImGuiID ImHashStr(const char* data_p, size_t data_size, ImGuiID seed) return ~crc; } +// Skip to the "###" marker if any. We don't skip past to match the behavior of GetID() +const char* ImHashSkipUncontributingPrefix(const char* label) +{ + if (const char* p = strstr(label, "###")) // FIXME: Should loop. + label = p; + return label; +} + //----------------------------------------------------------------------------- // [SECTION] MISC HELPERS/UTILITIES (File functions) //----------------------------------------------------------------------------- @@ -15259,13 +15267,9 @@ ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name) { ImGuiContext& g = *GImGui; + // Preserve the full string when ConfigDebugVerboseIniSettings is set to make .ini inspection easier. if (g.IO.ConfigDebugIniSettings == false) - { - // Skip to the "###" marker if any. We don't skip past to match the behavior of GetID() - // Preserve the full string when ConfigDebugVerboseIniSettings is set to make .ini inspection easier. - if (const char* p = strstr(name, "###")) - name = p; - } + name = ImHashSkipUncontributingPrefix(name); const size_t name_len = ImStrlen(name); // Allocate chunk diff --git a/imgui_internal.h b/imgui_internal.h index 1b21a8fcd..3085648dd 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -367,6 +367,7 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer // Helpers: Hashing IMGUI_API ImGuiID ImHashData(const void* data, size_t data_size, ImGuiID seed = 0); IMGUI_API ImGuiID ImHashStr(const char* data, size_t data_size = 0, ImGuiID seed = 0); +IMGUI_API const char* ImHashSkipUncontributingPrefix(const char* label); // Helpers: Sorting #ifndef ImQsort From 7d230594decfb434624c3d466acc95f96132ed5e Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 26 Aug 2025 16:25:33 +0200 Subject: [PATCH 08/13] Fixed ImHashSkipUncontributingPrefix() not looping in case of multiple ### elements. --- imgui.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 4207012ed..57ea52195 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2388,11 +2388,14 @@ ImGuiID ImHashStr(const char* data_p, size_t data_size, ImGuiID seed) } // Skip to the "###" marker if any. We don't skip past to match the behavior of GetID() +// FIXME-OPT: This is not designed to be optimal. Use with care. const char* ImHashSkipUncontributingPrefix(const char* label) { - if (const char* p = strstr(label, "###")) // FIXME: Should loop. - label = p; - return label; + const char* result = label; + while (unsigned char c = *label++) + if (c == '#' && label[0] == '#' && label[1] == '#') + result = label - 1; + return result; } //----------------------------------------------------------------------------- From 229d56e37a5d6e5f3cf8dee284754c2c8f3f5ca9 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 26 Aug 2025 16:30:13 +0200 Subject: [PATCH 09/13] Debug Tools: ID Stack Tool: when ### is used, uncontributing prefix before the ### is now skipped. (#8904, #4631) --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 28e4ab272..435057852 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -50,6 +50,8 @@ Other Changes: pointer, which could to issue when deleting the cloned list. (#8894, #1860) - Debug Tools: ID Stack Tool: fixed using fixed-size buffers preventing long identifiers from being displayed in the tool. (#8905, #4631) +- Debug Tools: ID Stack Tool: when ### is used, uncontributing prefix before the ### + is now skipped. (#8904, #4631) - Debug Tools: ID Stack Tool: added option to hex-encode non-ASCII characters in output path. (#8904, #4631) - Examples: Android: Android+OpenGL3: update Gradle project (#8888, #8878) [@scribam] diff --git a/imgui.cpp b/imgui.cpp index 57ea52195..16ae8d123 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -17733,14 +17733,14 @@ static int StackToolFormatLevelInfo(ImGuiIDStackTool* tool, int n, bool format_f ImGuiStackLevelInfo* info = &tool->Results[n]; ImGuiWindow* window = (info->DescOffset == -1 && n == 0) ? ImGui::FindWindowByID(info->ID) : NULL; if (window) // Source: window name (because the root ID don't call GetID() and so doesn't get hooked) - return ImFormatString(buf, buf_size, format_for_ui ? "\"%s\" [window]" : "%s", window->Name); + return ImFormatString(buf, buf_size, format_for_ui ? "\"%s\" [window]" : "%s", ImHashSkipUncontributingPrefix(window->Name)); if (info->QuerySuccess) // Source: GetID() hooks (prioritize over ItemInfo() because we frequently use patterns like: PushID(str), Button("") where they both have same id) - return ImFormatString(buf, buf_size, (format_for_ui && info->DataType == ImGuiDataType_String) ? "\"%s\"" : "%s", &tool->ResultPathsBuf.Buf[info->DescOffset]); + return ImFormatString(buf, buf_size, (format_for_ui && info->DataType == ImGuiDataType_String) ? "\"%s\"" : "%s", ImHashSkipUncontributingPrefix(&tool->ResultPathsBuf.Buf[info->DescOffset])); if (tool->StackLevel < tool->Results.Size) // Only start using fallback below when all queries are done, so during queries we don't flickering ??? markers. return (*buf = 0); #ifdef IMGUI_ENABLE_TEST_ENGINE if (const char* label = ImGuiTestEngine_FindItemDebugLabel(GImGui, info->ID)) // Source: ImGuiTestEngine's ItemInfo() - return ImFormatString(buf, buf_size, format_for_ui ? "??? \"%s\"" : "%s", label); + return ImFormatString(buf, buf_size, format_for_ui ? "??? \"%s\"" : "%s", ImHashSkipUncontributingPrefix(label)); #endif return ImFormatString(buf, buf_size, "???"); } From 319c481abb380fcc0c37d6310f3f083ecff22c63 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 26 Aug 2025 17:57:51 +0200 Subject: [PATCH 10/13] AddFontDefault(): shallow simplification. --- imgui.cpp | 2 +- imgui_draw.cpp | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 16ae8d123..18e67eab2 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -17160,7 +17160,7 @@ void ImGui::DebugNodeFontGlyph(ImFont* font, const ImFontGlyph* glyph) if (glyph->PackId >= 0) { ImTextureRect* r = ImFontAtlasPackGetRect(font->ContainerAtlas, glyph->PackId); - Text("PackId: %d (%dx%d rect at %d,%d)", glyph->PackId, r->w, r->h, r->x, r->y); + Text("PackId: 0x%X (%dx%d rect at %d,%d)", glyph->PackId, r->w, r->h, r->x, r->y); } Text("SourceIdx: %d", glyph->SourceIdx); } diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 31beb4133..c4dd43a52 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3116,9 +3116,7 @@ ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template) int ttf_compressed_size = 0; const char* ttf_compressed = GetDefaultCompressedFontDataTTF(&ttf_compressed_size); - const ImWchar* glyph_ranges = font_cfg.GlyphRanges != NULL ? font_cfg.GlyphRanges : GetGlyphRangesDefault(); - ImFont* font = AddFontFromMemoryCompressedTTF(ttf_compressed, ttf_compressed_size, font_cfg.SizePixels, &font_cfg, glyph_ranges); - return font; + return AddFontFromMemoryCompressedTTF(ttf_compressed, ttf_compressed_size, font_cfg.SizePixels, &font_cfg); #else IM_ASSERT(0 && "AddFontDefault() disabled in this build."); IM_UNUSED(font_cfg_template); From 87c1ab79883b90b5c8fc9698a8bff0bfb7f1b5c8 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 26 Aug 2025 18:48:08 +0200 Subject: [PATCH 11/13] Windows: changed how g.CurrentItemFlags is modified before windows' CloseButton() submission to be less misleading. (#8903) I don't think anyone would have `ImGuiItemFlags_NoFocus` set globally but technically it might. --- imgui.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 18e67eab2..bc4da78ee 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7113,10 +7113,11 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl // Close button if (has_close_button) { + ImGuiItemFlags backup_item_flags = g.CurrentItemFlags; g.CurrentItemFlags |= ImGuiItemFlags_NoFocus; if (CloseButton(window->GetID("#CLOSE"), close_button_pos)) *p_open = false; - g.CurrentItemFlags &= ~ImGuiItemFlags_NoFocus; + g.CurrentItemFlags = backup_item_flags; } window->DC.NavLayerCurrent = ImGuiNavLayer_Main; From a309d2dcac2c0941a6a04ef1e4d07b7d9c5b9485 Mon Sep 17 00:00:00 2001 From: Christian Fillion Date: Wed, 27 Aug 2025 00:05:30 -0400 Subject: [PATCH 12/13] Fonts: fixed assertion failure when ImFontAtlasRectEntry::Generation overflows. (#8906) --- docs/CHANGELOG.txt | 2 ++ imgui_draw.cpp | 2 ++ imgui_internal.h | 10 +++++----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 435057852..619e0c42e 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -45,6 +45,8 @@ Other Changes: - Scrollbar, Style: added configurable style.ScrollbarPadding value and corresponding ImGuiStyleVar_ScrollbarPadding enum, instead of hardcoded computed default. (#8895) +- Fonts: fixed an assertion failure when a rectangle entry has been reused + 1024 times (e.g. due to constant change of font types). (#8906) [@cfillion] - Fixed Bullet() fixed tesselation amount which looked out of place in very large sizes. - DrawList: Fixed CloneOutput() unnecessarily taking a copy of the ImDrawListSharedData pointer, which could to issue when deleting the cloned list. (#8894, #1860) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index c4dd43a52..76d8474bf 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -4293,6 +4293,8 @@ void ImFontAtlasPackDiscardRect(ImFontAtlas* atlas, ImFontAtlasRectId id) index_entry->IsUsed = false; index_entry->TargetIndex = builder->RectsIndexFreeListStart; index_entry->Generation++; + if (index_entry->Generation == 0) + index_entry->Generation++; // Keep non-zero on overflow const int pack_padding = atlas->TexGlyphPadding; builder->RectsIndexFreeListStart = index_idx; diff --git a/imgui_internal.h b/imgui_internal.h index 3085648dd..873e7881e 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -3736,12 +3736,12 @@ inline bool operator==(const ImTextureRef& lhs, const ImTextureRef& rhs) { re inline bool operator!=(const ImTextureRef& lhs, const ImTextureRef& rhs) { return lhs._TexID != rhs._TexID || lhs._TexData != rhs._TexData; } // Refer to ImFontAtlasPackGetRect() to better understand how this works. -#define ImFontAtlasRectId_IndexMask_ (0x000FFFFF) // 20-bits: index to access builder->RectsIndex[]. +#define ImFontAtlasRectId_IndexMask_ (0x0007FFFF) // 20-bits signed: index to access builder->RectsIndex[]. #define ImFontAtlasRectId_GenerationMask_ (0x3FF00000) // 10-bits: entry generation, so each ID is unique and get can safely detected old identifiers. #define ImFontAtlasRectId_GenerationShift_ (20) -inline int ImFontAtlasRectId_GetIndex(ImFontAtlasRectId id) { return id & ImFontAtlasRectId_IndexMask_; } -inline int ImFontAtlasRectId_GetGeneration(ImFontAtlasRectId id) { return (id & ImFontAtlasRectId_GenerationMask_) >> ImFontAtlasRectId_GenerationShift_; } -inline ImFontAtlasRectId ImFontAtlasRectId_Make(int index_idx, int gen_idx) { IM_ASSERT(index_idx < ImFontAtlasRectId_IndexMask_ && gen_idx < (ImFontAtlasRectId_GenerationMask_ >> ImFontAtlasRectId_GenerationShift_)); return (ImFontAtlasRectId)(index_idx | (gen_idx << ImFontAtlasRectId_GenerationShift_)); } +inline int ImFontAtlasRectId_GetIndex(ImFontAtlasRectId id) { return (id & ImFontAtlasRectId_IndexMask_); } +inline unsigned int ImFontAtlasRectId_GetGeneration(ImFontAtlasRectId id) { return (unsigned int)(id & ImFontAtlasRectId_GenerationMask_) >> ImFontAtlasRectId_GenerationShift_; } +inline ImFontAtlasRectId ImFontAtlasRectId_Make(int index_idx, int gen_idx) { IM_ASSERT(index_idx >= 0 && index_idx <= ImFontAtlasRectId_IndexMask_ && gen_idx <= (ImFontAtlasRectId_GenerationMask_ >> ImFontAtlasRectId_GenerationShift_)); return (ImFontAtlasRectId)(index_idx | (gen_idx << ImFontAtlasRectId_GenerationShift_)); } // Packed rectangle lookup entry (we need an indirection to allow removing/reordering rectangles) // User are returned ImFontAtlasRectId values which are meant to be persistent. @@ -3751,7 +3751,7 @@ inline ImFontAtlasRectId ImFontAtlasRectId_Make(int index_idx, int gen_idx) struct ImFontAtlasRectEntry { int TargetIndex : 20; // When Used: ImFontAtlasRectId -> into Rects[]. When unused: index to next unused RectsIndex[] slot to consume free-list. - int Generation : 10; // Increased each time the entry is reused for a new rectangle. + unsigned int Generation : 10; // Increased each time the entry is reused for a new rectangle. unsigned int IsUsed : 1; }; From aa2f40c3bbd7963fa908877cece04ab56f8329db Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 27 Aug 2025 18:34:10 +0200 Subject: [PATCH 13/13] Clipper, Tables: added ImGuiListClipperFlags, ImGuiListClipperFlags_NoSetTableRowCounters. (#8886) a0cdac48e0 revealed the issue but technically the core issue is that clipper assume 1 item = 1 table row. --- docs/CHANGELOG.txt | 3 +++ imgui.cpp | 16 ++++++++++------ imgui.h | 11 ++++++++++- imgui_tables.cpp | 5 +++-- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 619e0c42e..38b9898e9 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -47,6 +47,9 @@ Other Changes: ImGuiStyleVar_ScrollbarPadding enum, instead of hardcoded computed default. (#8895) - Fonts: fixed an assertion failure when a rectangle entry has been reused 1024 times (e.g. due to constant change of font types). (#8906) [@cfillion] +- Clipper, Tables: added ImGuiListClipperFlags_NoSetTableRowCounters as a way to + disable the assumption that 1 clipper item == 1 table row, which breaks when + e.g. using clipper with ItemsHeight=1 in order to clip in pixel units. (#8886) - Fixed Bullet() fixed tesselation amount which looked out of place in very large sizes. - DrawList: Fixed CloneOutput() unnecessarily taking a copy of the ImDrawListSharedData pointer, which could to issue when deleting the cloned list. (#8894, #1860) diff --git a/imgui.cpp b/imgui.cpp index bc4da78ee..085575bbd 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3124,7 +3124,7 @@ static void ImGuiListClipper_SortAndFuseRanges(ImVector& } } -static void ImGuiListClipper_SeekCursorAndSetupPrevLine(float pos_y, float line_height) +static void ImGuiListClipper_SeekCursorAndSetupPrevLine(ImGuiListClipper* clipper, float pos_y, float line_height) { // Set cursor position and a few other things so that SetScrollHereY() and Columns() can work when seeking cursor. // FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue. @@ -3142,10 +3142,14 @@ static void ImGuiListClipper_SeekCursorAndSetupPrevLine(float pos_y, float line_ { if (table->IsInsideRow) ImGui::TableEndRow(table); + if ((clipper->Flags & ImGuiListClipperFlags_NoSetTableRowCounters) == 0) + { + const int row_increase = (int)((off_y / line_height) + 0.5f); + IM_ASSERT(row_increase >= 0); // If your clipper item height is != from actual table row height, consider using ImGuiListClipperFlags_NoSetTableRowCounters. See #8886. + table->CurrentRow += row_increase; + table->RowBgColorCounter += row_increase; + } table->RowPosY2 = window->DC.CursorPos.y; - const int row_increase = (int)((off_y / line_height) + 0.5f); - table->CurrentRow += row_increase; - table->RowBgColorCounter += row_increase; } } @@ -3228,7 +3232,7 @@ void ImGuiListClipper::SeekCursorForItem(int item_n) // - StartPosY starts from ItemsFrozen, by adding SeekOffsetY we generally cancel that out (SeekOffsetY == LossynessOffset - ItemsFrozen * ItemsHeight). // - The reason we store SeekOffsetY instead of inferring it, is because we want to allow user to perform Seek after the last step, where ImGuiListClipperData is already done. float pos_y = (float)((double)StartPosY + StartSeekOffsetY + (double)item_n * ItemsHeight); - ImGuiListClipper_SeekCursorAndSetupPrevLine(pos_y, ItemsHeight); + ImGuiListClipper_SeekCursorAndSetupPrevLine(this, pos_y, ItemsHeight); } static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper) @@ -3327,7 +3331,6 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper) if (g.NavId != 0 && window->NavLastIds[0] == g.NavId) data->Ranges.push_back(ImGuiListClipperRange::FromPositions(nav_rect_abs.Min.y, nav_rect_abs.Max.y, 0, 0)); - // Add visible range float min_y = window->ClipRect.Min.y; float max_y = window->ClipRect.Max.y; @@ -3346,6 +3349,7 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper) data->Ranges.push_back(ImGuiListClipperRange::FromPositions(bs->UnclipRect.Min.y, bs->UnclipRect.Max.y, 0, 0)); } + // Add main visible range const int off_min = (is_nav_request && g.NavMoveClipDir == ImGuiDir_Up) ? -1 : 0; const int off_max = (is_nav_request && g.NavMoveClipDir == ImGuiDir_Down) ? 1 : 0; data->Ranges.push_back(ImGuiListClipperRange::FromPositions(min_y, max_y, off_min, off_max)); diff --git a/imgui.h b/imgui.h index 6b35f8403..f0163f9f1 100644 --- a/imgui.h +++ b/imgui.h @@ -29,7 +29,7 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') #define IMGUI_VERSION "1.92.3 WIP" -#define IMGUI_VERSION_NUM 19223 +#define IMGUI_VERSION_NUM 19224 #define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000 #define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198 @@ -246,6 +246,7 @@ typedef int ImGuiInputFlags; // -> enum ImGuiInputFlags_ // Flags: f typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline() typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag(), shared by all items typedef int ImGuiKeyChord; // -> ImGuiKey | ImGuiMod_XXX // Flags: for IsKeyChordPressed(), Shortcut() etc. an ImGuiKey optionally OR-ed with one or more ImGuiMod_XXX values. +typedef int ImGuiListClipperFlags; // -> enum ImGuiListClipperFlags_// Flags: for ImGuiListClipper typedef int ImGuiPopupFlags; // -> enum ImGuiPopupFlags_ // Flags: for OpenPopup*(), BeginPopupContext*(), IsPopupOpen() typedef int ImGuiMultiSelectFlags; // -> enum ImGuiMultiSelectFlags_// Flags: for BeginMultiSelect() typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable() @@ -2782,6 +2783,13 @@ struct ImGuiStorage #endif }; +// Flags for ImGuiListClipper (currently not fully exposed in function calls: a future refactor will likely add this to ImGuiListClipper::Begin function equivalent) +enum ImGuiListClipperFlags_ +{ + ImGuiListClipperFlags_None = 0, + ImGuiListClipperFlags_NoSetTableRowCounters = 1 << 0, // [Internal] Disabled modifying table row counters. Avoid assumption that 1 clipper item == 1 table row. +}; + // Helper: Manually clip large list of items. // If you have lots evenly spaced items and you have random access to the list, you can perform coarse // clipping based on visibility to only submit items that are in view. @@ -2812,6 +2820,7 @@ struct ImGuiListClipper double StartPosY; // [Internal] Cursor position at the time of Begin() or after table frozen rows are all processed double StartSeekOffsetY; // [Internal] Account for frozen rows in a table and initial loss of precision in very large windows. void* TempData; // [Internal] Internal data + ImGuiListClipperFlags Flags; // [Internal] Flags, currently not yet well exposed. // items_count: Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step, and you can call SeekCursorForItem() manually if you need) // items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing(). diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 8824534e7..c2b7548c9 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -2054,10 +2054,11 @@ void ImGui::TableEndRow(ImGuiTable* table) } // End frozen rows (when we are past the last frozen row line, teleport cursor and alter clipping rectangle) - // We need to do that in TableEndRow() instead of TableBeginRow() so the list clipper can mark end of row and - // get the new cursor position. + // - We need to do that in TableEndRow() instead of TableBeginRow() so the list clipper can mark + // end of row and get the new cursor position. if (unfreeze_rows_request) { + IM_ASSERT(table->FreezeRowsRequest > 0); for (int column_n = 0; column_n < table->ColumnsCount; column_n++) table->Columns[column_n].NavLayerCurrent = table->NavLayer; const float y0 = ImMax(table->RowPosY2 + 1, table->InnerClipRect.Min.y);