From d97bbf19042c8addf7098978609de20fef9978e6 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 6 Nov 2024 18:08:15 +0100 Subject: [PATCH 1/8] Tabs, Style: made ImGuiCol_TabDimmedSelectedOverline alpha 0 (not visible) in default styles. --- docs/CHANGELOG.txt | 2 ++ imgui_draw.cpp | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 1e8016a13..abf339421 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -64,6 +64,8 @@ Other changes: - Fonts: removed const qualifiers from most font functions. - InputText: fixed a bug (regression in 1.91.2) where modifying text buffer within a callback would sometimes prevents further appending to the buffer. +- Tabs, Style: made ImGuiCol_TabDimmedSelectedOverline alpha 0 (not visible) in default + styles as the current look is not right (but ImGuiCol_TabSelectedOverline stays the same). - Log/Capture: better decorating of BeginMenu() and TabItem() output. - Log/Capture: a non terminated log ends automatically in the window which called it. - Log/Capture: added experimental io.ConfigWindowsCopyContentsWithCtrlC option to diff --git a/imgui_draw.cpp b/imgui_draw.cpp index ac6d02281..43a49eb29 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -218,7 +218,7 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst) colors[ImGuiCol_TabSelectedOverline] = colors[ImGuiCol_HeaderActive]; colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f); - colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); + colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.50f, 0.50f, 0.50f, 0.00f); colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); @@ -281,7 +281,7 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst) colors[ImGuiCol_TabSelectedOverline] = colors[ImGuiCol_HeaderActive]; colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f); - colors[ImGuiCol_TabDimmedSelectedOverline] = colors[ImGuiCol_HeaderActive]; + colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.53f, 0.53f, 0.87f, 0.00f); colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); @@ -345,7 +345,7 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst) colors[ImGuiCol_TabSelectedOverline] = colors[ImGuiCol_HeaderActive]; colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f); - colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.26f, 0.59f, 1.00f, 1.00f); + colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.26f, 0.59f, 1.00f, 0.00f); colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f); colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); From 3543dfda953beefd9add1316328e2c7cfb4aa637 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 6 Nov 2024 18:14:44 +0100 Subject: [PATCH 2/8] Docs: document removal of ImFont const qualifier as potentially breaking. --- docs/CHANGELOG.txt | 34 +++++++++++++++++----------------- imgui.cpp | 1 + 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index abf339421..ebc128a04 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -54,6 +54,7 @@ Breaking changes: consider updating to 1.91.4 first, then #define IMGUI_DISABLE_OBSOLETE_KEYIO, then update to latest. - Obsoleted ImGuiKey_COUNT (it is unusually error-prone/misleading since valid keys don't start at 0). Probably use ImGuiKey_NamedKey_BEGIN/ImGuiKey_NamedKey_END? +- Fonts: removed const qualifiers from most font functions in prevision for upcoming fonts improvements. Other changes: @@ -61,7 +62,6 @@ Other changes: between _Header and _HeaderHovered which was introduced v1.91 (#8106, #1861) - Buttons: using ImGuiItemFlags_ButtonRepeat makes default button behavior use PressedOnClick instead of PressedOnClickRelease when unspecified. -- Fonts: removed const qualifiers from most font functions. - InputText: fixed a bug (regression in 1.91.2) where modifying text buffer within a callback would sometimes prevents further appending to the buffer. - Tabs, Style: made ImGuiCol_TabDimmedSelectedOverline alpha 0 (not visible) in default @@ -74,9 +74,9 @@ Other changes: and (3) text output comes in submission order rather than spatial order. - Backends: DX12: Unmap() call specify written range. The range is informational and may be used by debug tools. -- Backends: SDL2: Replace SDL_Vulkan_GetDrawableSize() forward declaration with the - actual include. (#8095, #7967, #3190) [@sev-] -- Backends: SDL2, SDL3: SDL_EVENT_MOUSE_WHEEL event doesn't require dividing +- Backends: SDL2: Replace SDL_Vulkan_GetDrawableSize() forward declaration with the + actual include. (#8095, #7967, #3190) [@sev-] +- Backends: SDL2, SDL3: SDL_EVENT_MOUSE_WHEEL event doesn't require dividing by 100.0f on Emscripten target. (#4019, #6096, #1463) - Examples: SDL3+Vulkan: Added example. (#8084, #8085) - Examples: Android+OpenGL: Using ALooper_pollOnce() instead of ALooper_pollAll() @@ -88,7 +88,7 @@ Other changes: Breaking changes: -- Style: renamed ImGuiCol_NavHighlight to ImGuiCol_NavCursor, for consistency with +- Style: renamed ImGuiCol_NavHighlight to ImGuiCol_NavCursor, for consistency with newly exposed and reworked features. Kept inline redirection enum (will obsolete). - The typedef for ImTextureID now defaults to ImU64 instead of void*. (#1641) - This removes the requirement to redefine it for backends which are e.g. storing @@ -104,9 +104,9 @@ Breaking changes: - Note that you can always define ImTextureID to be your own high-level structures (with dedicated constructors and extra render parameters) if you like. - IO: moved ImGuiConfigFlags_NavEnableSetMousePos to standalone io.ConfigNavMoveSetMousePos bool. -- IO: moved ImGuiConfigFlags_NavNoCaptureKeyboard to standalone io.ConfigNavCaptureKeyboard bool +- IO: moved ImGuiConfigFlags_NavNoCaptureKeyboard to standalone io.ConfigNavCaptureKeyboard bool (note the inverted value!). (#2517, #2009) - Kept legacy names (will obsolete) + code that copies settings once the first time. + Kept legacy names (will obsolete) + code that copies settings once the first time. Dynamically changing the old value won't work. Switch to using the new value! Other changes: @@ -122,48 +122,48 @@ Other changes: - Set io.ConfigNavCursorVisibleAuto = true (default) to enable automatic toggling of cursor visibility (mouse click hide the cursor, arrow keys makes it visible). - Set io.ConfigNavCursorVisibleAlways to keep cursor always visible. - - Nav: added NavSetCursorVisible(bool visible) function to manipulate visibility of + - Nav: added NavSetCursorVisible(bool visible) function to manipulate visibility of navigation cursor (e.g. set default state, or after some actions). (#1074, #2048, #7237, #8059) - Nav: added io.ConfigNavEscapeClearFocusItem and io.ConfigNavEscapeClearFocusWindow to change how pressing Escape affects navigation. (#8059, #2048, #1074, #3200) - Set io.ConfigNavEscapeClearFocusItem = true (default) to clear focused item and highlight. - Set io.ConfigNavEscapeClearFocusItem = false for Escape to not have an effect. - Set io.ConfigNavEscapeClearFocusWindow = true to completely unfocus the dear imgui window, - is for some reason your app relies on imgui focus to take other decisions. + is for some reason your app relies on imgui focus to take other decisions. - Nav: pressing escape to hide the navigation cursor doesn't clear location, so it may be restored when Ctrl+Tabbing back into the same window later. - Nav: fixed Ctrl+Tab initiated with no focused window from skipping the top-most window. (#3200) - - Nav: navigation cursor is not rendered for items with `ImGuiItemFlags_NoNav`. Can be relevant + - Nav: navigation cursor is not rendered for items with `ImGuiItemFlags_NoNav`. Can be relevant when e.g activating a _NoNav item with mouse, then Ctrl+Tabbing back and forth. -- Disabled: clicking a disabled item focuses parent window. (#8064) +- Disabled: clicking a disabled item focuses parent window. (#8064) - InvisibleButton, Nav: fixed an issue when InvisibleButton() would be navigable into but not display navigation highlight. Properly navigation on it by default. (#8057) - InvisibleButton: added ImGuiButtonFlags_EnableNav to enable navigation. (#8057) -- Tooltips: fixed incorrect tooltip positioning when using keyboard/gamepad navigation +- Tooltips: fixed incorrect tooltip positioning when using keyboard/gamepad navigation (1.91.3 regression). (#8036) - DrawList: AddCallback() added an optional size parameter allowing to copy and store any amount of user data for usage by callbacks: (#6969, #4770, #7665) - If userdata_size == 0: we copy/store the 'userdata' argument as-is (existing behavior). It will be available unmodified in ImDrawCmd::UserCallbackData during render. - If userdata_size > 0, we copy/store 'userdata_size' bytes pointed to by 'userdata' (new behavior). - We store them in a buffer stored inside the drawlist. ImDrawCmd::UserCallbackData + We store them in a buffer stored inside the drawlist. ImDrawCmd::UserCallbackData will point inside that buffer so you have to retrieve data from there. Your callback may need to use ImDrawCmd::UserCallbackDataSize if you expect dynamically-sized data. - Note that we use a raw type-less copy. - Tables: fixed initial auto-sizing issue with synced-instances. (#8045, #7218) - InputText: fixed an issue with not declaring ownership of Delete/Backspace/Arrow keys, - preventing use of external shortcuts that are not guarded by an ActiveId check. (#8048) + preventing use of external shortcuts that are not guarded by an ActiveId check. (#8048) [@geertbleyen] -- InputText: ensure mouse cursor shape is set regardless of whether keyboard mode is +- InputText: ensure mouse cursor shape is set regardless of whether keyboard mode is enabled or not. (#6417) - InputScalar: added an assert to clarify that ImGuiInputTextFlags_EnterReturnsTrue is not supported by InputFloat, InputInt, InputScalar etc. widgets. It actually never was. (#8065, #3946) -- imgui_freetype: Added support for plutosvg (as an alternative to lunasvg) to render +- imgui_freetype: Added support for plutosvg (as an alternative to lunasvg) to render OpenType SVG fonts. Requires defining IMGUI_ENABLE_FREETYPE_PLUTOSVG along with IMGUI_ENABLE_FREETYPE. Providing headers/librairies for plutosvg + plutovg is up to you (see #7927 for help). (#7927, #7187, #6591, #6607) [@pthom] - Backends: DX11, DX12, SDLRenderer2/3. Vulkan, WGPU: expose selected state in - ImGui_ImplXXXX_RenderState structures during render loop user draw callbacks. + ImGui_ImplXXXX_RenderState structures during render loop user draw callbacks. (#6969, #5834, #7468, #3590) - Backends: DX9, DX10, DX11, DX12, OpenGL, Vulkan, WGPU: Changed default texture sampler to Clamp instead of Repeat/Wrap. (#7468, #7511, #5999, #5502, #7230) diff --git a/imgui.cpp b/imgui.cpp index 7f853fa0f..1f2dbc09a 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -440,6 +440,7 @@ CODE - read https://github.com/ocornut/imgui/issues/4921 - if you have trouble updating a very old codebase using legacy backend-specific key codes: consider updating to 1.91.4 first, then #define IMGUI_DISABLE_OBSOLETE_KEYIO, then update to latest. - obsoleted ImGuiKey_COUNT (it is unusually error-prone/misleading since valid keys don't start at 0). probably use ImGuiKey_NamedKey_BEGIN/ImGuiKey_NamedKey_END? + - fonts: removed const qualifiers from most font functions in prevision for upcoming font improvements. - 2024/10/18 (1.91.4) - renamed ImGuiCol_NavHighlight to ImGuiCol_NavCursor (for consistency with newly exposed and reworked features). Kept inline redirection enum (will obsolete). - 2024/10/14 (1.91.4) - moved ImGuiConfigFlags_NavEnableSetMousePos to standalone io.ConfigNavMoveSetMousePos bool. moved ImGuiConfigFlags_NavNoCaptureKeyboard to standalone io.ConfigNavCaptureKeyboard bool (note the inverted value!). From 3b683927ee623d010725c7664cd4e2c4ac20085c Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 7 Nov 2024 14:39:54 +0100 Subject: [PATCH 3/8] imgui_freetype: Fixed a crash in build font atlas when using merged fonts and the first font in a merged set has no loaded glyph. (#8081) --- docs/CHANGELOG.txt | 2 ++ misc/freetype/imgui_freetype.cpp | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index ebc128a04..a1655fdab 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -72,6 +72,8 @@ Other changes: automatically copy window contents into clipboard using CTRL+C. This is experimental because (1) it currently breaks on nested Begin/End, (2) text output quality varies, and (3) text output comes in submission order rather than spatial order. +- imgui_freetype: Fixed a crash in build font atlas when using merged fonts and the + first font in a merged set has no loaded glyph. (#8081) - Backends: DX12: Unmap() call specify written range. The range is informational and may be used by debug tools. - Backends: SDL2: Replace SDL_Vulkan_GetDrawableSize() forward declaration with the diff --git a/misc/freetype/imgui_freetype.cpp b/misc/freetype/imgui_freetype.cpp index 646a3b14e..c2d5f074c 100644 --- a/misc/freetype/imgui_freetype.cpp +++ b/misc/freetype/imgui_freetype.cpp @@ -681,8 +681,6 @@ bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, u for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) { ImFontBuildSrcDataFT& src_tmp = src_tmp_array[src_i]; - if (src_tmp.GlyphsCount == 0) - continue; // When merging fonts with MergeMode=true: // - We can have multiple input fonts writing into a same destination font. @@ -693,6 +691,9 @@ bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, u const float ascent = src_tmp.Font.Info.Ascender; const float descent = src_tmp.Font.Info.Descender; ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent); + + if (src_tmp.GlyphsCount == 0) + continue; const float font_off_x = cfg.GlyphOffset.x; const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent); From 17bd417a3d18610dbdaba4b56296bdcf87c7cbbf Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 7 Nov 2024 14:57:16 +0100 Subject: [PATCH 4/8] AddCustomRectFontGlyph: added storage for Colored bool in ImFontAtlasCustomRect. (#8133) --- imgui.h | 5 +++-- imgui_draw.cpp | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/imgui.h b/imgui.h index ec3d6c0a7..de6ec7b1c 100644 --- a/imgui.h +++ b/imgui.h @@ -3278,11 +3278,12 @@ struct ImFontAtlasCustomRect { unsigned short Width, Height; // Input // Desired rectangle dimension unsigned short X, Y; // Output // Packed position in Atlas - unsigned int GlyphID; // Input // For custom font glyphs only (ID < 0x110000) + unsigned int GlyphID : 31; // Input // For custom font glyphs only (ID < 0x110000) + unsigned int GlyphColored : 1; // Input // For custom font glyphs only: glyph is colored, removed tinting. float GlyphAdvanceX; // Input // For custom font glyphs only: glyph xadvance ImVec2 GlyphOffset; // Input // For custom font glyphs only: glyph display offset ImFont* Font; // Input // For custom font glyphs only: target font - ImFontAtlasCustomRect() { Width = Height = 0; X = Y = 0xFFFF; GlyphID = 0; GlyphAdvanceX = 0.0f; GlyphOffset = ImVec2(0, 0); Font = NULL; } + ImFontAtlasCustomRect() { Width = Height = 0; X = Y = 0xFFFF; GlyphID = 0; GlyphColored = 0; GlyphAdvanceX = 0.0f; GlyphOffset = ImVec2(0, 0); Font = NULL; } bool IsPacked() const { return X != 0xFFFF; } }; diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 43a49eb29..c0a5b5b75 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -2676,6 +2676,7 @@ int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int r.Width = (unsigned short)width; r.Height = (unsigned short)height; r.GlyphID = id; + r.GlyphColored = 0; // Set to 1 manually to mark glyph as colored // FIXME: No official API for that (#8133) r.GlyphAdvanceX = advance_x; r.GlyphOffset = offset; r.Font = font; @@ -3286,6 +3287,8 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas) ImVec2 uv0, uv1; atlas->CalcCustomRectUV(r, &uv0, &uv1); r->Font->AddGlyph(NULL, (ImWchar)r->GlyphID, r->GlyphOffset.x, r->GlyphOffset.y, r->GlyphOffset.x + r->Width, r->GlyphOffset.y + r->Height, uv0.x, uv0.y, uv1.x, uv1.y, r->GlyphAdvanceX); + if (r->GlyphColored) + r->Font->Glyphs.back().Colored = 1; } // Build all fonts lookup tables From 419a9ada16eb9b6d84ead4911b9c2a32820cfffb Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 7 Nov 2024 19:08:37 +0100 Subject: [PATCH 5/8] Ignore clang warning Wnontrivial-memaccess (#8129, #8135) Amend 88e2327 Use void* cast in backend where the memset are infrequent. --- backends/imgui_impl_metal.mm | 9 +-------- backends/imgui_impl_osx.mm | 9 +-------- backends/imgui_impl_vulkan.cpp | 6 +++--- imgui.cpp | 1 + imgui.h | 1 + imgui_tables.cpp | 1 + imgui_widgets.cpp | 1 + 7 files changed, 9 insertions(+), 19 deletions(-) diff --git a/backends/imgui_impl_metal.mm b/backends/imgui_impl_metal.mm index 102f6982a..12dc3d50f 100644 --- a/backends/imgui_impl_metal.mm +++ b/backends/imgui_impl_metal.mm @@ -38,13 +38,6 @@ #import #import -#if defined(__clang__) -#if __has_warning("-Wunknown-warning-option") -#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' -#endif -#pragma clang diagnostic ignored "-Wnontrivial-memaccess" // warning: first argument in call to 'memset' is a pointer to non-trivially copyable type -#endif - #pragma mark - Support classes // A wrapper around a MTLBuffer object that knows the last time it was reused @@ -83,7 +76,7 @@ struct ImGui_ImplMetal_Data { MetalContext* SharedMetalContext; - ImGui_ImplMetal_Data() { memset(this, 0, sizeof(*this)); } + ImGui_ImplMetal_Data() { memset((void*)this, 0, sizeof(*this)); } }; static ImGui_ImplMetal_Data* ImGui_ImplMetal_GetBackendData() { return ImGui::GetCurrentContext() ? (ImGui_ImplMetal_Data*)ImGui::GetIO().BackendRendererUserData : nullptr; } diff --git a/backends/imgui_impl_osx.mm b/backends/imgui_impl_osx.mm index 69108ca4a..c99ba1f06 100644 --- a/backends/imgui_impl_osx.mm +++ b/backends/imgui_impl_osx.mm @@ -27,13 +27,6 @@ #import #import -#if defined(__clang__) -#if __has_warning("-Wunknown-warning-option") -#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' -#endif -#pragma clang diagnostic ignored "-Wnontrivial-memaccess" // warning: first argument in call to 'memset' is a pointer to non-trivially copyable type -#endif - // CHANGELOG // (minor and older changes stripped away, please see git history for details) // 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO: @@ -94,7 +87,7 @@ struct ImGui_ImplOSX_Data id Monitor; NSWindow* Window; - ImGui_ImplOSX_Data() { memset(this, 0, sizeof(*this)); } + ImGui_ImplOSX_Data() { memset((void*)this, 0, sizeof(*this)); } }; static ImGui_ImplOSX_Data* ImGui_ImplOSX_GetBackendData() { return (ImGui_ImplOSX_Data*)ImGui::GetIO().BackendPlatformUserData; } diff --git a/backends/imgui_impl_vulkan.cpp b/backends/imgui_impl_vulkan.cpp index 4e4e332fc..d499ecb92 100644 --- a/backends/imgui_impl_vulkan.cpp +++ b/backends/imgui_impl_vulkan.cpp @@ -489,7 +489,7 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm wrb->Index = 0; wrb->Count = v->ImageCount; wrb->FrameRenderBuffers = (ImGui_ImplVulkan_FrameRenderBuffers*)IM_ALLOC(sizeof(ImGui_ImplVulkan_FrameRenderBuffers) * wrb->Count); - memset(wrb->FrameRenderBuffers, 0, sizeof(ImGui_ImplVulkan_FrameRenderBuffers) * wrb->Count); + memset((void*)wrb->FrameRenderBuffers, 0, sizeof(ImGui_ImplVulkan_FrameRenderBuffers) * wrb->Count); } IM_ASSERT(wrb->Count == v->ImageCount); wrb->Index = (wrb->Index + 1) % wrb->Count; @@ -1445,8 +1445,8 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V wd->SemaphoreCount = wd->ImageCount + 1; wd->Frames = (ImGui_ImplVulkanH_Frame*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_Frame) * wd->ImageCount); wd->FrameSemaphores = (ImGui_ImplVulkanH_FrameSemaphores*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_FrameSemaphores) * wd->SemaphoreCount); - memset(wd->Frames, 0, sizeof(wd->Frames[0]) * wd->ImageCount); - memset(wd->FrameSemaphores, 0, sizeof(wd->FrameSemaphores[0]) * wd->SemaphoreCount); + memset((void*)wd->Frames, 0, sizeof(wd->Frames[0]) * wd->ImageCount); + memset((void*)wd->FrameSemaphores, 0, sizeof(wd->FrameSemaphores[0]) * wd->SemaphoreCount); for (uint32_t i = 0; i < wd->ImageCount; i++) wd->Frames[i].Backbuffer = backbuffers[i]; } diff --git a/imgui.cpp b/imgui.cpp index 1f2dbc09a..2ea9417b4 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1135,6 +1135,7 @@ CODE #pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. #pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision #pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access +#pragma clang diagnostic ignored "-Wnontrivial-memaccess" // warning: first argument in call to 'memset' is a pointer to non-trivially copyable type #elif defined(__GNUC__) // We disable -Wpragmas because GCC doesn't provide a has_warning equivalent and some forks/patches may not follow the warning/version association. #pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind diff --git a/imgui.h b/imgui.h index de6ec7b1c..32425db89 100644 --- a/imgui.h +++ b/imgui.h @@ -135,6 +135,7 @@ Index of this file: #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant #pragma clang diagnostic ignored "-Wreserved-identifier" // warning: identifier '_Xxx' is reserved because it starts with '_' followed by a capital letter #pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access +#pragma clang diagnostic ignored "-Wnontrivial-memaccess" // warning: first argument in call to 'memset' is a pointer to non-trivially copyable type #elif defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 03007bb79..122cd87b1 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -229,6 +229,7 @@ Index of this file: #pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated #pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision #pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access +#pragma clang diagnostic ignored "-Wnontrivial-memaccess" // warning: first argument in call to 'memset' is a pointer to non-trivially copyable type #elif defined(__GNUC__) #pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind #pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 9d5724222..bb445d977 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -79,6 +79,7 @@ Index of this file: #pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated #pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision #pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access +#pragma clang diagnostic ignored "-Wnontrivial-memaccess" // warning: first argument in call to 'memset' is a pointer to non-trivially copyable type #elif defined(__GNUC__) #pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind #pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked From 01d27a4acde14c13e86adfcd0569e752f181e205 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 7 Nov 2024 16:58:50 +0100 Subject: [PATCH 6/8] Internals: added IM_LIKELY(), IM_UNLIKELY() helper macros (yet unused). Added ImFontGetCharAdvanceX() macro. --- imgui_draw.cpp | 16 +++++++++------- imgui_internal.h | 9 +++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index c0a5b5b75..7934949ec 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3847,7 +3847,7 @@ const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) return &Glyphs.Data[i]; } -// Wrapping skips upcoming blanks +// Trim trailing space and find beginning of next line static inline const char* CalcWordWrapNextLineStartA(const char* text, const char* text_end) { while (text < text_end && ImCharIsBlankA(*text)) @@ -3857,6 +3857,8 @@ static inline const char* CalcWordWrapNextLineStartA(const char* text, const cha return text; } +#define ImFontGetCharAdvanceX(_FONT, _CH) ((int)(_CH) < (_FONT)->IndexAdvanceX.Size ? (_FONT)->IndexAdvanceX.Data[_CH] : (_FONT)->FallbackAdvanceX) + // Simple word-wrapping for English, not full-featured. Please submit failing cases! // This will return the next location to wrap from. If no wrapping if necessary, this will fast-forward to e.g. text_end. // FIXME: Much possible improvements (don't cut things like "word !", "word!!!" but cut within "word,,,,", more sensible support for punctuations, support for Unicode punctuations, etc.) @@ -3909,7 +3911,7 @@ const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const c } } - const float char_width = ((int)c < IndexAdvanceX.Size ? IndexAdvanceX.Data[c] : FallbackAdvanceX); + const float char_width = ImFontGetCharAdvanceX(this, c); if (ImCharIsBlankW(c)) { if (inside_word) @@ -4014,7 +4016,7 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons continue; } - const float char_width = ((int)c < IndexAdvanceX.Size ? IndexAdvanceX.Data[c] : FallbackAdvanceX) * scale; + const float char_width = ImFontGetCharAdvanceX(this, c); if (line_width + char_width >= max_width) { s = prev_s; @@ -4063,9 +4065,9 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, Im if (y > clip_rect.w) return; - const float start_x = x; const float scale = size / FontSize; const float line_height = FontSize * scale; + const float origin_x = x; const bool word_wrap_enabled = (wrap_width > 0.0f); // Fast-forward to first visible line @@ -4124,11 +4126,11 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, Im { // Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature. if (!word_wrap_eol) - word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - (x - start_x)); + word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - (x - origin_x)); if (s >= word_wrap_eol) { - x = start_x; + x = origin_x; y += line_height; if (y > clip_rect.w) break; // break out of main loop @@ -4149,7 +4151,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, Im { if (c == '\n') { - x = start_x; + x = origin_x; y += line_height; if (y > clip_rect.w) break; // break out of main loop diff --git a/imgui_internal.h b/imgui_internal.h index 6d84f1027..9e6452bcb 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -260,6 +260,15 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer #define IM_FLOOR IM_TRUNC #endif +// Hint for branch prediction +#if (defined(__cplusplus) && (__cplusplus >= 202002L)) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 202002L)) +#define IM_LIKELY [[likely]] +#define IM_UNLIKELY [[unlikely]] +#else +#define IM_LIKELY +#define IM_UNLIKELY +#endif + // Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall #ifdef _MSC_VER #define IMGUI_CDECL __cdecl From 31b967f098dc53a6bb36f9be36f4a9e5d592f775 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 7 Nov 2024 19:35:00 +0100 Subject: [PATCH 7/8] Fix 01d27a4 (sorry I cherry-picked from wrong branch) --- imgui_draw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 7934949ec..48d42f392 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -4016,7 +4016,7 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons continue; } - const float char_width = ImFontGetCharAdvanceX(this, c); + const float char_width = ImFontGetCharAdvanceX(this, c) * scale; if (line_width + char_width >= max_width) { s = prev_s; From f401021d5a5d56fe2304056c391e78f81c8d4b8f Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 7 Nov 2024 19:38:30 +0100 Subject: [PATCH 8/8] Version 1.91.5 --- docs/CHANGELOG.txt | 14 +++++++++----- imgui.cpp | 2 +- imgui.h | 6 +++--- imgui_demo.cpp | 2 +- imgui_draw.cpp | 2 +- imgui_internal.h | 2 +- imgui_tables.cpp | 2 +- imgui_widgets.cpp | 2 +- 8 files changed, 18 insertions(+), 14 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index a1655fdab..ce752ca29 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -36,9 +36,11 @@ HOW TO UPDATE? - Please report any issue! ----------------------------------------------------------------------- - VERSION 1.91.5 WIP (In Progress) + VERSION 1.91.5 (Released 2024-11-07) ----------------------------------------------------------------------- +Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.91.5 + Breaking changes: - Commented out pre-1.87 IO system (equivalent to using IMGUI_DISABLE_OBSOLETE_KEYIO or IMGUI_DISABLE_OBSOLETE_FUNCTIONS before). @@ -47,8 +49,8 @@ Breaking changes: - Pre-1.87 backends are not supported: - backends need to call io.AddKeyEvent(), io.AddMouseEvent() instead of writing to io.KeysDown[], io.MouseDown[] fields. - backends need to call io.AddKeyAnalogEvent() for gamepad values instead of writing to io.NavInputs[] fields. - - For more reference: - - read 1.87 and 1.88 part of this section or read Changelog for 1.87 and 1.88. + - For more references: + - read 1.87 and 1.88 part of API BREAKING CHANGES in imgui.cpp or read Changelog for 1.87 and 1.88. - read https://github.com/ocornut/imgui/issues/4921 - If you have trouble updating a very old codebase using legacy backend-specific key codes: consider updating to 1.91.4 first, then #define IMGUI_DISABLE_OBSOLETE_KEYIO, then update to latest. @@ -66,12 +68,12 @@ Other changes: a callback would sometimes prevents further appending to the buffer. - Tabs, Style: made ImGuiCol_TabDimmedSelectedOverline alpha 0 (not visible) in default styles as the current look is not right (but ImGuiCol_TabSelectedOverline stays the same). -- Log/Capture: better decorating of BeginMenu() and TabItem() output. -- Log/Capture: a non terminated log ends automatically in the window which called it. - Log/Capture: added experimental io.ConfigWindowsCopyContentsWithCtrlC option to automatically copy window contents into clipboard using CTRL+C. This is experimental because (1) it currently breaks on nested Begin/End, (2) text output quality varies, and (3) text output comes in submission order rather than spatial order. +- Log/Capture: better decorating of BeginMenu() and TabItem() output. +- Log/Capture: a non terminated log ends automatically in the window which called it. - imgui_freetype: Fixed a crash in build font atlas when using merged fonts and the first font in a merged set has no loaded glyph. (#8081) - Backends: DX12: Unmap() call specify written range. The range is informational and @@ -88,6 +90,8 @@ Other changes: VERSION 1.91.4 (Released 2024-10-18) ----------------------------------------------------------------------- +Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.91.4 + Breaking changes: - Style: renamed ImGuiCol_NavHighlight to ImGuiCol_NavCursor, for consistency with diff --git a/imgui.cpp b/imgui.cpp index 2ea9417b4..4624c45d9 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.91.5 WIP +// dear imgui, v1.91.5 // (main code and documentation) // Help: diff --git a/imgui.h b/imgui.h index 32425db89..d6286592b 100644 --- a/imgui.h +++ b/imgui.h @@ -1,4 +1,4 @@ -// dear imgui, v1.91.5 WIP +// dear imgui, v1.91.5 // (headers) // Help: @@ -28,8 +28,8 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') -#define IMGUI_VERSION "1.91.5 WIP" -#define IMGUI_VERSION_NUM 19144 +#define IMGUI_VERSION "1.91.5" +#define IMGUI_VERSION_NUM 19150 #define IMGUI_HAS_TABLE /* diff --git a/imgui_demo.cpp b/imgui_demo.cpp index e28ca3b7a..76a06cc7d 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.91.5 WIP +// dear imgui, v1.91.5 // (demo code) // Help: diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 48d42f392..fa82a9419 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.91.5 WIP +// dear imgui, v1.91.5 // (drawing and font code) /* diff --git a/imgui_internal.h b/imgui_internal.h index 9e6452bcb..49452ab0a 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1,4 +1,4 @@ -// dear imgui, v1.91.5 WIP +// dear imgui, v1.91.5 // (internal structures/api) // You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility. diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 122cd87b1..e36e6f172 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.91.5 WIP +// dear imgui, v1.91.5 // (tables and columns code) /* diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index bb445d977..b5d66baa0 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.91.5 WIP +// dear imgui, v1.91.5 // (widgets code) /*