From 8be48a44f786dc16163112a6a17d4934ada625f9 Mon Sep 17 00:00:00 2001 From: Elie Michel Date: Mon, 25 Mar 2024 03:10:38 +0100 Subject: [PATCH 01/19] Backends: WebGPU: Avoid using -1u literal (#7436) --- backends/imgui_impl_wgpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backends/imgui_impl_wgpu.h b/backends/imgui_impl_wgpu.h index 9dc3ff290..2e19ea36e 100644 --- a/backends/imgui_impl_wgpu.h +++ b/backends/imgui_impl_wgpu.h @@ -32,7 +32,7 @@ struct ImGui_ImplWGPU_InitInfo ImGui_ImplWGPU_InitInfo() { PipelineMultisampleState.count = 1; - PipelineMultisampleState.mask = -1u; + PipelineMultisampleState.mask = UINT32_MAX; PipelineMultisampleState.alphaToCoverageEnabled = false; } }; From 38ddfb24f09f34022d457c71c3a4fbfc7a44c970 Mon Sep 17 00:00:00 2001 From: cfillion Date: Mon, 18 Mar 2024 01:39:36 -0400 Subject: [PATCH 02/19] Tables: Angled headers: fixed border hit box extending beyond non-scrollable tables. (#7416) --- docs/CHANGELOG.txt | 2 ++ imgui_tables.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 20e12f251..2399932f9 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -55,6 +55,8 @@ Other changes: - Windows: Scrollbar visibility decision uses current size when both size and contents size are submitted by API. (#7252) - Windows: Double-click to collapse may be disabled via key-ownership mechanism. (#7369) +- Tables: Angled headers: fixed border hit box extending beyond when used within + non-scrollable tables. (#7416) [@cfillion] - Menus, Popups: Fixed an issue where sibling menu popups re-opening in successive frames would erroneously close the window. While it is technically a popup issue it would generally manifest when fast moving the mouse bottom to top in a sub-menu. diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 5dbd0972a..b8e0d8628 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -1240,7 +1240,7 @@ void ImGui::TableUpdateBorders(ImGuiTable* table) ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent); const float hit_half_width = TABLE_RESIZE_SEPARATOR_HALF_THICKNESS; const float hit_y1 = (table->FreezeRowsCount >= 1 ? table->OuterRect.Min.y : table->WorkRect.Min.y) + table->AngledHeadersHeight; - const float hit_y2_body = ImMax(table->OuterRect.Max.y, hit_y1 + table_instance->LastOuterHeight); + const float hit_y2_body = ImMax(table->OuterRect.Max.y, hit_y1 + table_instance->LastOuterHeight - table->AngledHeadersHeight); const float hit_y2_head = hit_y1 + table_instance->LastTopHeadersRowHeight; for (int order_n = 0; order_n < table->ColumnsCount; order_n++) From 29ff159f941d3ea68512166193bfdf4cc71a8687 Mon Sep 17 00:00:00 2001 From: cfillion Date: Mon, 18 Mar 2024 02:10:46 -0400 Subject: [PATCH 03/19] Tables: Angled headers: fixed borders not moving back up after TableAngleHeadersRow stops being called. (#7416) --- docs/CHANGELOG.txt | 2 ++ imgui_tables.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 2399932f9..a12cdbf1e 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -57,6 +57,8 @@ Other changes: - Windows: Double-click to collapse may be disabled via key-ownership mechanism. (#7369) - Tables: Angled headers: fixed border hit box extending beyond when used within non-scrollable tables. (#7416) [@cfillion] +- Tables: Angled headers: fixed borders not moving back up after TableAngleHeadersRow() + stops being called. (#7416) [@cfillion] - Menus, Popups: Fixed an issue where sibling menu popups re-opening in successive frames would erroneously close the window. While it is technically a popup issue it would generally manifest when fast moving the mouse bottom to top in a sub-menu. diff --git a/imgui_tables.cpp b/imgui_tables.cpp index b8e0d8628..82d105025 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -498,6 +498,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG table->DeclColumnsCount = table->AngledHeadersCount = 0; if (previous_frame_active + 1 < g.FrameCount) table->IsActiveIdInTable = false; + table->AngledHeadersHeight = 0.0f; temp_data->AngledHeadersExtraWidth = 0.0f; // Using opaque colors facilitate overlapping lines of the grid, otherwise we'd need to improve TableDrawBorders() From f0802287db52d153d86f9be7a1b9fdc96a84662c Mon Sep 17 00:00:00 2001 From: cfillion Date: Mon, 18 Mar 2024 02:45:38 -0400 Subject: [PATCH 04/19] Tables: Angled headers: fixed table contents overflowing when a list clipper is used. (#7416) --- docs/CHANGELOG.txt | 2 ++ imgui_tables.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index a12cdbf1e..24f358665 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -59,6 +59,8 @@ Other changes: non-scrollable tables. (#7416) [@cfillion] - Tables: Angled headers: fixed borders not moving back up after TableAngleHeadersRow() stops being called. (#7416) [@cfillion] +- Tables: Angled headers: rounding header size to nearest integers, fixes some issues + when using clipper. - Menus, Popups: Fixed an issue where sibling menu popups re-opening in successive frames would erroneously close the window. While it is technically a popup issue it would generally manifest when fast moving the mouse bottom to top in a sub-menu. diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 82d105025..951b2479c 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -3186,7 +3186,7 @@ void ImGui::TableAngledHeadersRowEx(float angle, float max_label_width) // Calculate our base metrics and set angled headers data _before_ the first call to TableNextRow() // FIXME-STYLE: Would it be better for user to submit 'max_label_width' or 'row_height' ? One can be derived from the other. const float header_height = g.FontSize + g.Style.CellPadding.x * 2.0f; - const float row_height = ImFabs(ImRotate(ImVec2(max_label_width, flip_label ? +header_height : -header_height), cos_a, sin_a).y); + const float row_height = ImTrunc(ImFabs(ImRotate(ImVec2(max_label_width, flip_label ? +header_height : -header_height), cos_a, sin_a).y)); table->AngledHeadersHeight = row_height; table->AngledHeadersSlope = (sin_a != 0.0f) ? (cos_a / sin_a) : 0.0f; const ImVec2 header_angled_vector = unit_right * (row_height / -sin_a); // vector from bottom-left to top-left, and from bottom-right to top-right From cf4c10bef74888005c6c80091760d0a2f48a1b92 Mon Sep 17 00:00:00 2001 From: cfillion Date: Sun, 17 Mar 2024 08:48:52 -0400 Subject: [PATCH 05/19] Style: added ImGuiStyleVar_TabBorderSize, ImGuiStyleVar_TableAngledHeadersAngle. (#7411) --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 2 ++ imgui.h | 2 ++ 3 files changed, 6 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 24f358665..fcaa4665c 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -65,6 +65,8 @@ Other changes: frames would erroneously close the window. While it is technically a popup issue it would generally manifest when fast moving the mouse bottom to top in a sub-menu. (#7325, #7287, #7063) +- Style: Added ImGuiStyleVar_TabBorderSize, ImGuiStyleVar_TableAngledHeadersAngle for + consistency. (#7411) [@cfillion] - DrawList: Added AddConcavePolyFilled(), PathFillConcave() concave filling. (#760) [@thedmd] Note that only simple polygons (no self-intersections, no holes) are supported. - Docs: added more wiki links to headers of imgui.h/imgui.cpp to facilitate discovery diff --git a/imgui.cpp b/imgui.cpp index 5d8db20c4..ca0dc4a8f 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3130,7 +3130,9 @@ static const ImGuiDataVarInfo GStyleVarInfo[] = { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding + { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBorderSize) }, // ImGuiStyleVar_TabBorderSize { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBarBorderSize) }, // ImGuiStyleVar_TabBarBorderSize + { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TableAngledHeadersAngle)},// ImGuiStyleVar_TableAngledHeadersAngle { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, SelectableTextAlign) }, // ImGuiStyleVar_SelectableTextAlign { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, SeparatorTextBorderSize)},// ImGuiStyleVar_SeparatorTextBorderSize diff --git a/imgui.h b/imgui.h index cb833a1c2..3dd0a5e2a 100644 --- a/imgui.h +++ b/imgui.h @@ -1576,7 +1576,9 @@ enum ImGuiStyleVar_ ImGuiStyleVar_GrabMinSize, // float GrabMinSize ImGuiStyleVar_GrabRounding, // float GrabRounding ImGuiStyleVar_TabRounding, // float TabRounding + ImGuiStyleVar_TabBorderSize, // float TabBorderSize ImGuiStyleVar_TabBarBorderSize, // float TabBarBorderSize + ImGuiStyleVar_TableAngledHeadersAngle,// float TableAngledHeadersAngle ImGuiStyleVar_ButtonTextAlign, // ImVec2 ButtonTextAlign ImGuiStyleVar_SelectableTextAlign, // ImVec2 SelectableTextAlign ImGuiStyleVar_SeparatorTextBorderSize,// float SeparatorTextBorderSize From 5c5ae806aa1dfac9ebb01984d565fd8fe8b04b94 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 26 Mar 2024 14:15:35 +0900 Subject: [PATCH 06/19] Comments --- imgui.h | 18 ++++++++++++------ imgui_demo.cpp | 5 +++-- imgui_tables.cpp | 5 +++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/imgui.h b/imgui.h index 3dd0a5e2a..b65b6973c 100644 --- a/imgui.h +++ b/imgui.h @@ -175,8 +175,9 @@ struct ImGuiViewport; // A Platform Window (always only one in 'ma // Enumerations // - We don't use strongly typed enums much because they add constraints (can't extend in private code, can't store typed in bit fields, extra casting on iteration) // - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists! -// In Visual Studio IDE: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. -// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments. +// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. +// - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments. +// - In Visual Studio Code: CTRL+click can follow symbols inside comments. enum ImGuiKey : int; // -> enum ImGuiKey // Enum: A key identifier (ImGuiKey_XXX or ImGuiMod_XXX value) enum ImGuiMouseSource : int; // -> enum ImGuiMouseSource // Enum; A mouse input source identifier (Mouse, TouchScreen, Pen) typedef int ImGuiCol; // -> enum ImGuiCol_ // Enum: A color identifier for styling @@ -191,8 +192,9 @@ typedef int ImGuiTableBgTarget; // -> enum ImGuiTableBgTarget_ // Enum: A // Flags (declared as int to allow using as flags without overhead, and to not pollute the top of this file) // - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists! -// In Visual Studio IDE: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. -// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments. +// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. +// - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments. +// - In Visual Studio Code: CTRL+click can follow symbols inside comments. typedef int ImDrawFlags; // -> enum ImDrawFlags_ // Flags: for ImDrawList functions typedef int ImDrawListFlags; // -> enum ImDrawListFlags_ // Flags: for ImDrawList instance typedef int ImFontAtlasFlags; // -> enum ImFontAtlasFlags_ // Flags: for ImFontAtlas build @@ -1547,8 +1549,9 @@ enum ImGuiCol_ // - The enum only refers to fields of ImGuiStyle which makes sense to be pushed/popped inside UI code. // During initialization or between frames, feel free to just poke into ImGuiStyle directly. // - Tip: Use your programming IDE navigation facilities on the names in the _second column_ below to find the actual members and their description. -// In Visual Studio IDE: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. -// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments. +// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. +// - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments. +// - In Visual Studio Code: CTRL+click can follow symbols inside comments. // - When changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type. enum ImGuiStyleVar_ { @@ -2045,6 +2048,9 @@ struct ImGuiStyle //----------------------------------------------------------------------------- // Communicate most settings and inputs/outputs to Dear ImGui using this structure. // Access via ImGui::GetIO(). Read 'Programmer guide' section in .cpp file for general usage. +// It is generally expected that: +// - initialization: backends and user code writes to ImGuiIO. +// - main loop: backends writes to ImGuiIO, user code and imgui code reads from ImGuiIO. //----------------------------------------------------------------------------- // [Internal] Storage used by IsKeyDown(), IsKeyPressed() etc functions. diff --git a/imgui_demo.cpp b/imgui_demo.cpp index a191a1df5..5c33c0a1f 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -54,8 +54,9 @@ // Because we can't assume anything about your support of maths operators, we cannot use them in imgui_demo.cpp. // Navigating this file: -// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. -// - With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments. +// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. +// - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments. +// - In Visual Studio Code: CTRL+click can follow symbols inside comments. /* diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 951b2479c..443321cd8 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -24,8 +24,9 @@ Index of this file: */ // Navigating this file: -// - In Visual Studio IDE: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. -// - With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments. +// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. +// - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments. +// - In Visual Studio Code: CTRL+click can follow symbols inside comments. //----------------------------------------------------------------------------- // [SECTION] Commentary From 37b37fc2a3ed2fda41cdac42b21b95fe7372202f Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 27 Mar 2024 10:50:55 +0900 Subject: [PATCH 07/19] DrawList: Allow AddText() to accept null ranges. (#3615, 7391) --- docs/CHANGELOG.txt | 1 + imgui.h | 8 ++++---- imgui_demo.cpp | 2 +- imgui_draw.cpp | 5 +++-- imgui_tables.cpp | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index fcaa4665c..05b0f9af8 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -69,6 +69,7 @@ Other changes: consistency. (#7411) [@cfillion] - DrawList: Added AddConcavePolyFilled(), PathFillConcave() concave filling. (#760) [@thedmd] Note that only simple polygons (no self-intersections, no holes) are supported. +- DrawList: Allow AddText() to accept null ranges. (#3615, 7391) - Docs: added more wiki links to headers of imgui.h/imgui.cpp to facilitate discovery of interesting resources, because github doesn't allow Wiki to be crawled by search engines. - This is the main wiki: https://github.com/ocornut/imgui/wiki diff --git a/imgui.h b/imgui.h index b65b6973c..782bf891f 100644 --- a/imgui.h +++ b/imgui.h @@ -28,7 +28,7 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') #define IMGUI_VERSION "1.90.5 WIP" -#define IMGUI_VERSION_NUM 19046 +#define IMGUI_VERSION_NUM 19047 #define IMGUI_HAS_TABLE /* @@ -177,7 +177,7 @@ struct ImGuiViewport; // A Platform Window (always only one in 'ma // - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists! // - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. // - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments. -// - In Visual Studio Code: CTRL+click can follow symbols inside comments. +// - In VS Code, CLion, etc.: CTRL+click can follow symbols inside comments. enum ImGuiKey : int; // -> enum ImGuiKey // Enum: A key identifier (ImGuiKey_XXX or ImGuiMod_XXX value) enum ImGuiMouseSource : int; // -> enum ImGuiMouseSource // Enum; A mouse input source identifier (Mouse, TouchScreen, Pen) typedef int ImGuiCol; // -> enum ImGuiCol_ // Enum: A color identifier for styling @@ -194,7 +194,7 @@ typedef int ImGuiTableBgTarget; // -> enum ImGuiTableBgTarget_ // Enum: A // - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists! // - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. // - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments. -// - In Visual Studio Code: CTRL+click can follow symbols inside comments. +// - In VS Code, CLion, etc.: CTRL+click can follow symbols inside comments. typedef int ImDrawFlags; // -> enum ImDrawFlags_ // Flags: for ImDrawList functions typedef int ImDrawListFlags; // -> enum ImDrawListFlags_ // Flags: for ImDrawList instance typedef int ImFontAtlasFlags; // -> enum ImFontAtlasFlags_ // Flags: for ImFontAtlas build @@ -1551,7 +1551,7 @@ enum ImGuiCol_ // - Tip: Use your programming IDE navigation facilities on the names in the _second column_ below to find the actual members and their description. // - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. // - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments. -// - In Visual Studio Code: CTRL+click can follow symbols inside comments. +// - In VS Code, CLion, etc.: CTRL+click can follow symbols inside comments. // - When changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type. enum ImGuiStyleVar_ { diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 5c33c0a1f..f739dfabe 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -56,7 +56,7 @@ // Navigating this file: // - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. // - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments. -// - In Visual Studio Code: CTRL+click can follow symbols inside comments. +// - In VS Code, CLion, etc.: CTRL+click can follow symbols inside comments. /* diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 405684f54..83e29e10f 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1613,10 +1613,11 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, if ((col & IM_COL32_A_MASK) == 0) return; + // Accept null ranges + if (text_begin == text_end || text_begin[0] == 0) + return; if (text_end == NULL) text_end = text_begin + strlen(text_begin); - if (text_begin == text_end) - return; // Pull default font/size from the shared ImDrawListSharedData instance if (font == NULL) diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 443321cd8..88433da28 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -26,7 +26,7 @@ Index of this file: // Navigating this file: // - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. // - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments. -// - In Visual Studio Code: CTRL+click can follow symbols inside comments. +// - In VS Code, CLion, etc.: CTRL+click can follow symbols inside comments. //----------------------------------------------------------------------------- // [SECTION] Commentary From 976dc239656295094709f107c8a3e1974328c605 Mon Sep 17 00:00:00 2001 From: cfillion Date: Mon, 25 Mar 2024 10:02:40 -0400 Subject: [PATCH 08/19] Windows: extend outer resize borders to the edges when there are no corner grips. (#7440, #1710) --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 05b0f9af8..12aa33f58 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -55,6 +55,8 @@ Other changes: - Windows: Scrollbar visibility decision uses current size when both size and contents size are submitted by API. (#7252) - Windows: Double-click to collapse may be disabled via key-ownership mechanism. (#7369) +- Windows: Extend outer resize borders to the edges when there are no corner grips. + Essentially affects resizable child windows. (#7440, #1710) [@cfillion] - Tables: Angled headers: fixed border hit box extending beyond when used within non-scrollable tables. (#7416) [@cfillion] - Tables: Angled headers: fixed borders not moving back up after TableAngleHeadersRow() diff --git a/imgui.cpp b/imgui.cpp index ca0dc4a8f..c7da9d3a4 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5901,7 +5901,7 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& si int ret_auto_fit_mask = 0x00; const float grip_draw_size = IM_TRUNC(ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f)); - const float grip_hover_inner_size = IM_TRUNC(grip_draw_size * 0.75f); + const float grip_hover_inner_size = (resize_grip_count > 0) ? IM_TRUNC(grip_draw_size * 0.75f) : 0.0f; const float grip_hover_outer_size = g.IO.ConfigWindowsResizeFromEdges ? WINDOWS_HOVER_PADDING : 0.0f; ImRect clamp_rect = visibility_rect; From 515b437c0845dc696e60aaca890f9ee54903aa95 Mon Sep 17 00:00:00 2001 From: cfillion Date: Mon, 25 Mar 2024 13:31:46 -0400 Subject: [PATCH 09/19] Child windows: look at the parent window's flags to decide whether to clamp child resizes. (#7440, #1710) --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 12aa33f58..e6f53f105 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -57,6 +57,8 @@ Other changes: - Windows: Double-click to collapse may be disabled via key-ownership mechanism. (#7369) - Windows: Extend outer resize borders to the edges when there are no corner grips. Essentially affects resizable child windows. (#7440, #1710) [@cfillion] +- Windows: Resizing logic for child windows evaluates whether per-axis clamping should be + applied based on parent scrollbars, not child scrollbars. (#7440, #1710) [@cfillion] - Tables: Angled headers: fixed border hit box extending beyond when used within non-scrollable tables. (#7416) [@cfillion] - Tables: Angled headers: fixed borders not moving back up after TableAngleHeadersRow() diff --git a/imgui.cpp b/imgui.cpp index c7da9d3a4..bf5765b47 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6029,10 +6029,12 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& si border_target = ImClamp(border_target, clamp_min, clamp_max); if (flags & ImGuiWindowFlags_ChildWindow) // Clamp resizing of childs within parent { - if ((flags & (ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar)) == 0 || (flags & ImGuiWindowFlags_NoScrollbar)) - border_target.x = ImClamp(border_target.x, window->ParentWindow->InnerClipRect.Min.x, window->ParentWindow->InnerClipRect.Max.x); - if (flags & ImGuiWindowFlags_NoScrollbar) - border_target.y = ImClamp(border_target.y, window->ParentWindow->InnerClipRect.Min.y, window->ParentWindow->InnerClipRect.Max.y); + ImGuiWindowFlags parent_flags = window->ParentWindow->Flags; + const ImRect parent_rect = window->ParentWindow->InnerClipRect; + if ((parent_flags & (ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar)) == 0 || (parent_flags & ImGuiWindowFlags_NoScrollbar)) + border_target.x = ImClamp(border_target.x, parent_rect.Min.x, parent_rect.Max.x); + if (parent_flags & ImGuiWindowFlags_NoScrollbar) + border_target.y = ImClamp(border_target.y, parent_rect.Min.y, parent_rect.Max.y); } if (!ignore_resize) CalcResizePosSizeFromAnyCorner(window, border_target, ImMin(def.SegmentN1, def.SegmentN2), &pos_target, &size_target); From 742e53434f4389536b1c723f5d232b7f15415a11 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 27 Mar 2024 11:36:57 +0900 Subject: [PATCH 10/19] Child Windows: adjust resizing limits to match window padding rather than inner clipping rectangle. (#7440) --- docs/CHANGELOG.txt | 9 +++++---- imgui.cpp | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index e6f53f105..74a201a6a 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -55,10 +55,11 @@ Other changes: - Windows: Scrollbar visibility decision uses current size when both size and contents size are submitted by API. (#7252) - Windows: Double-click to collapse may be disabled via key-ownership mechanism. (#7369) -- Windows: Extend outer resize borders to the edges when there are no corner grips. - Essentially affects resizable child windows. (#7440, #1710) [@cfillion] -- Windows: Resizing logic for child windows evaluates whether per-axis clamping should be - applied based on parent scrollbars, not child scrollbars. (#7440, #1710) [@cfillion] +- Windows: BeginChild(): Extend outer resize borders to the edges when there are no corner + grips. Essentially affects resizable child windows. (#7440, #1710) [@cfillion] +- Windows: BeginChild(): Resizing logic for child windows evaluates whether per-axis clamping + should be applied based on parent scrollbars, not child scrollbars. (#7440, #1710) [@cfillion] + Adjust those resizing limits to match window padding rather than inner clipping rectangle. - Tables: Angled headers: fixed border hit box extending beyond when used within non-scrollable tables. (#7416) [@cfillion] - Tables: Angled headers: fixed borders not moving back up after TableAngleHeadersRow() diff --git a/imgui.cpp b/imgui.cpp index bf5765b47..5832b502f 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6030,11 +6030,12 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& si if (flags & ImGuiWindowFlags_ChildWindow) // Clamp resizing of childs within parent { ImGuiWindowFlags parent_flags = window->ParentWindow->Flags; - const ImRect parent_rect = window->ParentWindow->InnerClipRect; + ImRect border_limit_rect = window->ParentWindow->InnerRect; + border_limit_rect.Expand(ImVec2(-ImMax(window->WindowPadding.x, window->WindowBorderSize), -ImMax(window->WindowPadding.y, window->WindowBorderSize))); if ((parent_flags & (ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar)) == 0 || (parent_flags & ImGuiWindowFlags_NoScrollbar)) - border_target.x = ImClamp(border_target.x, parent_rect.Min.x, parent_rect.Max.x); + border_target.x = ImClamp(border_target.x, border_limit_rect.Min.x, border_limit_rect.Max.x); if (parent_flags & ImGuiWindowFlags_NoScrollbar) - border_target.y = ImClamp(border_target.y, parent_rect.Min.y, parent_rect.Max.y); + border_target.y = ImClamp(border_target.y, border_limit_rect.Min.y, border_limit_rect.Max.y); } if (!ignore_resize) CalcResizePosSizeFromAnyCorner(window, border_target, ImMin(def.SegmentN1, def.SegmentN2), &pos_target, &size_target); From 9638c2839a12602321be73926aa93fcc0bc37480 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 27 Mar 2024 12:00:50 +0900 Subject: [PATCH 11/19] Internals: adding ImGuiNavMoveFlags_NoClearActiveId even though there's currently no satisfying way to take advantage of it. (#1418) --- imgui.cpp | 6 ++++-- imgui_internal.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 5832b502f..0b0c583c7 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -12303,8 +12303,10 @@ void ImGui::NavMoveRequestApplyResult() g.NavLastValidSelectionUserData = ImGuiSelectionUserData_Invalid; } - // FIXME: Could become optional e.g. ImGuiNavMoveFlags_NoClearActiveId if we later want to apply navigation requests without altering active input. - if (g.ActiveId != result->ID) + // Clear active id unless requested not to + // FIXME: ImGuiNavMoveFlags_NoClearActiveId is currently unused as we don't have a clear strategy to preserve active id after interaction, + // so this is mostly provided as a gateway for further experiments (see #1418, #2890) + if (g.ActiveId != result->ID && (g.NavMoveFlags & ImGuiNavMoveFlags_NoClearActiveId) == 0) ClearActiveID(); // Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId) diff --git a/imgui_internal.h b/imgui_internal.h index cb2518367..25d85f4f1 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1578,6 +1578,7 @@ enum ImGuiNavMoveFlags_ ImGuiNavMoveFlags_Activate = 1 << 12, // Activate/select target item. ImGuiNavMoveFlags_NoSelect = 1 << 13, // Don't trigger selection by not setting g.NavJustMovedTo ImGuiNavMoveFlags_NoSetNavHighlight = 1 << 14, // Do not alter the visible state of keyboard vs mouse nav highlight + ImGuiNavMoveFlags_NoClearActiveId = 1 << 15, // (Experimental) Do not clear active id when applying move result }; enum ImGuiNavLayer From 25a492f3307f646a34cc4c159ab846e83003cff6 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 29 Mar 2024 19:09:55 +0900 Subject: [PATCH 12/19] ProgressBar: Fixed passing fraction==NaN from leading to a crash. (#7451) --- docs/CHANGELOG.txt | 1 + imgui_widgets.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 74a201a6a..bc5822f99 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -70,6 +70,7 @@ Other changes: frames would erroneously close the window. While it is technically a popup issue it would generally manifest when fast moving the mouse bottom to top in a sub-menu. (#7325, #7287, #7063) +- ProgressBar: Fixed passing fraction==NaN from leading to a crash. (#7451) - Style: Added ImGuiStyleVar_TabBorderSize, ImGuiStyleVar_TableAngledHeadersAngle for consistency. (#7411) [@cfillion] - DrawList: Added AddConcavePolyFilled(), PathFillConcave() concave filling. (#760) [@thedmd] diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index d83a080f5..f1ffbf0f5 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1288,12 +1288,15 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over if (!ItemAdd(bb, 0)) return; - // Render + // Out of courtesy we accept a NaN fraction without crashing fraction = ImSaturate(fraction); + const float fraction_not_nan = (fraction == fraction) ? fraction : 0.0f; + + // Render RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize)); - const ImVec2 fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction), bb.Max.y); - RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), 0.0f, fraction, style.FrameRounding); + const ImVec2 fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction_not_nan), bb.Max.y); + RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), 0.0f, fraction_not_nan, style.FrameRounding); // Default displaying the fraction as percentage string, but user can override it char overlay_buf[32]; From d3c3514a59bb31406c954c2b525f330e9d167845 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 29 Mar 2024 19:39:05 +0900 Subject: [PATCH 13/19] Tables: Fixed auto-width columns when using synced-instances of same table. (#7218) --- docs/CHANGELOG.txt | 2 ++ imgui_demo.cpp | 1 + imgui_tables.cpp | 19 +++++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index bc5822f99..4d783dc03 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -60,6 +60,8 @@ Other changes: - Windows: BeginChild(): Resizing logic for child windows evaluates whether per-axis clamping should be applied based on parent scrollbars, not child scrollbars. (#7440, #1710) [@cfillion] Adjust those resizing limits to match window padding rather than inner clipping rectangle. +- Tables: Fixed auto-width columns when using synced-instances of same table, width of + one instance would bleed into next one instead of sharing their widths. (#7218) - Tables: Angled headers: fixed border hit box extending beyond when used within non-scrollable tables. (#7416) [@cfillion] - Tables: Angled headers: fixed borders not moving back up after TableAngleHeadersRow() diff --git a/imgui_demo.cpp b/imgui_demo.cpp index f739dfabe..7297d5e7c 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -5478,6 +5478,7 @@ static void ShowDemoWindowTables() HelpMarker("Multiple tables with the same identifier will share their settings, width, visibility, order etc."); static ImGuiTableFlags flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_NoSavedSettings; + ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable); ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY); ImGui::CheckboxFlags("ImGuiTableFlags_SizingFixedFit", &flags, ImGuiTableFlags_SizingFixedFit); ImGui::CheckboxFlags("ImGuiTableFlags_HighlightHoveredColumn", &flags, ImGuiTableFlags_HighlightHoveredColumn); diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 88433da28..1fe1a721b 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -1068,6 +1068,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table) // - ClipRect.Max.x: using WorkMaxX instead of MaxX (aka including padding) makes things more consistent when resizing down, tho slightly detrimental to visibility in very-small column. // - ClipRect.Max.x: using MaxX makes it easier for header to receive hover highlight with no discontinuity and display sorting arrow. // - FIXME-TABLE: We want equal width columns to have equal (ClipRect.Max.x - WorkMinX) width, which means ClipRect.max.x cannot stray off host_clip_rect.Max.x else right-most column may appear shorter. + const float previous_instance_work_min_x = column->WorkMinX; column->WorkMinX = column->MinX + table->CellPaddingX + table->CellSpacingX1; column->WorkMaxX = column->MaxX - table->CellPaddingX - table->CellSpacingX2; // Expected max column->ItemWidth = ImTrunc(column->WidthGiven * 0.65f); @@ -1120,8 +1121,22 @@ void ImGui::TableUpdateLayout(ImGuiTable* table) // column->WorkMinX = ImLerp(column->WorkMinX, ImMax(column->StartX, column->MaxX - column->ContentWidthRowsUnfrozen), 0.5f); // Reset content width variables - column->ContentMaxXFrozen = column->ContentMaxXUnfrozen = column->WorkMinX; - column->ContentMaxXHeadersUsed = column->ContentMaxXHeadersIdeal = column->WorkMinX; + if (table->InstanceCurrent == 0) + { + column->ContentMaxXFrozen = column->WorkMinX; + column->ContentMaxXUnfrozen = column->WorkMinX; + column->ContentMaxXHeadersUsed = column->WorkMinX; + column->ContentMaxXHeadersIdeal = column->WorkMinX; + } + else + { + // As we store an absolute value to make per-cell updates faster, we need to offset values used for width computation. + const float offset_from_previous_instance = column->WorkMinX - previous_instance_work_min_x; + column->ContentMaxXFrozen += offset_from_previous_instance; + column->ContentMaxXUnfrozen += offset_from_previous_instance; + column->ContentMaxXHeadersUsed += offset_from_previous_instance; + column->ContentMaxXHeadersIdeal += offset_from_previous_instance; + } // Don't decrement auto-fit counters until container window got a chance to submit its items if (table->HostSkipItems == false) From 9a2b598ec1eeadd316650bc3081c735d0b6e15a4 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 3 Apr 2024 10:18:49 +0900 Subject: [PATCH 14/19] ListBox: Fixed text-baseline offset when using SameLine()+Text() after a labeled ListBox(). Visible in demo->basic->listbox --- docs/CHANGELOG.txt | 1 + imgui_demo.cpp | 2 ++ imgui_widgets.cpp | 1 + 3 files changed, 4 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 4d783dc03..45339c010 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -73,6 +73,7 @@ Other changes: it would generally manifest when fast moving the mouse bottom to top in a sub-menu. (#7325, #7287, #7063) - ProgressBar: Fixed passing fraction==NaN from leading to a crash. (#7451) +- ListBox: Fixed text-baseline offset when using SameLine()+Text() after a labeled ListBox(). - Style: Added ImGuiStyleVar_TabBorderSize, ImGuiStyleVar_TableAngledHeadersAngle for consistency. (#7411) [@cfillion] - DrawList: Added AddConcavePolyFilled(), PathFillConcave() concave filling. (#760) [@thedmd] diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 7297d5e7c..ad0be025a 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1289,6 +1289,7 @@ static void ShowDemoWindowWidgets() } ImGui::EndListBox(); } + ImGui::SameLine(); HelpMarker("Here we are sharing selection state between both boxes."); // Custom size: use all width, 5 items tall ImGui::Text("Full-width:"); @@ -1823,6 +1824,7 @@ static void ShowDemoWindowWidgets() static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f }; ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr)); ImGui::PlotHistogram("Histogram", arr, IM_ARRAYSIZE(arr), 0, NULL, 0.0f, 1.0f, ImVec2(0, 80.0f)); + //ImGui::SameLine(); HelpMarker("Consider using ImPlot instead!"); // Fill an array of contiguous float values to plot // Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index f1ffbf0f5..c8ac26625 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -6930,6 +6930,7 @@ bool ImGui::BeginListBox(const char* label, const ImVec2& size_arg) ImVec2 label_pos = ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y); RenderText(label_pos, label); window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, label_pos + label_size); + AlignTextToFramePadding(); } BeginChild(id, frame_bb.GetSize(), ImGuiChildFlags_FrameStyle); From 0bf134a8e2ef0b00d1070e4c8a30e552168cc74d Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 3 Apr 2024 10:42:57 +0900 Subject: [PATCH 15/19] Refactor moving ID stack functions to their own section. --- imgui.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 0b0c583c7..1d5555916 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -77,6 +77,7 @@ CODE // [SECTION] RENDER HELPERS // [SECTION] INITIALIZATION, SHUTDOWN // [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!) +// [SECTION] ID STACK // [SECTION] INPUTS // [SECTION] ERROR CHECKING // [SECTION] ITEM SUBMISSION @@ -7983,6 +7984,22 @@ ImGuiStorage* ImGui::GetStateStorage() return window->DC.StateStorage; } +bool ImGui::IsRectVisible(const ImVec2& size) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->ClipRect.Overlaps(ImRect(window->DC.CursorPos, window->DC.CursorPos + size)); +} + +bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->ClipRect.Overlaps(ImRect(rect_min, rect_max)); +} + +//----------------------------------------------------------------------------- +// [SECTION] ID STACK +//----------------------------------------------------------------------------- + void ImGui::PushID(const char* str_id) { ImGuiContext& g = *GImGui; @@ -8071,19 +8088,6 @@ ImGuiID ImGui::GetID(const void* ptr_id) return window->GetID(ptr_id); } -bool ImGui::IsRectVisible(const ImVec2& size) -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->ClipRect.Overlaps(ImRect(window->DC.CursorPos, window->DC.CursorPos + size)); -} - -bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max) -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->ClipRect.Overlaps(ImRect(rect_min, rect_max)); -} - - //----------------------------------------------------------------------------- // [SECTION] INPUTS //----------------------------------------------------------------------------- From f959c417fecf49a98acbabbfacab65a651c81e7d Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 3 Apr 2024 10:47:15 +0900 Subject: [PATCH 16/19] Refactor moving ID stack functions to their own section (part 2) --- imgui.cpp | 80 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 1d5555916..64655f15d 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3782,45 +3782,6 @@ ImGuiWindow::~ImGuiWindow() ColumnsStorage.clear_destruct(); } -ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end) -{ - ImGuiID seed = IDStack.back(); - ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); - ImGuiContext& g = *Ctx; - if (g.DebugHookIdInfo == id) - ImGui::DebugHookIdInfo(id, ImGuiDataType_String, str, str_end); - return id; -} - -ImGuiID ImGuiWindow::GetID(const void* ptr) -{ - ImGuiID seed = IDStack.back(); - ImGuiID id = ImHashData(&ptr, sizeof(void*), seed); - ImGuiContext& g = *Ctx; - if (g.DebugHookIdInfo == id) - ImGui::DebugHookIdInfo(id, ImGuiDataType_Pointer, ptr, NULL); - return id; -} - -ImGuiID ImGuiWindow::GetID(int n) -{ - ImGuiID seed = IDStack.back(); - ImGuiID id = ImHashData(&n, sizeof(n), seed); - ImGuiContext& g = *Ctx; - if (g.DebugHookIdInfo == id) - ImGui::DebugHookIdInfo(id, ImGuiDataType_S32, (void*)(intptr_t)n, NULL); - return id; -} - -// This is only used in rare/specific situations to manufacture an ID out of nowhere. -ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs) -{ - ImGuiID seed = IDStack.back(); - ImRect r_rel = ImGui::WindowRectAbsToRel(this, r_abs); - ImGuiID id = ImHashData(&r_rel, sizeof(r_rel), seed); - return id; -} - static void SetCurrentWindow(ImGuiWindow* window) { ImGuiContext& g = *GImGui; @@ -8000,6 +7961,47 @@ bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max) // [SECTION] ID STACK //----------------------------------------------------------------------------- +// This is one of the very rare legacy case where we use ImGuiWindow methods, +// it should ideally be flattened at some point but it's been used a lots by widgets. +ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end) +{ + ImGuiID seed = IDStack.back(); + ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); + ImGuiContext& g = *Ctx; + if (g.DebugHookIdInfo == id) + ImGui::DebugHookIdInfo(id, ImGuiDataType_String, str, str_end); + return id; +} + +ImGuiID ImGuiWindow::GetID(const void* ptr) +{ + ImGuiID seed = IDStack.back(); + ImGuiID id = ImHashData(&ptr, sizeof(void*), seed); + ImGuiContext& g = *Ctx; + if (g.DebugHookIdInfo == id) + ImGui::DebugHookIdInfo(id, ImGuiDataType_Pointer, ptr, NULL); + return id; +} + +ImGuiID ImGuiWindow::GetID(int n) +{ + ImGuiID seed = IDStack.back(); + ImGuiID id = ImHashData(&n, sizeof(n), seed); + ImGuiContext& g = *Ctx; + if (g.DebugHookIdInfo == id) + ImGui::DebugHookIdInfo(id, ImGuiDataType_S32, (void*)(intptr_t)n, NULL); + return id; +} + +// This is only used in rare/specific situations to manufacture an ID out of nowhere. +ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs) +{ + ImGuiID seed = IDStack.back(); + ImRect r_rel = ImGui::WindowRectAbsToRel(this, r_abs); + ImGuiID id = ImHashData(&r_rel, sizeof(r_rel), seed); + return id; +} + void ImGui::PushID(const char* str_id) { ImGuiContext& g = *GImGui; From e7712ff103dc8c15212f884f90d3f6a662726d1c Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 3 Apr 2024 10:50:32 +0900 Subject: [PATCH 17/19] Out of courtesy/consistency move all the DebugHookIdInfo compares into ifndef block. --- imgui.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index 64655f15d..e3d20a943 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7967,9 +7967,11 @@ ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end) { ImGuiID seed = IDStack.back(); ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); +#ifndef IMGUI_DISABLE_DEBUG_TOOLS ImGuiContext& g = *Ctx; if (g.DebugHookIdInfo == id) ImGui::DebugHookIdInfo(id, ImGuiDataType_String, str, str_end); +#endif return id; } @@ -7977,9 +7979,11 @@ ImGuiID ImGuiWindow::GetID(const void* ptr) { ImGuiID seed = IDStack.back(); ImGuiID id = ImHashData(&ptr, sizeof(void*), seed); +#ifndef IMGUI_DISABLE_DEBUG_TOOLS ImGuiContext& g = *Ctx; if (g.DebugHookIdInfo == id) ImGui::DebugHookIdInfo(id, ImGuiDataType_Pointer, ptr, NULL); +#endif return id; } @@ -7987,9 +7991,11 @@ ImGuiID ImGuiWindow::GetID(int n) { ImGuiID seed = IDStack.back(); ImGuiID id = ImHashData(&n, sizeof(n), seed); +#ifndef IMGUI_DISABLE_DEBUG_TOOLS ImGuiContext& g = *Ctx; if (g.DebugHookIdInfo == id) ImGui::DebugHookIdInfo(id, ImGuiDataType_S32, (void*)(intptr_t)n, NULL); +#endif return id; } @@ -8039,8 +8045,10 @@ void ImGui::PushOverrideID(ImGuiID id) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; +#ifndef IMGUI_DISABLE_DEBUG_TOOLS if (g.DebugHookIdInfo == id) DebugHookIdInfo(id, ImGuiDataType_ID, NULL, NULL); +#endif window->IDStack.push_back(id); } @@ -8050,18 +8058,22 @@ void ImGui::PushOverrideID(ImGuiID id) ImGuiID ImGui::GetIDWithSeed(const char* str, const char* str_end, ImGuiID seed) { ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); +#ifndef IMGUI_DISABLE_DEBUG_TOOLS ImGuiContext& g = *GImGui; if (g.DebugHookIdInfo == id) DebugHookIdInfo(id, ImGuiDataType_String, str, str_end); +#endif return id; } ImGuiID ImGui::GetIDWithSeed(int n, ImGuiID seed) { ImGuiID id = ImHashData(&n, sizeof(n), seed); +#ifndef IMGUI_DISABLE_DEBUG_TOOLS ImGuiContext& g = *GImGui; if (g.DebugHookIdInfo == id) DebugHookIdInfo(id, ImGuiDataType_S32, (void*)(intptr_t)n, NULL); +#endif return id; } From 4f9ba19e520bea478f5cb654d37ef45e6404bd52 Mon Sep 17 00:00:00 2001 From: GamingMinds-DanielC Date: Mon, 11 Mar 2024 16:35:27 +0100 Subject: [PATCH 18/19] Drags, Sliders, Inputs: Reactivated decimal point replacement for SliderScalar and DragScalar. (#7389, #6719, #2278) Amend/fix 4a242644 --- docs/CHANGELOG.txt | 2 ++ imgui_internal.h | 1 + imgui_widgets.cpp | 7 ++++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 45339c010..d38b347e5 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -74,6 +74,8 @@ Other changes: (#7325, #7287, #7063) - ProgressBar: Fixed passing fraction==NaN from leading to a crash. (#7451) - ListBox: Fixed text-baseline offset when using SameLine()+Text() after a labeled ListBox(). +- Drags, Sliders, Inputs: Fixed io.PlatformLocaleDecimalPoint decimal point localization + feature not working regression from 1.90.1. (#7389, #6719, #2278) [@GamingMinds-DanielC] - Style: Added ImGuiStyleVar_TabBorderSize, ImGuiStyleVar_TableAngledHeadersAngle for consistency. (#7411) [@cfillion] - DrawList: Added AddConcavePolyFilled(), PathFillConcave() concave filling. (#760) [@thedmd] diff --git a/imgui_internal.h b/imgui_internal.h index 25d85f4f1..813d6add8 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -864,6 +864,7 @@ enum ImGuiInputTextFlagsPrivate_ ImGuiInputTextFlags_Multiline = 1 << 26, // For internal use by InputTextMultiline() ImGuiInputTextFlags_NoMarkEdited = 1 << 27, // For internal use by functions using InputText() before reformatting data ImGuiInputTextFlags_MergedItem = 1 << 28, // For internal use by TempInputText(), will skip calling ItemAdd(). Require bounding-box to strictly match. + ImGuiInputTextFlags_LocalizeDecimalPoint= 1 << 29, // For internal use by InputScalar() and TempInputScalar() }; // Extend ImGuiButtonFlags_ diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index c8ac26625..cf13660ba 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -3429,7 +3429,7 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG DataTypeFormatString(data_buf, IM_ARRAYSIZE(data_buf), data_type, p_data, format); ImStrTrimBlanks(data_buf); - ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited; + ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited | (ImGuiInputTextFlags)ImGuiInputTextFlags_LocalizeDecimalPoint; bool value_changed = false; if (TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags)) @@ -3474,6 +3474,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format); flags |= ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselves by comparing the actual data rather than the string. + flags |= (ImGuiInputTextFlags)ImGuiInputTextFlags_LocalizeDecimalPoint; bool value_changed = false; if (p_step == NULL) @@ -3951,7 +3952,7 @@ static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, Im return false; // Generic named filters - if (apply_named_filters && (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsScientific))) + if (apply_named_filters && (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsScientific | (ImGuiInputTextFlags)ImGuiInputTextFlags_LocalizeDecimalPoint))) { // The libc allows overriding locale, with e.g. 'setlocale(LC_NUMERIC, "de_DE.UTF-8");' which affect the output/input of printf/scanf to use e.g. ',' instead of '.'. // The standard mandate that programs starts in the "C" locale where the decimal point is '.'. @@ -3961,7 +3962,7 @@ static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, Im // Users of non-default decimal point (in particular ',') may be affected by word-selection logic (is_word_boundary_from_right/is_word_boundary_from_left) functions. ImGuiContext& g = *ctx; const unsigned c_decimal_point = (unsigned int)g.IO.PlatformLocaleDecimalPoint; - if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsScientific)) + if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsScientific | (ImGuiInputTextFlags)ImGuiInputTextFlags_LocalizeDecimalPoint)) if (c == '.' || c == ',') c = c_decimal_point; From 231cbee0fc4f59dbe5b8b853a11b08dc84e57c65 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 11 Apr 2024 15:45:27 +0200 Subject: [PATCH 19/19] Version 1.90.5 --- docs/CHANGELOG.txt | 8 +++++--- imgui.cpp | 4 ++-- imgui.h | 8 ++++---- imgui_demo.cpp | 2 +- imgui_draw.cpp | 2 +- imgui_internal.h | 2 +- imgui_tables.cpp | 2 +- imgui_widgets.cpp | 2 +- 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index d38b347e5..2c33cb2be 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -36,9 +36,11 @@ HOW TO UPDATE? - Please report any issue! ----------------------------------------------------------------------- - VERSION 1.90.5 WIP (In Progress) + VERSION 1.90.5 (Released 2024-04-11) ----------------------------------------------------------------------- +Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.90.5 + Breaking changes: - More formally obsoleted GetKeyIndex() when IMGUI_DISABLE_OBSOLETE_FUNCTIONS is set. @@ -47,7 +49,7 @@ Breaking changes: - IsKeyPressed(GetKeyIndex(ImGuiKey_XXX)) --> IsKeyPressed(ImGuiKey_XXX) - ImDrawList: Merged the radius_x/radius_y parameters in AddEllipse(), AddEllipseFilled() and PathEllipticalArcTo() into a single ImVec2 parameter. Exceptionally, because those - functions were added in 1.90, we are not adding inline redirection functions. + functions were added recently in 1.90, we are not adding inline redirection functions. The transition is easy and should affect few users. (#2743, #7417) [@cfillion] Other changes: @@ -85,7 +87,7 @@ Other changes: of interesting resources, because github doesn't allow Wiki to be crawled by search engines. - This is the main wiki: https://github.com/ocornut/imgui/wiki - This is the crawlable version: https://github-wiki-see.page/m/ocornut/imgui/wiki - Adding a link to the crawlable version, even though it is not indended for humans, + Adding a link to the crawlable version, even though it is not intended for humans, to increase its search rank. diff --git a/imgui.cpp b/imgui.cpp index e3d20a943..daa389b13 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.90.5 WIP +// dear imgui, v1.90.5 // (main code and documentation) // Help: @@ -1204,7 +1204,7 @@ ImGuiStyle::ImGuiStyle() FrameBorderSize = 0.0f; // Thickness of border around frames. Generally set to 0.0f or 1.0f. Other values not well tested. ItemSpacing = ImVec2(8,4); // Horizontal and vertical spacing between widgets/lines ItemInnerSpacing = ImVec2(4,4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label) - CellPadding = ImVec2(4,2); // Padding within a table cell. CellPadding.y may be altered between different rows. + CellPadding = ImVec2(4,2); // Padding within a table cell. Cellpadding.x is locked for entire table. CellPadding.y may be altered between different rows. TouchExtraPadding = ImVec2(0,0); // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much! IndentSpacing = 21.0f; // Horizontal spacing when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2). ColumnsMinSpacing = 6.0f; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1). diff --git a/imgui.h b/imgui.h index 782bf891f..73aceb2ce 100644 --- a/imgui.h +++ b/imgui.h @@ -1,4 +1,4 @@ -// dear imgui, v1.90.5 WIP +// dear imgui, v1.90.5 // (headers) // Help: @@ -27,8 +27,8 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') -#define IMGUI_VERSION "1.90.5 WIP" -#define IMGUI_VERSION_NUM 19047 +#define IMGUI_VERSION "1.90.5" +#define IMGUI_VERSION_NUM 19050 #define IMGUI_HAS_TABLE /* @@ -2001,7 +2001,7 @@ struct ImGuiStyle float FrameBorderSize; // Thickness of border around frames. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines. ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label). - ImVec2 CellPadding; // Padding within a table cell. CellPadding.y may be altered between different rows. + ImVec2 CellPadding; // Padding within a table cell. Cellpadding.x is locked for entire table. CellPadding.y may be altered between different rows. ImVec2 TouchExtraPadding; // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much! float IndentSpacing; // Horizontal indentation when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2). float ColumnsMinSpacing; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1). diff --git a/imgui_demo.cpp b/imgui_demo.cpp index ad0be025a..356f71ae2 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.90.5 WIP +// dear imgui, v1.90.5 // (demo code) // Help: diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 83e29e10f..eded4ffad 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.90.5 WIP +// dear imgui, v1.90.5 // (drawing and font code) /* diff --git a/imgui_internal.h b/imgui_internal.h index 813d6add8..55399f8d2 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1,4 +1,4 @@ -// dear imgui, v1.90.5 WIP +// dear imgui, v1.90.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 1fe1a721b..676c3b4e9 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.90.5 WIP +// dear imgui, v1.90.5 // (tables and columns code) /* diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index cf13660ba..aec4d51ef 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.90.5 WIP +// dear imgui, v1.90.5 // (widgets code) /*