diff --git a/backends/imgui_impl_metal.mm b/backends/imgui_impl_metal.mm
index 09a2e599..521a01ac 100644
--- a/backends/imgui_impl_metal.mm
+++ b/backends/imgui_impl_metal.mm
@@ -150,13 +150,13 @@ void ImGui_ImplMetal_Shutdown()
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
ImGui_ImplMetal_ShutdownPlatformInterface();
+ ImGui_ImplMetal_DestroyDeviceObjects();
+ ImGui_ImplMetal_DestroyBackendData();
ImGuiIO& io = ImGui::GetIO();
io.BackendRendererName = nullptr;
io.BackendRendererUserData = nullptr;
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
- ImGui_ImplMetal_DestroyDeviceObjects();
- ImGui_ImplMetal_DestroyBackendData();
}
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
diff --git a/backends/imgui_impl_opengl3.cpp b/backends/imgui_impl_opengl3.cpp
index bab39264..4ebe1f72 100644
--- a/backends/imgui_impl_opengl3.cpp
+++ b/backends/imgui_impl_opengl3.cpp
@@ -16,6 +16,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2023-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
+// 2023-05-09: OpenGL: Support for glBindSampler() backup/restore on ES3. (#6375)
// 2023-04-18: OpenGL: Restore front and back polygon mode separately when supported by context. (#6333)
// 2023-03-23: OpenGL: Properly restoring "no shader program bound" if it was the case prior to running the rendering function. (#6267, #6220, #6224)
// 2023-03-15: OpenGL: Fixed GL loader crash when GL_VERSION returns NULL. (#6154, #4445, #3530)
@@ -178,8 +179,8 @@
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
#endif
-// Desktop GL 3.3+ has glBindSampler()
-#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_3)
+// Desktop GL 3.3+ and GL ES 3.0+ have glBindSampler()
+#if !defined(IMGUI_IMPL_OPENGL_ES2) && (defined(IMGUI_IMPL_OPENGL_ES3) || defined(GL_VERSION_3_3))
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
#endif
@@ -207,6 +208,8 @@ struct ImGui_ImplOpenGL3_Data
{
GLuint GlVersion; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries (e.g. 320 for GL 3.2)
char GlslVersionString[32]; // Specified by user or detected based on compile time GL settings.
+ bool GlProfileIsES2;
+ bool GlProfileIsES3;
bool GlProfileIsCompat;
GLint GlProfileMask;
GLuint FontTexture;
@@ -307,8 +310,12 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
bd->UseBufferSubData = true;
#endif
*/
-#else
+#elif defined(IMGUI_IMPL_OPENGL_ES2)
bd->GlVersion = 200; // GLES 2
+ bd->GlProfileIsES2 = true;
+#elif defined(IMGUI_IMPL_OPENGL_ES3)
+ bd->GlVersion = 200; // Don't raise version as it is intended as a desktop version check for now.
+ bd->GlProfileIsES3 = true;
#endif
#ifdef IMGUI_IMPL_OPENGL_DEBUG
@@ -439,8 +446,8 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
glUniformMatrix4fv(bd->AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
- if (bd->GlVersion >= 330)
- glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
+ if (bd->GlVersion >= 330 || bd->GlProfileIsES3)
+ glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 and GL ES 3.0 may set that otherwise.
#endif
(void)vertex_array_object;
@@ -478,7 +485,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
- GLuint last_sampler; if (bd->GlVersion >= 330) { glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler); } else { last_sampler = 0; }
+ GLuint last_sampler; if (bd->GlVersion >= 330 || bd->GlProfileIsES3) { glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler); } else { last_sampler = 0; }
#endif
GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
@@ -605,7 +612,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
if (last_program == 0 || glIsProgram(last_program)) glUseProgram(last_program);
glBindTexture(GL_TEXTURE_2D, last_texture);
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
- if (bd->GlVersion >= 330)
+ if (bd->GlVersion >= 330 || bd->GlProfileIsES3)
glBindSampler(0, last_sampler);
#endif
glActiveTexture(last_active_texture);
diff --git a/backends/imgui_impl_osx.mm b/backends/imgui_impl_osx.mm
index 4deeeaf5..bfd0dba9 100644
--- a/backends/imgui_impl_osx.mm
+++ b/backends/imgui_impl_osx.mm
@@ -496,7 +496,6 @@ void ImGui_ImplOSX_Shutdown()
{
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
- ImGui_ImplOSX_ShutdownPlatformInterface();
bd->Observer = nullptr;
if (bd->Monitor != nullptr)
@@ -505,11 +504,12 @@ void ImGui_ImplOSX_Shutdown()
bd->Monitor = nullptr;
}
+ ImGui_ImplOSX_ShutdownPlatformInterface();
+ ImGui_ImplOSX_DestroyBackendData();
ImGuiIO& io = ImGui::GetIO();
io.BackendPlatformName = nullptr;
io.BackendPlatformUserData = nullptr;
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports);
- ImGui_ImplOSX_DestroyBackendData();
}
static void ImGui_ImplOSX_UpdateMouseCursor()
diff --git a/backends/imgui_impl_sdl3.cpp b/backends/imgui_impl_sdl3.cpp
index b5b59743..06317016 100644
--- a/backends/imgui_impl_sdl3.cpp
+++ b/backends/imgui_impl_sdl3.cpp
@@ -22,6 +22,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2023-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
+// 2023-05-04: Fixed build on Emscripten/iOS/Android. (#6391)
// 2023-04-06: Inputs: Avoid calling SDL_StartTextInput()/SDL_StopTextInput() as they don't only pertain to IME. It's unclear exactly what their relation is to IME. (#6306)
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen. (#2702)
// 2023-02-23: Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. (#6189, #6114, #3644)
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index a789f71f..bce96e33 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -111,25 +111,43 @@ Other changes:
- Tables: Fixed a small miscalculation in TableHeader() leading to an empty tooltip
showing when a sorting column has no visible name. (#6342) [@lukaasm]
+- Tables: Fixed command merging when compiling with VS2013 (one array on stack was not
+ initialized on VS2013. Unsure if due to a bug or UB/standard conformance). (#6377)
- InputText: Avoid setting io.WantTextInputNextFrame during the deactivation frame.
(#6341) [@lukaasm]
+- Drag, Sliders: if the format string doesn't contain any %, CTRL+Click to input text will
+ use the default format specifier for the type. Allow display/input of raw value when using
+ "enums" patterns (display label instead of value) + allow using when value is hidden. (#6405)
+- Nav: Record/restore preferred position on each given axis after a movement on that axis,
+ then score movement on the other axis using this as a bias. This allows going up and down
+ between e.g. a large header spanning horizontal space and three-ways-columns, landing
+ on the same column as before.
- Nav: Fixed navigation within tables/columns where item boundaries goes beyond columns limits,
unclipped bounding boxes would interfere with other columns. (#2221) [@zzzyap, @ocornut]
- Nav: Fixed CTRL+Tab into a root window with only childs with _NavFlattened flags
erroneously initializing default nav layer to menu layer.
- Menus: Fixed an issue when opening a menu hierarchy in a given menu-bar would allow
opening another via simple hovering. (#3496, #4797)
+- Misc: Added ImVec2 unary minus operator. (#6368) [@Koostosh]
- Debug Tools: Debug Log: Fixed not parsing 0xXXXXXXXX values for geo-locating on mouse
hover hover when the identifier is at the end of the line. (#5855)
+- Debug Tools: Added 'io.ConfigDebugIgnoreFocusLoss' option to disable 'io.AddFocusEvent(false)'
+ handling. May facilitate interactions with a debugger when focus loss leads to clearing
+ inputs data. (#4388, #4921)
- Backends: Clear bits sets io.BackendFlags on backend Shutdown(). (#6334, #6335] [@GereonV]
Potentially this would facilitate switching runtime backend mid-session.
- Backends: Win32: Added ImGui_ImplWin32_InitForOpenGL() to facilitate combining raw
Win32/Winapi with OpenGL. (#3218)
- Backends: OpenGL3: Restore front and back polygon mode separately when supported
by context (Desktop 3.0, 3.1, or 3.2+ with compat bit). (#6333) [@GereonV]
+- Backends: OpenGL3: Support for glBindSampler() backup/restore on ES3. (#6375) [@jsm174]
+- Backends: SDL3: Fixed build on Emscripten/iOS/Android. (#6391) [@jo-codegirl]
- Examples: Added native Win32+OpenGL3 example. We don't recommend using this setup but we
provide it for completeness. (#3218, #5170, #6086, #2772, #2600, #2359, #2022, #1553) [@learn-more]
- Examples: Vulkan: Use integrated GPU if nothing else is available. (#6359) [@kimidaisuki22]
+- Examples: DX9, DX10, DX11: Queue framebuffer resize instead of processing in WM_SIZE,
+ as some drivers tends to only cleanup after existing the native resize modal loop. (#6374)
+- Examples: Updated all Visual Studio projects and batches to use /utf-8 argument.
Docking+Viewports Branch:
diff --git a/docs/FAQ.md b/docs/FAQ.md
index 8dd0c441..7e6ad7b5 100644
--- a/docs/FAQ.md
+++ b/docs/FAQ.md
@@ -557,7 +557,7 @@ backslash \ within a string literal, you need to write it double backslash "\\":
```cpp
io.Fonts->AddFontFromFileTTF("MyFolder\MyFont.ttf", size); // WRONG (you are escaping the M here!)
-io.Fonts->AddFontFromFileTTF("MyFolder\\MyFont.ttf", size; // CORRECT (Windows only)
+io.Fonts->AddFontFromFileTTF("MyFolder\\MyFont.ttf", size); // CORRECT (Windows only)
io.Fonts->AddFontFromFileTTF("MyFolder/MyFont.ttf", size); // ALSO CORRECT
```
@@ -628,10 +628,11 @@ builder.BuildRanges(&ranges); // Build the final result
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", 16.0f, nullptr, ranges.Data);
```
-All your strings need to use UTF-8 encoding. In C++11 you can encode a string literal in UTF-8
-by using the u8"hello" syntax. Specifying literal in your source code using a local code page
-(such as CP-923 for Japanese or CP-1251 for Cyrillic) will NOT work!
-Otherwise, you can convert yourself to UTF-8 or load text data from a file already saved as UTF-8.
+All your strings need to use UTF-8 encoding.
+You need to tell your compiler to use UTF-8, or in C++11 you can encode a string literal in UTF-8 by using the u8"hello" syntax.
+Specifying literal in your source code using a local code page (such as CP-923 for Japanese or CP-1251 for Cyrillic) will NOT work!
+See [About UTF-8 Encoding](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md#about-utf-8-encoding) section
+of [FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) for details about UTF-8 Encoding.
Text input: it is up to your application to pass the right character code by calling `io.AddInputCharacter()`.
The applications in examples/ are doing that.
diff --git a/docs/FONTS.md b/docs/FONTS.md
index ff62733b..6049fb48 100644
--- a/docs/FONTS.md
+++ b/docs/FONTS.md
@@ -12,41 +12,118 @@ In the [misc/fonts/](https://github.com/ocornut/imgui/tree/master/misc/fonts) fo
## Index
- [Readme First](#readme-first)
+- [About Filenames](#about-filenames)
+- [About UTF-8 Encoding](#about-utf-8-encoding)
+- [Debug Tools](#debug-tools)
- [How should I handle DPI in my application?](#how-should-i-handle-dpi-in-my-application)
-- [Fonts Loading Instructions](#font-loading-instructions)
+- [Fonts Loading Instructions](#fonts-loading-instructions)
- [Using Icon Fonts](#using-icon-fonts)
- [Using FreeType Rasterizer (imgui_freetype)](#using-freetype-rasterizer-imgui_freetype)
- [Using Colorful Glyphs/Emojis](#using-colorful-glyphsemojis)
- [Using Custom Glyph Ranges](#using-custom-glyph-ranges)
- [Using Custom Colorful Icons](#using-custom-colorful-icons)
- [Using Font Data Embedded In Source Code](#using-font-data-embedded-in-source-code)
-- [About filenames](#about-filenames)
- [Credits/Licenses For Fonts Included In Repository](#creditslicenses-for-fonts-included-in-repository)
- [Font Links](#font-links)
---------------------------------------
- ## Readme First
-- You can use the `Metrics/Debugger` window (available in `Demo>Tools`) to browse your fonts and understand what's going on if you have an issue. You can also reach it in `Demo->Tools->Style Editor->Fonts`. The same information are also available in the Style Editor under Fonts.
+## Readme First
-
+**A vast majority of font and text related issues encountered comes from 3 things:**
+- Invalid filename due to use of `\` or unexpected working directory. See [About Filenames](#about-filenames). AddFontXXX functions should assert if the filename is incorrect.
+- Invalid UTF-8 encoding of your non-ASCII strings. See [About UTF-8 Encoding](#about-utf-8-encoding). Use the encoding viewer to confirm yours is correct.
+- You need to load a font with explicit glyph ranges if you want to use non-ASCII characters. See [Fonts Loading Instructions](#fonts-loading-instructions). Use Metrics/Debugger->Fonts to confirm loaded fonts and loaded glyph ranges.
-- You can use the `UTF-8 Encoding viewer` in `Metrics/Debugger` to verify the content of your UTF-8 strings. From C/C++ code, you can call `ImGui::DebugTextEncoding("my string");` function to verify that your UTF-8 encoding is correct.
+The third point is a current constraint of Dear ImGui (which we will lift in the future): when loading a font you need to specify which characters glyphs to load.
+All loaded fonts glyphs are rendered into a single texture atlas ahead of time. Calling either of `io.Fonts->GetTexDataAsAlpha8()`, `io.Fonts->GetTexDataAsRGBA32()` or `io.Fonts->Build()` will build the atlas. This is generally called by the Renderer backend, e.g. `ImGui_ImplDX11_NewFrame()` calls it.
-
+**If you use custom glyphs ranges, make sure the array is persistent** and available during the calls to `GetTexDataAsAlpha8()/GetTexDataAsRGBA32()/Build()`.
+
+##### [Return to Index](#index)
-- All loaded fonts glyphs are rendered into a single texture atlas ahead of time. Calling either of `io.Fonts->GetTexDataAsAlpha8()`, `io.Fonts->GetTexDataAsRGBA32()` or `io.Fonts->Build()` will build the atlas.
+## About Filenames
-- Make sure your font ranges data are persistent (available during the calls to `GetTexDataAsAlpha8()`/`GetTexDataAsRGBA32()/`Build()`.
+**Please note that many new C/C++ users have issues loading their files _because the filename they provide is wrong_ due to incorrect assumption of what is the current directory.**
-- Use C++11 u8"my text" syntax to encode literal strings as UTF-8. e.g.:
+Two things to watch for:
+
+(1) In C/C++ and most programming languages if you want to use a backslash `\` within a string literal, you need to write it double backslash `\\`. At it happens, Windows uses backslashes as a path separator, so be mindful.
```cpp
-u8"hello"
-u8"こんにちは" // this will be encoded as UTF-8
+io.Fonts->AddFontFromFileTTF("MyFiles\MyImage01.jpg", ...); // This is INCORRECT!!
+io.Fonts->AddFontFromFileTTF("MyFiles\\MyImage01.jpg", ...); // This is CORRECT
```
+In some situations, you may also use `/` path separator under Windows.
+(2) Make sure your IDE/debugger settings starts your executable from the right working (current) directory. In Visual Studio you can change your working directory in project `Properties > General > Debugging > Working Directory`. People assume that their execution will start from the root folder of the project, where by default it often starts from the folder where object or executable files are stored.
+```cpp
+io.Fonts->AddFontFromFileTTF("MyImage01.jpg", ...); // Relative filename depends on your Working Directory when running your program!
+io.Fonts->AddFontFromFileTTF("../MyImage01.jpg", ...); // Load from the parent folder of your Working Directory
+```
##### [Return to Index](#index)
+
+## About UTF-8 Encoding
+
+**For non-ASCII characters display, a common user issue is not passing correctly UTF-8 encoded strings.**
+
+(1) We provide a function `ImGui::DebugTextEncoding(const char* text)` which you can call to verify the content of your UTF-8 strings.
+This is a convenient way to confirm that your encoding is correct.
+
+```cpp
+ImGui::SeparatorText("CORRECT");
+ImGui::DebugTextEncoding(u8"こんにちは");
+
+ImGui::SeparatorText("INCORRECT");
+ImGui::DebugTextEncoding("こんにちは");
+```
+
+
+You can also find this tool under `Metrics/Debuggers->Tools->UTF-8 Encoding viewer` if you want to paste from clipboard, but this won't validate the UTF-8 encoding done by your compiler.
+
+(2) To encode in UTF-8:
+
+There are also compiler-specific ways to enforce UTF-8 encoding by default:
+
+- Visual Studio compiler: `/utf-8` command-line flag.
+- Visual Studio compiler: `#pragma execution_character_set("utf-8")` inside your code.
+- Since May 2023 we have changed the Visual Studio projects of all our examples to use `/utf-8` ([see commit](https://github.com/ocornut/imgui/commit/513af1efc9080857bbd10000d98f98f2a0c96803)).
+
+Or, since C++11, you can use the `u8"my text"` syntax to encode literal strings as UTF-8. e.g.:
+```cpp
+ImGui::Text(u8"hello");
+ImGui::Text(u8"こんにちは"); // this will always be encoded as UTF-8
+ImGui::Text("こんにちは"); // the encoding of this is depending on compiler settings/flags and may be incorrect.
+```
+
+Since C++20, because the C++ committee hate its users, they decided to change the `u8""` syntax to not return `const char*` but a new type `const char_t*` which doesn't cast to `const char*`.
+Because of type usage of `u8""` in C++20 is a little more tedious:
+```cpp
+ImGui::Text((const char*)u8"こんにちは");
+```
+We suggest using a macro in your codebase:
+```cpp
+#define U8(_S) (const char*)u8##_S
+ImGui::Text(U8("こんにちは"));
+```
+##### [Return to Index](#index)
+
+
+## Debug Tools
+
+#### Metrics/Debugger->Fonts
+You can use the `Metrics/Debugger` window (available in `Demo>Tools`) to browse your fonts and understand what's going on if you have an issue. You can also reach it in `Demo->Tools->Style Editor->Fonts`. The same information are also available in the Style Editor under Fonts.
+
+
+
+#### UTF-8 Encoding Viewer**
+You can use the `UTF-8 Encoding viewer` in `Metrics/Debugger` to verify the content of your UTF-8 strings. From C/C++ code, you can call `ImGui::DebugTextEncoding("my string");` function to verify that your UTF-8 encoding is correct.
+
+
+
+##### [Return to Index](#index)
+
+
## How should I handle DPI in my application?
See [FAQ entry](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-how-should-i-handle-dpi-in-my-application).
@@ -54,7 +131,7 @@ See [FAQ entry](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-how-s
##### [Return to Index](#index)
-## Font Loading Instructions
+## Fonts Loading Instructions
**Load default font:**
```cpp
@@ -62,7 +139,6 @@ ImGuiIO& io = ImGui::GetIO();
io.Fonts->AddFontDefault();
```
-
**Load .TTF/.OTF file with:**
```cpp
ImGuiIO& io = ImGui::GetIO();
@@ -70,7 +146,6 @@ io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
```
If you get an assert stating "Could not load font file!", your font filename is likely incorrect. Read "[About filenames](#about-filenames)" carefully.
-
**Load multiple fonts:**
```cpp
// Init
@@ -86,7 +161,6 @@ ImGui::Text("Hello with another font");
ImGui::PopFont();
```
-
**For advanced options create a ImFontConfig structure and pass it to the AddFont() function (it will be copied internally):**
```cpp
ImFontConfig config;
@@ -96,7 +170,6 @@ config.GlyphExtraSpacing.x = 1.0f;
ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, &config);
```
-
**Combine multiple fonts into one:**
```cpp
// Load a first font
@@ -311,28 +384,6 @@ ImFont* font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(compressed_data_ba
##### [Return to Index](#index)
-## About filenames
-
-**Please note that many new C/C++ users have issues loading their files _because the filename they provide is wrong_.**
-
-Two things to watch for:
-- Make sure your IDE/debugger settings starts your executable from the right working directory. In Visual Studio you can change your working directory in project `Properties > General > Debugging > Working Directory`. People assume that their execution will start from the root folder of the project, where by default it often starts from the folder where object or executable files are stored.
-```cpp
-// Relative filename depends on your Working Directory when running your program!
-io.Fonts->AddFontFromFileTTF("MyImage01.jpg", ...);
-
-// Load from the parent folder of your Working Directory
-io.Fonts->AddFontFromFileTTF("../MyImage01.jpg", ...);
-```
-- In C/C++ and most programming languages if you want to use a backslash `\` within a string literal, you need to write it double backslash `\\`. At it happens, Windows uses backslashes as a path separator, so be mindful.
-```cpp
-io.Fonts->AddFontFromFileTTF("MyFiles\MyImage01.jpg", ...); // This is INCORRECT!!
-io.Fonts->AddFontFromFileTTF("MyFiles\\MyImage01.jpg", ...); // This is CORRECT
-```
-In some situations, you may also use `/` path separator under Windows.
-
-##### [Return to Index](#index)
-
## Credits/Licenses For Fonts Included In Repository
Some fonts files are available in the `misc/fonts/` folder:
diff --git a/examples/example_allegro5/README.md b/examples/example_allegro5/README.md
index c86179cc..4af31f6f 100644
--- a/examples/example_allegro5/README.md
+++ b/examples/example_allegro5/README.md
@@ -32,5 +32,5 @@ vcpkg integrate install ; register include / libs in Visual Studio
Build:
```
set ALLEGRODIR=path_to_your_allegro5_folder
-cl /Zi /MD /I %ALLEGRODIR%\include /DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" /I .. /I ..\.. /I ..\..\backends main.cpp ..\..\backends\imgui_impl_allegro5.cpp ..\..\imgui*.cpp /link /LIBPATH:%ALLEGRODIR%\lib allegro-5.0.10-monolith-md.lib user32.lib
+cl /Zi /MD /utf-8 /I %ALLEGRODIR%\include /DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" /I .. /I ..\.. /I ..\..\backends main.cpp ..\..\backends\imgui_impl_allegro5.cpp ..\..\imgui*.cpp /link /LIBPATH:%ALLEGRODIR%\lib allegro-5.0.10-monolith-md.lib user32.lib
```
diff --git a/examples/example_allegro5/example_allegro5.vcxproj b/examples/example_allegro5/example_allegro5.vcxproj
index 8c549b44..02f6a474 100644
--- a/examples/example_allegro5/example_allegro5.vcxproj
+++ b/examples/example_allegro5/example_allegro5.vcxproj
@@ -91,6 +91,7 @@
Level4
Disabled
..\..;..\..\backends;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -105,6 +106,7 @@
Level4
Disabled
..\..;..\..\backends;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -122,6 +124,7 @@
true
..\..;..\..\backends;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
@@ -142,6 +145,7 @@
true
..\..;..\..\backends;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_glfw_opengl2/build_win32.bat b/examples/example_glfw_opengl2/build_win32.bat
index a0a75f90..24c0e08f 100644
--- a/examples/example_glfw_opengl2/build_win32.bat
+++ b/examples/example_glfw_opengl2/build_win32.bat
@@ -5,4 +5,4 @@
@set SOURCES=main.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
mkdir %OUT_DIR%
-cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
+cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
diff --git a/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj b/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj
index 82bdac22..2aa25506 100644
--- a/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj
+++ b/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj
@@ -91,6 +91,7 @@
Level4
Disabled
..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -105,6 +106,7 @@
Level4
Disabled
..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -122,6 +124,7 @@
true
..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
@@ -142,6 +145,7 @@
true
..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_glfw_opengl3/build_win32.bat b/examples/example_glfw_opengl3/build_win32.bat
index 4ba58d8c..b5979ad4 100644
--- a/examples/example_glfw_opengl3/build_win32.bat
+++ b/examples/example_glfw_opengl3/build_win32.bat
@@ -5,4 +5,4 @@
@set SOURCES=main.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
mkdir %OUT_DIR%
-cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
+cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
diff --git a/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj b/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj
index 0a1c3d6b..4bd503af 100644
--- a/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj
+++ b/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj
@@ -91,6 +91,7 @@
Level4
Disabled
..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -105,6 +106,7 @@
Level4
Disabled
..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -122,6 +124,7 @@
true
..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
@@ -142,6 +145,7 @@
true
..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_glfw_vulkan/build_win32.bat b/examples/example_glfw_vulkan/build_win32.bat
index 82f01112..be923981 100644
--- a/examples/example_glfw_vulkan/build_win32.bat
+++ b/examples/example_glfw_vulkan/build_win32.bat
@@ -7,8 +7,8 @@
@set OUT_DIR=Debug
mkdir %OUT_DIR%
-cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
+cl /nologo /Zi /MD /utf-8 %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
@set OUT_DIR=Release
mkdir %OUT_DIR%
-cl /nologo /Zi /MD /Ox /Oi %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
+cl /nologo /Zi /MD /utf-8 /Ox /Oi %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
diff --git a/examples/example_glfw_vulkan/build_win64.bat b/examples/example_glfw_vulkan/build_win64.bat
index 0bf7936c..c60b0278 100644
--- a/examples/example_glfw_vulkan/build_win64.bat
+++ b/examples/example_glfw_vulkan/build_win64.bat
@@ -6,8 +6,8 @@
@set OUT_DIR=Debug
mkdir %OUT_DIR%
-cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
+cl /nologo /Zi /MD /utf-8 %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
@set OUT_DIR=Release
mkdir %OUT_DIR%
-cl /nologo /Zi /MD /Ox /Oi %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
+cl /nologo /Zi /MD /utf-8 /Ox /Oi %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
diff --git a/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj b/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj
index 4eb8b7ce..d0d1c5f8 100644
--- a/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj
+++ b/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj
@@ -92,6 +92,7 @@
Disabled
..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)
ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)
+ /utf-8 %(AdditionalOptions)
true
@@ -107,6 +108,7 @@
Disabled
..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)
ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)
+ /utf-8 %(AdditionalOptions)
true
@@ -125,6 +127,7 @@
..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)
false
ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)
+ /utf-8 %(AdditionalOptions)
true
@@ -146,6 +149,7 @@
..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)
false
ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
index 266ac04e..c56452b2 100644
--- a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -91,6 +91,7 @@
Level4
Disabled
$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -105,6 +106,7 @@
Level4
Disabled
$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -122,6 +124,7 @@
true
$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
@@ -142,6 +145,7 @@
true
$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_null/build_win32.bat b/examples/example_null/build_win32.bat
index 0cdfdc93..be81d809 100644
--- a/examples/example_null/build_win32.bat
+++ b/examples/example_null/build_win32.bat
@@ -1,3 +1,3 @@
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
mkdir Debug
-cl /nologo /Zi /MD /I ..\.. %* *.cpp ..\..\*.cpp /FeDebug/example_null.exe /FoDebug/ /link gdi32.lib shell32.lib imm32.lib
+cl /nologo /Zi /MD /utf-8 /I ..\.. %* *.cpp ..\..\*.cpp /FeDebug/example_null.exe /FoDebug/ /link gdi32.lib shell32.lib imm32.lib
diff --git a/examples/example_sdl2_directx11/build_win32.bat b/examples/example_sdl2_directx11/build_win32.bat
index 54f30fc9..f0b485ca 100644
--- a/examples/example_sdl2_directx11/build_win32.bat
+++ b/examples/example_sdl2_directx11/build_win32.bat
@@ -5,4 +5,4 @@
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\imgui*.cpp
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib shell32.lib
mkdir %OUT_DIR%
-cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
+cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
diff --git a/examples/example_sdl2_directx11/example_sdl2_directx11.vcxproj b/examples/example_sdl2_directx11/example_sdl2_directx11.vcxproj
index e6a57f6c..c23800c9 100644
--- a/examples/example_sdl2_directx11/example_sdl2_directx11.vcxproj
+++ b/examples/example_sdl2_directx11/example_sdl2_directx11.vcxproj
@@ -92,6 +92,7 @@
Level4
Disabled
..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -106,6 +107,7 @@
Level4
Disabled
..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -123,6 +125,7 @@
true
..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
@@ -143,6 +146,7 @@
true
..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_sdl2_opengl2/build_win32.bat b/examples/example_sdl2_opengl2/build_win32.bat
index 287a418b..7543edaf 100644
--- a/examples/example_sdl2_opengl2/build_win32.bat
+++ b/examples/example_sdl2_opengl2/build_win32.bat
@@ -5,4 +5,4 @@
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\imgui*.cpp
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib shell32.lib
mkdir %OUT_DIR%
-cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
+cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
diff --git a/examples/example_sdl2_opengl2/example_sdl2_opengl2.vcxproj b/examples/example_sdl2_opengl2/example_sdl2_opengl2.vcxproj
index 08a6df9b..036463f9 100644
--- a/examples/example_sdl2_opengl2/example_sdl2_opengl2.vcxproj
+++ b/examples/example_sdl2_opengl2/example_sdl2_opengl2.vcxproj
@@ -91,6 +91,7 @@
Level4
Disabled
..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -105,6 +106,7 @@
Level4
Disabled
..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -122,6 +124,7 @@
true
..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
@@ -142,6 +145,7 @@
true
..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_sdl2_opengl3/README.md b/examples/example_sdl2_opengl3/README.md
index 9ecb9e90..81fd9fe7 100644
--- a/examples/example_sdl2_opengl3/README.md
+++ b/examples/example_sdl2_opengl3/README.md
@@ -10,10 +10,10 @@ Use the provided project file (.vcxproj). Add to solution (imgui_examples.sln) i
Use build_win32.bat or directly:
```
set SDL2_DIR=path_to_your_sdl2_folder
-cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
-# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries
+cl /Zi /MD /utf-8 /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
+# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries
# or for 64-bit:
-cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
+cl /Zi /MD /utf-8 /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
```
## Linux and similar Unixes
diff --git a/examples/example_sdl2_opengl3/build_win32.bat b/examples/example_sdl2_opengl3/build_win32.bat
index abbf3c78..7b2fac92 100644
--- a/examples/example_sdl2_opengl3/build_win32.bat
+++ b/examples/example_sdl2_opengl3/build_win32.bat
@@ -5,4 +5,4 @@
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib shell32.lib
mkdir %OUT_DIR%
-cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
+cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
diff --git a/examples/example_sdl2_opengl3/example_sdl2_opengl3.vcxproj b/examples/example_sdl2_opengl3/example_sdl2_opengl3.vcxproj
index 21ce0693..6a81c677 100644
--- a/examples/example_sdl2_opengl3/example_sdl2_opengl3.vcxproj
+++ b/examples/example_sdl2_opengl3/example_sdl2_opengl3.vcxproj
@@ -91,6 +91,7 @@
Level4
Disabled
..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -105,6 +106,7 @@
Level4
Disabled
..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -122,6 +124,7 @@
true
..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
@@ -142,6 +145,7 @@
true
..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_sdl2_sdlrenderer/README.md b/examples/example_sdl2_sdlrenderer/README.md
index 4fa37433..0445bc4d 100644
--- a/examples/example_sdl2_sdlrenderer/README.md
+++ b/examples/example_sdl2_sdlrenderer/README.md
@@ -5,10 +5,10 @@
```
set SDL2_DIR=path_to_your_sdl2_folder
-cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_sdlrenderer.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_sdlrenderer.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /subsystem:console
-# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries
+cl /Zi /MD /utf-8 /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_sdlrenderer.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_sdlrenderer.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /subsystem:console
+# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries
# or for 64-bit:
-cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_sdlrenderer.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_sdlrenderer.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib /subsystem:console
+cl /Zi /MD /utf-8 /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_sdlrenderer.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_sdlrenderer.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib /subsystem:console
```
- On Linux and similar Unixes
diff --git a/examples/example_sdl2_sdlrenderer/build_win32.bat b/examples/example_sdl2_sdlrenderer/build_win32.bat
index 1bae121b..ca3f650c 100644
--- a/examples/example_sdl2_sdlrenderer/build_win32.bat
+++ b/examples/example_sdl2_sdlrenderer/build_win32.bat
@@ -5,4 +5,4 @@
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_sdlrenderer.cpp ..\..\imgui*.cpp
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib
mkdir %OUT_DIR%
-cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
+cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
diff --git a/examples/example_sdl2_sdlrenderer/example_sdl2_sdlrenderer.vcxproj b/examples/example_sdl2_sdlrenderer/example_sdl2_sdlrenderer.vcxproj
index 35bcfe2e..fdc85d8c 100644
--- a/examples/example_sdl2_sdlrenderer/example_sdl2_sdlrenderer.vcxproj
+++ b/examples/example_sdl2_sdlrenderer/example_sdl2_sdlrenderer.vcxproj
@@ -91,6 +91,7 @@
Level4
Disabled
..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -105,6 +106,7 @@
Level4
Disabled
..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -122,6 +124,7 @@
true
..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
@@ -142,6 +145,7 @@
true
..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_sdl2_vulkan/build_win32.bat b/examples/example_sdl2_vulkan/build_win32.bat
index 5bc51985..8a4aefc2 100644
--- a/examples/example_sdl2_vulkan/build_win32.bat
+++ b/examples/example_sdl2_vulkan/build_win32.bat
@@ -7,4 +7,4 @@
@set OUT_DIR=Debug
mkdir %OUT_DIR%
-cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
+cl /nologo /Zi /MD /utf-8 %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
diff --git a/examples/example_sdl2_vulkan/example_sdl2_vulkan.vcxproj b/examples/example_sdl2_vulkan/example_sdl2_vulkan.vcxproj
index e5cbdc36..ba6afaf7 100644
--- a/examples/example_sdl2_vulkan/example_sdl2_vulkan.vcxproj
+++ b/examples/example_sdl2_vulkan/example_sdl2_vulkan.vcxproj
@@ -92,6 +92,7 @@
Disabled
..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)
+ /utf-8 %(AdditionalOptions)
true
@@ -107,6 +108,7 @@
Disabled
..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)
+ /utf-8 %(AdditionalOptions)
true
@@ -125,6 +127,7 @@
..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
false
ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)
+ /utf-8 %(AdditionalOptions)
true
@@ -146,6 +149,7 @@
..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)
false
ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_sdl3_opengl3/README.md b/examples/example_sdl3_opengl3/README.md
index 8b137b16..ab7f8e99 100644
--- a/examples/example_sdl3_opengl3/README.md
+++ b/examples/example_sdl3_opengl3/README.md
@@ -10,10 +10,10 @@ Use the provided project file (.vcxproj). Add to solution (imgui_examples.sln) i
Use build_win32.bat or directly:
```
set SDL2_DIR=path_to_your_sdl3_folder
-cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl3.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp /FeDebug/example_sdl3_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL3.lib opengl32.lib /subsystem:console
-# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries
+cl /Zi /MD /utf-8 /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl3.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp /FeDebug/example_sdl3_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL3.lib opengl32.lib /subsystem:console
+# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries
# or for 64-bit:
-cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl3.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp /FeDebug/example_sdl3_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL3.lib SDL2mainopengl32.lib /subsystem:console
+cl /Zi /MD /utf-8 /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl3.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp /FeDebug/example_sdl3_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL3.lib SDL2mainopengl32.lib /subsystem:console
```
## Linux and similar Unixes
diff --git a/examples/example_sdl3_opengl3/build_win32.bat b/examples/example_sdl3_opengl3/build_win32.bat
index ba7d25bc..5b8d5f87 100644
--- a/examples/example_sdl3_opengl3/build_win32.bat
+++ b/examples/example_sdl3_opengl3/build_win32.bat
@@ -5,4 +5,4 @@
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl3.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp
@set LIBS=/LIBPATH:%SDL3_DIR%\lib\x86 SDL3.lib opengl32.lib shell32.lib
mkdir %OUT_DIR%
-cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
+cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
diff --git a/examples/example_sdl3_opengl3/example_sdl3_opengl3.vcxproj b/examples/example_sdl3_opengl3/example_sdl3_opengl3.vcxproj
index a29e3afd..051f87d7 100644
--- a/examples/example_sdl3_opengl3/example_sdl3_opengl3.vcxproj
+++ b/examples/example_sdl3_opengl3/example_sdl3_opengl3.vcxproj
@@ -91,6 +91,7 @@
Level4
Disabled
..\..;..\..\backends;%SDL3_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL3;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -105,6 +106,7 @@
Level4
Disabled
..\..;..\..\backends;%SDL3_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL3;%(AdditionalIncludeDirectories)
+ /utf-8 %(AdditionalOptions)
true
@@ -122,6 +124,7 @@
true
..\..;..\..\backends;%SDL3_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL3;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
@@ -142,6 +145,7 @@
true
..\..;..\..\backends;%SDL3_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL3;%(AdditionalIncludeDirectories)
false
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_win32_directx10/build_win32.bat b/examples/example_win32_directx10/build_win32.bat
index fd742239..78a6e374 100644
--- a/examples/example_win32_directx10/build_win32.bat
+++ b/examples/example_win32_directx10/build_win32.bat
@@ -5,4 +5,4 @@
@set SOURCES=main.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\backends\imgui_impl_dx10.cpp ..\..\imgui*.cpp
@set LIBS=/LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d10.lib d3dcompiler.lib
mkdir %OUT_DIR%
-cl /nologo /Zi /MD %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
+cl /nologo /Zi /MD /utf-8 %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
diff --git a/examples/example_win32_directx10/example_win32_directx10.vcxproj b/examples/example_win32_directx10/example_win32_directx10.vcxproj
index 2dc2333e..d11aed88 100644
--- a/examples/example_win32_directx10/example_win32_directx10.vcxproj
+++ b/examples/example_win32_directx10/example_win32_directx10.vcxproj
@@ -87,6 +87,7 @@
Level4
Disabled
..\..;..\..\backends;%(AdditionalIncludeDirectories);
+ /utf-8 %(AdditionalOptions)
true
@@ -100,6 +101,7 @@
Level4
Disabled
..\..;..\..\backends;%(AdditionalIncludeDirectories);
+ /utf-8 %(AdditionalOptions)
true
@@ -116,6 +118,7 @@
true
..\..;..\..\backends;%(AdditionalIncludeDirectories);
false
+ /utf-8 %(AdditionalOptions)
true
@@ -134,6 +137,7 @@
true
..\..;..\..\backends;%(AdditionalIncludeDirectories);
false
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_win32_directx10/main.cpp b/examples/example_win32_directx10/main.cpp
index 6644daa7..04f2d2ba 100644
--- a/examples/example_win32_directx10/main.cpp
+++ b/examples/example_win32_directx10/main.cpp
@@ -12,6 +12,7 @@
// Data
static ID3D10Device* g_pd3dDevice = nullptr;
static IDXGISwapChain* g_pSwapChain = nullptr;
+static UINT g_ResizeWidth = 0, g_ResizeHeight = 0;
static ID3D10RenderTargetView* g_mainRenderTargetView = nullptr;
// Forward declarations of helper functions
@@ -107,6 +108,15 @@ int main(int, char**)
if (done)
break;
+ // Handle window resize (we don't resize directly in the WM_SIZE handler)
+ if (g_ResizeWidth != 0 && g_ResizeHeight != 0)
+ {
+ CleanupRenderTarget();
+ g_pSwapChain->ResizeBuffers(0, g_ResizeWidth, g_ResizeHeight, DXGI_FORMAT_UNKNOWN, 0);
+ g_ResizeWidth = g_ResizeHeight = 0;
+ CreateRenderTarget();
+ }
+
// Start the Dear ImGui frame
ImGui_ImplDX10_NewFrame();
ImGui_ImplWin32_NewFrame();
@@ -246,12 +256,10 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
switch (msg)
{
case WM_SIZE:
- if (g_pd3dDevice != nullptr && wParam != SIZE_MINIMIZED)
- {
- CleanupRenderTarget();
- g_pSwapChain->ResizeBuffers(0, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam), DXGI_FORMAT_UNKNOWN, 0);
- CreateRenderTarget();
- }
+ if (wParam == SIZE_MINIMIZED)
+ return 0;
+ g_ResizeWidth = (UINT)LOWORD(lParam); // Queue resize
+ g_ResizeHeight = (UINT)HIWORD(lParam);
return 0;
case WM_SYSCOMMAND:
if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu
diff --git a/examples/example_win32_directx11/build_win32.bat b/examples/example_win32_directx11/build_win32.bat
index b1cf7d1c..c9a717c6 100644
--- a/examples/example_win32_directx11/build_win32.bat
+++ b/examples/example_win32_directx11/build_win32.bat
@@ -5,5 +5,5 @@
@set SOURCES=main.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp
@set LIBS=/LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib
mkdir %OUT_DIR%
-cl /nologo /Zi /MD %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
+cl /nologo /Zi /MD /utf-8 %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
diff --git a/examples/example_win32_directx11/example_win32_directx11.vcxproj b/examples/example_win32_directx11/example_win32_directx11.vcxproj
index 3264f509..bace6a2c 100644
--- a/examples/example_win32_directx11/example_win32_directx11.vcxproj
+++ b/examples/example_win32_directx11/example_win32_directx11.vcxproj
@@ -86,6 +86,7 @@
Level4
Disabled
..\..;..\..\backends;%(AdditionalIncludeDirectories);
+ /utf-8 %(AdditionalOptions)
true
@@ -99,6 +100,7 @@
Level4
Disabled
..\..;..\..\backends;%(AdditionalIncludeDirectories);
+ /utf-8 %(AdditionalOptions)
true
@@ -115,6 +117,7 @@
true
..\..;..\..\backends;%(AdditionalIncludeDirectories);
false
+ /utf-8 %(AdditionalOptions)
true
@@ -133,6 +136,7 @@
true
..\..;..\..\backends;%(AdditionalIncludeDirectories);
false
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_win32_directx11/main.cpp b/examples/example_win32_directx11/main.cpp
index 267e5ff9..65601317 100644
--- a/examples/example_win32_directx11/main.cpp
+++ b/examples/example_win32_directx11/main.cpp
@@ -12,6 +12,7 @@
static ID3D11Device* g_pd3dDevice = nullptr;
static ID3D11DeviceContext* g_pd3dDeviceContext = nullptr;
static IDXGISwapChain* g_pSwapChain = nullptr;
+static UINT g_ResizeWidth = 0, g_ResizeHeight = 0;
static ID3D11RenderTargetView* g_mainRenderTargetView = nullptr;
// Forward declarations of helper functions
@@ -112,6 +113,15 @@ int main(int, char**)
if (done)
break;
+ // Handle window resize (we don't resize directly in the WM_SIZE handler)
+ if (g_ResizeWidth != 0 && g_ResizeHeight != 0)
+ {
+ CleanupRenderTarget();
+ g_pSwapChain->ResizeBuffers(0, g_ResizeWidth, g_ResizeHeight, DXGI_FORMAT_UNKNOWN, 0);
+ g_ResizeWidth = g_ResizeHeight = 0;
+ CreateRenderTarget();
+ }
+
// Start the Dear ImGui frame
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
@@ -259,12 +269,10 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
switch (msg)
{
case WM_SIZE:
- if (g_pd3dDevice != nullptr && wParam != SIZE_MINIMIZED)
- {
- CleanupRenderTarget();
- g_pSwapChain->ResizeBuffers(0, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam), DXGI_FORMAT_UNKNOWN, 0);
- CreateRenderTarget();
- }
+ if (wParam == SIZE_MINIMIZED)
+ return 0;
+ g_ResizeWidth = (UINT)LOWORD(lParam); // Queue resize
+ g_ResizeHeight = (UINT)HIWORD(lParam);
return 0;
case WM_SYSCOMMAND:
if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu
diff --git a/examples/example_win32_directx12/build_win32.bat b/examples/example_win32_directx12/build_win32.bat
index 48dadb29..68e3c921 100644
--- a/examples/example_win32_directx12/build_win32.bat
+++ b/examples/example_win32_directx12/build_win32.bat
@@ -6,4 +6,4 @@
@set SOURCES=main.cpp ..\..\backends\imgui_impl_dx12.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp
@set LIBS=d3d12.lib d3dcompiler.lib dxgi.lib
mkdir Debug
-cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
+cl /nologo /Zi /MD /utf-8 %INCLUDES% /D ImTextureID=ImU64 /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
diff --git a/examples/example_win32_directx12/example_win32_directx12.vcxproj b/examples/example_win32_directx12/example_win32_directx12.vcxproj
index 9e073774..7b64371e 100644
--- a/examples/example_win32_directx12/example_win32_directx12.vcxproj
+++ b/examples/example_win32_directx12/example_win32_directx12.vcxproj
@@ -88,6 +88,7 @@
Disabled
..\..;..\..\backends;%(AdditionalIncludeDirectories)
ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ /utf-8 %(AdditionalOptions)
true
@@ -102,6 +103,7 @@
Disabled
..\..;..\..\backends;%(AdditionalIncludeDirectories)
ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ /utf-8 %(AdditionalOptions)
true
@@ -118,6 +120,7 @@
true
..\..;..\..\backends;%(AdditionalIncludeDirectories)
ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ /utf-8 %(AdditionalOptions)
true
@@ -136,6 +139,7 @@
true
..\..;..\..\backends;%(AdditionalIncludeDirectories)
ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_win32_directx9/build_win32.bat b/examples/example_win32_directx9/build_win32.bat
index bbd4b13c..ece5ea1b 100644
--- a/examples/example_win32_directx9/build_win32.bat
+++ b/examples/example_win32_directx9/build_win32.bat
@@ -5,4 +5,4 @@
@set SOURCES=main.cpp ..\..\backends\imgui_impl_dx9.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp
@set LIBS=/LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d9.lib
mkdir %OUT_DIR%
-cl /nologo /Zi /MD %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
+cl /nologo /Zi /MD /utf-8 %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
diff --git a/examples/example_win32_directx9/example_win32_directx9.vcxproj b/examples/example_win32_directx9/example_win32_directx9.vcxproj
index 44be2247..8c3f9958 100644
--- a/examples/example_win32_directx9/example_win32_directx9.vcxproj
+++ b/examples/example_win32_directx9/example_win32_directx9.vcxproj
@@ -87,6 +87,7 @@
Level4
Disabled
..\..;..\..\backends;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
+ /utf-8 %(AdditionalOptions)
true
@@ -100,6 +101,7 @@
Level4
Disabled
..\..;..\..\backends;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
+ /utf-8 %(AdditionalOptions)
true
@@ -116,6 +118,7 @@
true
..\..;..\..\backends;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
false
+ /utf-8 %(AdditionalOptions)
true
@@ -134,6 +137,7 @@
true
..\..;..\..\backends;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
false
+ /utf-8 %(AdditionalOptions)
true
diff --git a/examples/example_win32_directx9/main.cpp b/examples/example_win32_directx9/main.cpp
index d3e6dddb..972c6030 100644
--- a/examples/example_win32_directx9/main.cpp
+++ b/examples/example_win32_directx9/main.cpp
@@ -11,6 +11,7 @@
// Data
static LPDIRECT3D9 g_pD3D = nullptr;
static LPDIRECT3DDEVICE9 g_pd3dDevice = nullptr;
+static UINT g_ResizeWidth = 0, g_ResizeHeight = 0;
static D3DPRESENT_PARAMETERS g_d3dpp = {};
// Forward declarations of helper functions
@@ -105,6 +106,14 @@ int main(int, char**)
if (done)
break;
+ // Handle window resize (we don't resize directly in the WM_SIZE handler)
+ if (g_ResizeWidth != 0 && g_ResizeHeight != 0)
+ {
+ g_d3dpp.BackBufferWidth = g_ResizeWidth;
+ g_d3dpp.BackBufferHeight = g_ResizeHeight;
+ ResetDevice();
+ }
+
// Start the Dear ImGui frame
ImGui_ImplDX9_NewFrame();
ImGui_ImplWin32_NewFrame();
@@ -242,12 +251,10 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
switch (msg)
{
case WM_SIZE:
- if (g_pd3dDevice != nullptr && wParam != SIZE_MINIMIZED)
- {
- g_d3dpp.BackBufferWidth = LOWORD(lParam);
- g_d3dpp.BackBufferHeight = HIWORD(lParam);
- ResetDevice();
- }
+ if (wParam == SIZE_MINIMIZED)
+ return 0;
+ g_ResizeWidth = (UINT)LOWORD(lParam); // Queue resize
+ g_ResizeHeight = (UINT)HIWORD(lParam);
return 0;
case WM_SYSCOMMAND:
if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu
diff --git a/examples/example_win32_opengl3/build_win32.bat b/examples/example_win32_opengl3/build_win32.bat
index 91cc6bec..48df0808 100644
--- a/examples/example_win32_opengl3/build_win32.bat
+++ b/examples/example_win32_opengl3/build_win32.bat
@@ -5,4 +5,4 @@
@set SOURCES=main.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp
@set LIBS=opengl32.lib
mkdir %OUT_DIR%
-cl /nologo /Zi /MD %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
+cl /nologo /Zi /MD /utf-8 %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
diff --git a/examples/example_win32_opengl3/example_win32_opengl3.vcxproj b/examples/example_win32_opengl3/example_win32_opengl3.vcxproj
index 49023e3d..98fc38fd 100644
--- a/examples/example_win32_opengl3/example_win32_opengl3.vcxproj
+++ b/examples/example_win32_opengl3/example_win32_opengl3.vcxproj
@@ -87,6 +87,7 @@
Level4
Disabled
..\..;..\..\backends;
+ /utf-8 %(AdditionalOptions)
true
@@ -100,6 +101,7 @@
Level4
Disabled
..\..;..\..\backends;
+ /utf-8 %(AdditionalOptions)
true
@@ -116,6 +118,7 @@
true
..\..;..\..\backends;
false
+ /utf-8 %(AdditionalOptions)
true
@@ -134,6 +137,7 @@
true
..\..;..\..\backends;
false
+ /utf-8 %(AdditionalOptions)
true
diff --git a/imgui.cpp b/imgui.cpp
index 489ea037..f101eafa 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -1597,7 +1597,7 @@ void ImGuiIO::AddFocusEvent(bool focused)
// Filter duplicate
const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_Focus);
const bool latest_focused = latest_event ? latest_event->AppFocused.Focused : !g.IO.AppFocusLost;
- if (latest_focused == focused)
+ if (latest_focused == focused || (ConfigDebugIgnoreFocusLoss && !focused))
return;
ImGuiInputEvent e;
@@ -3772,6 +3772,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* ctx, const char* name) : DrawListInst(NUL
DrawList = &DrawListInst;
DrawList->_Data = &Ctx->DrawListSharedData;
DrawList->_OwnerName = Name;
+ NavPreferredScoringPosRel[0] = NavPreferredScoringPosRel[1] = ImVec2(FLT_MAX, FLT_MAX);
IM_PLACEMENT_NEW(&WindowClass) ImGuiWindowClass();
}
@@ -7071,8 +7072,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// - We disable this when the parent window has zero vertices, which is a common pattern leading to laying out multiple overlapping childs
ImGuiWindow* previous_child = parent_window->DC.ChildWindows.Size >= 2 ? parent_window->DC.ChildWindows[parent_window->DC.ChildWindows.Size - 2] : NULL;
bool previous_child_overlapping = previous_child ? previous_child->Rect().Overlaps(window->Rect()) : false;
- bool parent_is_empty = parent_window->DrawList->VtxBuffer.Size > 0;
- if (window->DrawList->CmdBuffer.back().ElemCount == 0 && parent_is_empty && !previous_child_overlapping)
+ bool parent_is_empty = (parent_window->DrawList->VtxBuffer.Size == 0);
+ if (window->DrawList->CmdBuffer.back().ElemCount == 0 && !parent_is_empty && !previous_child_overlapping)
render_decorations_in_parent = true;
}
if (render_decorations_in_parent)
@@ -11282,6 +11283,12 @@ void ImGui::SetNavWindow(ImGuiWindow* window)
NavUpdateAnyRequestFlag();
}
+void ImGui::NavClearPreferredPosForAxis(ImGuiAxis axis)
+{
+ ImGuiContext& g = *GImGui;
+ g.NavWindow->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer][axis] = FLT_MAX;
+}
+
void ImGui::SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel)
{
ImGuiContext& g = *GImGui;
@@ -11292,6 +11299,10 @@ void ImGui::SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id
g.NavFocusScopeId = focus_scope_id;
g.NavWindow->NavLastIds[nav_layer] = id;
g.NavWindow->NavRectRel[nav_layer] = rect_rel;
+
+ // Clear preferred scoring position (NavMoveRequestApplyResult() will tend to restore it)
+ NavClearPreferredPosForAxis(ImGuiAxis_X);
+ NavClearPreferredPosForAxis(ImGuiAxis_Y);
}
void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
@@ -11316,6 +11327,10 @@ void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
g.NavDisableMouseHover = true;
else
g.NavDisableHighlight = true;
+
+ // Clear preferred scoring position (NavMoveRequestApplyResult() will tend to restore it)
+ NavClearPreferredPosForAxis(ImGuiAxis_X);
+ NavClearPreferredPosForAxis(ImGuiAxis_Y);
}
ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy)
@@ -11408,16 +11423,22 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result)
draw_list->AddText(cand.Min, IM_COL32(255, 255, 255, 255), buf);
}
}
- if (IsMouseHoveringRect(cand.Min, cand.Max))
+ const bool debug_hovering = IsMouseHoveringRect(cand.Min, cand.Max);
+ const bool debug_tty = (g.IO.KeyCtrl && IsKeyPressed(ImGuiKey_Space));
+ if (debug_hovering || debug_tty)
{
ImFormatString(buf, IM_ARRAYSIZE(buf),
"d-box (%7.3f,%7.3f) -> %7.3f\nd-center (%7.3f,%7.3f) -> %7.3f\nd-axial (%7.3f,%7.3f) -> %7.3f\nnav %c, quadrant %c",
- dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "WENS"[g.NavMoveDir], "WENS"[quadrant]);
- ImDrawList* draw_list = GetForegroundDrawList(window);
- draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255,200,0,100));
- draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255,255,0,200));
- draw_list->AddRectFilled(cand.Max - ImVec2(4, 4), cand.Max + CalcTextSize(buf) + ImVec2(4, 4), IM_COL32(40,0,0,200));
- draw_list->AddText(cand.Max, ~0U, buf);
+ dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "-WENS"[move_dir+1], "-WENS"[quadrant+1]);
+ if (debug_hovering)
+ {
+ ImDrawList* draw_list = GetForegroundDrawList(window);
+ draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255, 200, 0, 100));
+ draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255, 255, 0, 200));
+ draw_list->AddRectFilled(cand.Max - ImVec2(4, 4), cand.Max + CalcTextSize(buf) + ImVec2(4, 4), IM_COL32(40, 0, 0, 200));
+ draw_list->AddText(cand.Max, ~0U, buf);
+ }
+ if (debug_tty) { IMGUI_DEBUG_LOG_NAV("id 0x%08X\n%s\n", g.LastItemData.ID, buf); }
}
#endif
@@ -11988,11 +12009,11 @@ static void ImGui::NavUpdate()
// [DEBUG]
g.NavScoringDebugCount = 0;
#if IMGUI_DEBUG_NAV_RECTS
- if (g.NavWindow)
+ if (ImGuiWindow* debug_window = g.NavWindow)
{
- ImDrawList* draw_list = GetForegroundDrawList(g.NavWindow);
- if (1) { for (int layer = 0; layer < 2; layer++) { ImRect r = WindowRectRelToAbs(g.NavWindow, g.NavWindow->NavRectRel[layer]); draw_list->AddRect(r.Min, r.Max, IM_COL32(255,200,0,255)); } } // [DEBUG]
- if (1) { ImU32 col = (!g.NavWindow->Hidden) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredRefPos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); draw_list->AddCircleFilled(p, 3.0f, col); draw_list->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
+ ImDrawList* draw_list = GetForegroundDrawList(debug_window);
+ int layer = g.NavLayer; /* for (int layer = 0; layer < 2; layer++)*/ { ImRect r = WindowRectRelToAbs(debug_window, debug_window->NavRectRel[layer]); draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 200, 0, 255)); }
+ //if (1) { ImU32 col = (!debug_window->Hidden) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredRefPos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); draw_list->AddCircleFilled(p, 3.0f, col); draw_list->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
}
#endif
}
@@ -12013,6 +12034,28 @@ void ImGui::NavInitRequestApplyResult()
NavRestoreHighlightAfterMove();
}
+// Bias scoring rect ahead of scoring + update preferred pos (if missing) using source position
+static void NavBiasScoringRect(ImRect& r, ImVec2& preferred_pos_rel, ImGuiDir move_dir)
+{
+ // Bias initial rect
+ ImGuiContext& g = *GImGui;
+ const ImVec2 rel_to_abs_offset = g.NavWindow->DC.CursorStartPos;
+
+ // Initialize bias on departure if we don't have any. So mouse-click + arrow will record bias.
+ // - We default to L/U bias, so moving down from a large source item into several columns will land on left-most column.
+ // - But each successful move sets new bias on one axis, only cleared when using mouse.
+ if (preferred_pos_rel.x == FLT_MAX)
+ preferred_pos_rel.x = ImMin(r.Min.x + 1.0f, r.Max.x) - rel_to_abs_offset.x;
+ if (preferred_pos_rel.y == FLT_MAX)
+ preferred_pos_rel.y = r.GetCenter().y - rel_to_abs_offset.y;
+
+ // Apply general bias on the other axis
+ if (move_dir == ImGuiDir_Up || move_dir == ImGuiDir_Down)
+ r.Min.x = r.Max.x = preferred_pos_rel.x + rel_to_abs_offset.x;
+ else
+ r.Min.y = r.Max.y = preferred_pos_rel.y + rel_to_abs_offset.y;
+}
+
void ImGui::NavUpdateCreateMoveRequest()
{
ImGuiContext& g = *GImGui;
@@ -12119,8 +12162,8 @@ void ImGui::NavUpdateCreateMoveRequest()
ImRect nav_rect_rel = !window->NavRectRel[g.NavLayer].IsInverted() ? window->NavRectRel[g.NavLayer] : ImRect(0, 0, 0, 0);
scoring_rect = WindowRectRelToAbs(window, nav_rect_rel);
scoring_rect.TranslateY(scoring_rect_offset_y);
- scoring_rect.Min.x = ImMin(scoring_rect.Min.x + 1.0f, scoring_rect.Max.x);
- scoring_rect.Max.x = scoring_rect.Min.x;
+ if (g.NavMoveSubmitted)
+ NavBiasScoringRect(scoring_rect, window->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer], g.NavMoveDir);
IM_ASSERT(!scoring_rect.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allow us to remove extraneous ImFabs() calls in NavScoreItem().
//GetForegroundDrawList()->AddRect(scoring_rect.Min, scoring_rect.Max, IM_COL32(255,200,0,255)); // [DEBUG]
//if (!g.NavScoringNoClipRect.IsInverted()) { GetForegroundDrawList()->AddRect(g.NavScoringNoClipRect.Min, g.NavScoringNoClipRect.Max, IM_COL32(255, 200, 0, 255)); } // [DEBUG]
@@ -12174,12 +12217,14 @@ void ImGui::NavMoveRequestApplyResult()
result = &g.NavTabbingResultFirst;
// In a situation when there are no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result)
+ const ImGuiAxis axis = (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
if (result == NULL)
{
if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing)
g.NavMoveFlags |= ImGuiNavMoveFlags_DontSetNavHighlight;
if (g.NavId != 0 && (g.NavMoveFlags & ImGuiNavMoveFlags_DontSetNavHighlight) == 0)
NavRestoreHighlightAfterMove();
+ NavClearPreferredPosForAxis(axis); // On a failed move, clear preferred pos for this axis.
IMGUI_DEBUG_LOG_NAV("[nav] NavMoveSubmitted but not led to a result!\n");
return;
}
@@ -12224,10 +12269,19 @@ void ImGui::NavMoveRequestApplyResult()
g.NavJustMovedToKeyMods = g.NavMoveKeyMods;
}
- // Focus
+ // Apply new NavID/Focus
IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequest: result NavID 0x%08X in Layer %d Window \"%s\"\n", result->ID, g.NavLayer, g.NavWindow->Name);
+ ImVec2 preferred_scoring_pos_rel = g.NavWindow->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer];
SetNavID(result->ID, g.NavLayer, result->FocusScopeId, result->RectRel);
+ // Restore last preferred position for current axis
+ // (storing in RootWindowForNav-> as the info is desirable at the beginning of a Move Request. In theory all storage should use RootWindowForNav..)
+ if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) == 0)
+ {
+ preferred_scoring_pos_rel[axis] = result->RectRel.GetCenter()[axis];
+ g.NavWindow->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer] = preferred_scoring_pos_rel;
+ }
+
// Tabbing: Activates Inputable or Focus non-Inputable
if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && (result->InFlags & ImGuiItemFlags_Inputable))
{
@@ -12441,6 +12495,8 @@ static void ImGui::NavUpdateCreateWrappingRequest()
if (!do_forward)
return;
window->NavRectRel[g.NavLayer] = bb_rel;
+ NavClearPreferredPosForAxis(ImGuiAxis_X);
+ NavClearPreferredPosForAxis(ImGuiAxis_Y);
NavMoveRequestForward(g.NavMoveDir, clip_dir, move_flags, g.NavMoveScrollFlags);
}
@@ -18878,7 +18934,7 @@ void ImGui::DebugRenderKeyboardPreview(ImDrawList* draw_list)
void ImGui::DebugTextEncoding(const char* str)
{
Text("Text: \"%s\"", str);
- if (!BeginTable("list", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit))
+ if (!BeginTable("##DebugTextEncoding", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable))
return;
TableSetupColumn("Offset");
TableSetupColumn("UTF-8");
@@ -20012,6 +20068,9 @@ void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label)
BulletText("NavLastIds[%d]: 0x%08X at +(%.1f,%.1f)(%.1f,%.1f)", layer, window->NavLastIds[layer], r.Min.x, r.Min.y, r.Max.x, r.Max.y);
DebugLocateItemOnHover(window->NavLastIds[layer]);
}
+ const ImVec2* pr = window->NavPreferredScoringPosRel;
+ for (int layer = 0; layer < ImGuiNavLayer_COUNT; layer++)
+ BulletText("NavPreferredScoringPosRel[%d] = {%.1f,%.1f)", layer, (pr[layer].x == FLT_MAX ? -99999.0f : pr[layer].x), (pr[layer].y == FLT_MAX ? -99999.0f : pr[layer].y)); // Display as 99999.0f so it looks neater.
BulletText("NavLayersActiveMask: %X, NavLastChildNavWindow: %s", window->DC.NavLayersActiveMask, window->NavLastChildNavWindow ? window->NavLastChildNavWindow->Name : "NULL");
BulletText("Viewport: %d%s, ViewportId: 0x%08X, ViewportPos: (%.1f,%.1f)", window->Viewport ? window->Viewport->Idx : -1, window->ViewportOwned ? " (Owned)" : "", window->ViewportId, window->ViewportPos.x, window->ViewportPos.y);
diff --git a/imgui.h b/imgui.h
index ca5bc9bc..3b9769de 100644
--- a/imgui.h
+++ b/imgui.h
@@ -23,7 +23,7 @@
// Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
#define IMGUI_VERSION "1.89.6 WIP"
-#define IMGUI_VERSION_NUM 18954
+#define IMGUI_VERSION_NUM 18956
#define IMGUI_HAS_TABLE
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
#define IMGUI_HAS_DOCK // Docking WIP branch
@@ -2039,11 +2039,15 @@ struct ImGuiIO
// Debug options
// - tools to test correct Begin/End and BeginChild/EndChild behaviors.
- // - presently Begn()/End() and BeginChild()EndChild() needs to ALWAYS be called in tandem, regardless of return value of BeginXXX()
+ // - presently Begin()/End() and BeginChild()/EndChild() needs to ALWAYS be called in tandem, regardless of return value of BeginXXX()
// this is inconsistent with other BeginXXX functions and create confusion for many users.
- // - we expect to update the API eventually. In the meanwhile we provided tools to facilitate checking user-code behavior.
- bool ConfigDebugBeginReturnValueOnce; // = false // First-time calls to Begin()/BeginChild() will return false. NEEDS TO BE SET AT APPLICATION BOOT TIME if you don't want to miss windows.
- bool ConfigDebugBeginReturnValueLoop; // = false // Some calls to Begin()/BeginChild() will return false. Will cycle through window depths then repeat. Suggested use: add "io.ConfigDebugBeginReturnValue = io.KeyShift" in your main loop then occasionally press SHIFT. Windows should be flickering while running.
+ // - we expect to update the API eventually. In the meanwhile we provide tools to facilitate checking user-code behavior.
+ bool ConfigDebugBeginReturnValueOnce;// = false // First-time calls to Begin()/BeginChild() will return false. NEEDS TO BE SET AT APPLICATION BOOT TIME if you don't want to miss windows.
+ bool ConfigDebugBeginReturnValueLoop;// = false // Some calls to Begin()/BeginChild() will return false. Will cycle through window depths then repeat. Suggested use: add "io.ConfigDebugBeginReturnValue = io.KeyShift" in your main loop then occasionally press SHIFT. Windows should be flickering while running.
+ // - option to deactivate io.AddFocusEvent(false) handling. May facilitate interactions with a debugger when focus loss leads to clearing inputs data.
+ // - backends may have other side-effects on focus loss, so this will reduce side-effects but not necessary remove all of them.
+ // - consider using e.g. Win32's IsDebuggerPresent() as an additional filter (or see ImOsIsDebuggerPresent() in imgui_test_engine/imgui_te_utils.cpp for a Unix compatible version).
+ bool ConfigDebugIgnoreFocusLoss; // = false // Ignore io.AddFocusEvent(false), consequently not calling io.ClearInputKeys() in input processing.
//------------------------------------------------------------------
// Platform Functions
@@ -2463,7 +2467,6 @@ struct ImGuiListClipper
// - It is important that we are keeping those disabled by default so they don't leak in user space.
// - This is in order to allow user enabling implicit cast operators between ImVec2/ImVec4 and their own types (using IM_VEC2_CLASS_EXTRA in imconfig.h)
// - You can use '#define IMGUI_DEFINE_MATH_OPERATORS' to import our operators, provided as a courtesy.
-// - We unfortunately don't have a unary- operator for ImVec2 because this would needs to be defined inside the class itself.
#ifdef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS_IMPLEMENTED
IM_MSVC_RUNTIME_CHECKS_OFF
@@ -2473,6 +2476,7 @@ static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return
static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x - rhs.x, lhs.y - rhs.y); }
static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x / rhs.x, lhs.y / rhs.y); }
+static inline ImVec2 operator-(const ImVec2& lhs) { return ImVec2(-lhs.x, -lhs.y); }
static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
@@ -2940,7 +2944,8 @@ struct ImFontAtlas
//-------------------------------------------
// Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list)
- // NB: Make sure that your string are UTF-8 and NOT in your local code page. In C++11, you can create UTF-8 string literal using the u8"Hello world" syntax. See FAQ for details.
+ // NB: Make sure that your string are UTF-8 and NOT in your local code page.
+ // Read https://github.com/ocornut/imgui/blob/master/docs/FONTS.md/#about-utf-8-encoding for details.
// NB: Consider using ImFontGlyphRangesBuilder to build glyph ranges from textual data.
IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin
IMGUI_API const ImWchar* GetGlyphRangesGreek(); // Default + Greek and Coptic
diff --git a/imgui_demo.cpp b/imgui_demo.cpp
index 3045c8ba..a0f9e4ad 100644
--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -525,6 +525,8 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::SameLine(); HelpMarker("First calls to Begin()/BeginChild() will return false.\n\nTHIS OPTION IS DISABLED because it needs to be set at application boot-time to make sense. Showing the disabled option is a way to make this feature easier to discover");
ImGui::Checkbox("io.ConfigDebugBeginReturnValueLoop", &io.ConfigDebugBeginReturnValueLoop);
ImGui::SameLine(); HelpMarker("Some calls to Begin()/BeginChild() will return false.\n\nWill cycle through window depths then repeat. Windows should be flickering while running.");
+ ImGui::Checkbox("io.ConfigDebugIgnoreFocusLoss", &io.ConfigDebugIgnoreFocusLoss);
+ ImGui::SameLine(); HelpMarker("Option to deactivate io.AddFocusEvent(false) handling. May facilitate interactions with a debugger when focus loss leads to clearing inputs data.");
ImGui::TreePop();
ImGui::Spacing();
@@ -690,7 +692,7 @@ static void ShowDemoWindowWidgets()
ImGui::Text("Tooltips:");
ImGui::SameLine();
- ImGui::SmallButton("Button");
+ ImGui::SmallButton("Basic");
if (ImGui::IsItemHovered())
ImGui::SetTooltip("I am a tooltip");
@@ -803,7 +805,7 @@ static void ShowDemoWindowWidgets()
static int elem = Element_Fire;
const char* elems_names[Element_COUNT] = { "Fire", "Earth", "Air", "Water" };
const char* elem_name = (elem >= 0 && elem < Element_COUNT) ? elems_names[elem] : "Unknown";
- ImGui::SliderInt("slider enum", &elem, 0, Element_COUNT - 1, elem_name);
+ ImGui::SliderInt("slider enum", &elem, 0, Element_COUNT - 1, elem_name); // Use ImGuiSliderFlags_NoInput flag to disable CTRL+Click here.
ImGui::SameLine(); HelpMarker("Using the format string parameter to display a name instead of the underlying integer.");
}
diff --git a/imgui_draw.cpp b/imgui_draw.cpp
index f360deb0..c7166546 100644
--- a/imgui_draw.cpp
+++ b/imgui_draw.cpp
@@ -2629,6 +2629,9 @@ void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opa
ImVector& user_rects = atlas->CustomRects;
IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong.
+#ifdef __GNUC__
+ if (user_rects.Size < 1) { __builtin_unreachable(); } // Workaround for GCC bug if IM_ASSERT() is defined to conditionally throw (see #5343)
+#endif
ImVector pack_rects;
pack_rects.resize(user_rects.Size);
diff --git a/imgui_internal.h b/imgui_internal.h
index b32a3e42..951a2938 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -2584,6 +2584,7 @@ struct IMGUI_API ImGuiWindow
ImGuiWindow* NavLastChildNavWindow; // When going to the menu bar, we remember the child window we came from. (This could probably be made implicit if we kept g.Windows sorted by last focused including child window.)
ImGuiID NavLastIds[ImGuiNavLayer_COUNT]; // Last known NavId for this window, per layer (0/1)
ImRect NavRectRel[ImGuiNavLayer_COUNT]; // Reference rectangle, in window relative space
+ ImVec2 NavPreferredScoringPosRel[ImGuiNavLayer_COUNT]; // Preferred X/Y position updated when moving on a given axis, reset to FLT_MAX.
ImGuiID NavRootFocusScopeId; // Focus Scope ID at the time of Begin()
int MemoryDrawListIdxCapacity; // Backup of last idx/vtx count, so when waking up the window we can preallocate and avoid iterative alloc/copy
@@ -2995,6 +2996,7 @@ namespace ImGui
IMGUI_API void SetWindowHiddendAndSkipItemsForCurrentFrame(ImGuiWindow* window);
inline ImRect WindowRectAbsToRel(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x - off.x, r.Min.y - off.y, r.Max.x - off.x, r.Max.y - off.y); }
inline ImRect WindowRectRelToAbs(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x + off.x, r.Min.y + off.y, r.Max.x + off.x, r.Max.y + off.y); }
+ inline ImVec2 WindowPosRelToAbs(ImGuiWindow* window, const ImVec2& p) { ImVec2 off = window->DC.CursorStartPos; return ImVec2(p.x + off.x, p.y + off.y); }
// Windows: Display Order and Focus Order
IMGUI_API void FocusWindow(ImGuiWindow* window, ImGuiFocusRequestFlags flags = 0);
@@ -3147,6 +3149,7 @@ namespace ImGui
IMGUI_API void NavMoveRequestCancel();
IMGUI_API void NavMoveRequestApplyResult();
IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
+ IMGUI_API void NavClearPreferredPosForAxis(ImGuiAxis axis);
IMGUI_API void NavUpdateCurrentWindowIsScrollPushableX();
IMGUI_API void ActivateItem(ImGuiID id); // Remotely activate a button, checkbox, tree node etc. given its unique ID. activation is queued and processed on the next frame when the item is encountered again.
IMGUI_API void SetNavWindow(ImGuiWindow* window);
diff --git a/imgui_tables.cpp b/imgui_tables.cpp
index ea036741..7ff5d643 100644
--- a/imgui_tables.cpp
+++ b/imgui_tables.cpp
@@ -2383,11 +2383,11 @@ void ImGui::TableMergeDrawChannels(ImGuiTable* table)
struct MergeGroup
{
ImRect ClipRect;
- int ChannelsCount;
- ImBitArrayPtr ChannelsMask;
+ int ChannelsCount = 0;
+ ImBitArrayPtr ChannelsMask = NULL;
};
int merge_group_mask = 0x00;
- MergeGroup merge_groups[4] = {};
+ MergeGroup merge_groups[4];
// Use a reusable temp buffer for the merge masks as they are dynamically sized.
const int max_draw_channels = (4 + table->ColumnsCount * 2);
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index 9af348bf..0184895c 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -2096,7 +2096,8 @@ bool ImGui::DataTypeApplyFromText(const char* buf, ImGuiDataType data_type, void
memcpy(&data_backup, p_data, type_info->Size);
// Sanitize format
- // For float/double we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in, so force them into %f and %lf
+ // - For float/double we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in, so force them into %f and %lf
+ // - In theory could treat empty format as using default, but this would only cover rare/bizarre case of using InputScalar() + integer + format string without %.
char format_sanitized[32];
if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double)
format = type_info->ScanFmt;
@@ -3279,7 +3280,7 @@ const char* ImParseFormatFindEnd(const char* fmt)
}
// Extract the format out of a format string with leading or trailing decorations
-// fmt = "blah blah" -> return fmt
+// fmt = "blah blah" -> return ""
// fmt = "%.3f" -> return fmt
// fmt = "hello %.3f" -> return fmt + 6
// fmt = "%.3f hello" -> return buf written with "%.3f"
@@ -3287,7 +3288,7 @@ const char* ImParseFormatTrimDecorations(const char* fmt, char* buf, size_t buf_
{
const char* fmt_start = ImParseFormatFindStart(fmt);
if (fmt_start[0] != '%')
- return fmt;
+ return "";
const char* fmt_end = ImParseFormatFindEnd(fmt_start);
if (fmt_end[0] == 0) // If we only have leading decoration, we don't need to copy the data.
return fmt_start;
@@ -3405,9 +3406,14 @@ static inline ImGuiInputTextFlags InputScalar_DefaultCharsFilter(ImGuiDataType d
// However this may not be ideal for all uses, as some user code may break on out of bound values.
bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min, const void* p_clamp_max)
{
+ // FIXME: May need to clarify display behavior if format doesn't contain %.
+ // "%d" -> "%d" / "There are %d items" -> "%d" / "items" -> "%d" (fallback). Also see #6405
+ const ImGuiDataTypeInfo* type_info = DataTypeGetInfo(data_type);
char fmt_buf[32];
char data_buf[32];
format = ImParseFormatTrimDecorations(format, fmt_buf, IM_ARRAYSIZE(fmt_buf));
+ if (format[0] == 0)
+ format = type_info->PrintFmt;
DataTypeFormatString(data_buf, IM_ARRAYSIZE(data_buf), data_type, p_data, format);
ImStrTrimBlanks(data_buf);
@@ -3418,7 +3424,7 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG
if (TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags))
{
// Backup old value
- size_t data_type_size = DataTypeGetInfo(data_type)->Size;
+ size_t data_type_size = type_info->Size;
ImGuiDataTypeTempStorage data_backup;
memcpy(&data_backup, p_data, data_type_size);
@@ -6220,11 +6226,13 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
if (g.NavId == id && g.NavMoveDir == ImGuiDir_Left && is_open)
{
toggled = true;
+ NavClearPreferredPosForAxis(ImGuiAxis_X);
NavMoveRequestCancel();
}
if (g.NavId == id && g.NavMoveDir == ImGuiDir_Right && !is_open) // If there's something upcoming on the line we may want to give it the priority?
{
toggled = true;
+ NavClearPreferredPosForAxis(ImGuiAxis_X);
NavMoveRequestCancel();
}