From 16476f99fdd70f05228f0260aa2cfe98a3d46df9 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 22 Nov 2022 18:08:25 +0100 Subject: [PATCH 1/8] Backends: GLFW: cancel out errors emitted by glfwGetKeyName() when a name is missing. (#5908) --- backends/imgui_impl_glfw.cpp | 8 +++++++- docs/CHANGELOG.txt | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backends/imgui_impl_glfw.cpp b/backends/imgui_impl_glfw.cpp index 6ed2e9e47..dfde0331e 100644 --- a/backends/imgui_impl_glfw.cpp +++ b/backends/imgui_impl_glfw.cpp @@ -16,6 +16,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2022-11-22: Perform a dummy glfwGetError() read to cancel missing names with glfwGetKeyName(). (#5908) // 2022-10-18: Perform a dummy glfwGetError() read to cancel missing mouse cursors errors. Using GLFW_VERSION_COMBINED directly. (#5785) // 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11. // 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported). @@ -305,7 +306,12 @@ static int ImGui_ImplGlfw_TranslateUntranslatedKey(int key, int scancode) // This won't cover edge cases but this is at least going to cover common cases. if (key >= GLFW_KEY_KP_0 && key <= GLFW_KEY_KP_EQUAL) return key; + GLFWerrorfun prev_error_callback = glfwSetErrorCallback(nullptr); const char* key_name = glfwGetKeyName(key, scancode); + glfwSetErrorCallback(prev_error_callback); +#if (GLFW_VERSION_COMBINED >= 3300) // Eat errors (see #5908) + (void)glfwGetError(NULL); +#endif if (key_name && key_name[0] != 0 && key_name[1] == 0) { const char char_names[] = "`-=[]\\,;\'./"; @@ -495,10 +501,10 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw bd->MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); #endif + glfwSetErrorCallback(prev_error_callback); #if (GLFW_VERSION_COMBINED >= 3300) // Eat errors (see #5785) (void)glfwGetError(NULL); #endif - glfwSetErrorCallback(prev_error_callback); // Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any. if (install_callbacks) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 22598a88e..33e806ff5 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -38,6 +38,7 @@ HOW TO UPDATE? - Inputs: fixed moving a window or drag and dropping from preventing input-owner-unaware code from accessing keys. (#5888, #4921, #456) - Inputs: fixed moving a window or drag and dropping from capturing mods. (#5888, #4921, #456) +- Backends: GLFW: cancel out errors emitted by glfwGetKeyName() when a name is missing. (#5908) ----------------------------------------------------------------------- From 3a685749cb2ec54dbc8161842bfd0184d21c9d26 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 23 Nov 2022 14:40:58 +0100 Subject: [PATCH 2/8] ColorEdit: fixed label overlapping when using style.ColorButtonPosition == ImGuiDir_Left. (#5912) Amend 54fb051e5 + Internals: added IsKeyboardKey(), IsMouseKey() helpers. --- docs/CHANGELOG.txt | 2 ++ imgui.h | 2 +- imgui_internal.h | 8 ++++++-- imgui_widgets.cpp | 3 +++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 33e806ff5..5827fea49 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -38,6 +38,8 @@ HOW TO UPDATE? - Inputs: fixed moving a window or drag and dropping from preventing input-owner-unaware code from accessing keys. (#5888, #4921, #456) - Inputs: fixed moving a window or drag and dropping from capturing mods. (#5888, #4921, #456) +- ColorEdit: fixed label overlapping when using style.ColorButtonPosition == ImGuiDir_Left to + move the color button on the left side (regression introduced in 1.88 WIP 2022/02/28). (#5912) - Backends: GLFW: cancel out errors emitted by glfwGetKeyName() when a name is missing. (#5908) diff --git a/imgui.h b/imgui.h index da841e1a0..a626c79f4 100644 --- a/imgui.h +++ b/imgui.h @@ -23,7 +23,7 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345') #define IMGUI_VERSION "1.89.1 WIP" -#define IMGUI_VERSION_NUM 18902 +#define IMGUI_VERSION_NUM 18903 #define IMGUI_HAS_TABLE /* diff --git a/imgui_internal.h b/imgui_internal.h index bc31900ff..5c09ce493 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1210,8 +1210,10 @@ typedef ImBitArray ImBitAr #define ImGuiKey_Keyboard_END (ImGuiKey_GamepadStart) #define ImGuiKey_Gamepad_BEGIN (ImGuiKey_GamepadStart) #define ImGuiKey_Gamepad_END (ImGuiKey_GamepadRStickDown + 1) -#define ImGuiKey_Aliases_BEGIN (ImGuiKey_MouseLeft) -#define ImGuiKey_Aliases_END (ImGuiKey_MouseWheelY + 1) +#define ImGuiKey_Mouse_BEGIN (ImGuiKey_MouseLeft) +#define ImGuiKey_Mouse_END (ImGuiKey_MouseWheelY + 1) +#define ImGuiKey_Aliases_BEGIN (ImGuiKey_Mouse_BEGIN) +#define ImGuiKey_Aliases_END (ImGuiKey_Mouse_END) // [Internal] Named shortcuts for Navigation #define ImGuiKey_NavKeyboardTweakSlow ImGuiMod_Ctrl @@ -2821,7 +2823,9 @@ namespace ImGui inline bool IsNamedKey(ImGuiKey key) { return key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END; } inline bool IsNamedKeyOrModKey(ImGuiKey key) { return (key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END) || key == ImGuiMod_Ctrl || key == ImGuiMod_Shift || key == ImGuiMod_Alt || key == ImGuiMod_Super; } inline bool IsLegacyKey(ImGuiKey key) { return key >= ImGuiKey_LegacyNativeKey_BEGIN && key < ImGuiKey_LegacyNativeKey_END; } + inline bool IsKeyboardKey(ImGuiKey key) { return key >= ImGuiKey_Keyboard_BEGIN && key < ImGuiKey_Keyboard_END; } inline bool IsGamepadKey(ImGuiKey key) { return key >= ImGuiKey_Gamepad_BEGIN && key < ImGuiKey_Gamepad_END; } + inline bool IsMouseKey(ImGuiKey key) { return key >= ImGuiKey_Mouse_BEGIN && key < ImGuiKey_Mouse_END; } inline bool IsAliasKey(ImGuiKey key) { return key >= ImGuiKey_Aliases_BEGIN && key < ImGuiKey_Aliases_END; } inline ImGuiKey ConvertSingleModFlagToKey(ImGuiKey key) { diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 1887577b8..ec4830d4a 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -5103,7 +5103,10 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag if (label != label_display_end && !(flags & ImGuiColorEditFlags_NoLabel)) { + // Position not necessarily next to last submitted button (e.g. if style.ColorButtonPosition == ImGuiDir_Left), + // but we need to use SameLine() to setup baseline correctly. Might want to refactor SameLine() to simplify this. SameLine(0.0f, style.ItemInnerSpacing.x); + window->DC.CursorPos.x = pos.x + ((flags & ImGuiColorEditFlags_NoInputs) ? w_button : w_full + style.ItemInnerSpacing.x); TextEx(label, label_display_end); } From c3d9f8ee7e7fe6c51b5d580c65627d2732054ce3 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 23 Nov 2022 15:18:59 +0100 Subject: [PATCH 3/8] Layout: fixed End()/EndChild() incorrectly asserting if users manipulates cursor position inside a collapsed/culled window and IMGUI_DISABLE_OBSOLETE_FUNCTIONS is enabled. (#5548, #5911) --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 5827fea49..1dd5df4be 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -38,6 +38,8 @@ HOW TO UPDATE? - Inputs: fixed moving a window or drag and dropping from preventing input-owner-unaware code from accessing keys. (#5888, #4921, #456) - Inputs: fixed moving a window or drag and dropping from capturing mods. (#5888, #4921, #456) +- Layout: fixed End()/EndChild() incorrectly asserting if users manipulates cursor position + inside a collapsed/culled window and IMGUI_DISABLE_OBSOLETE_FUNCTIONS is enabled. (#5548, #5911) - ColorEdit: fixed label overlapping when using style.ColorButtonPosition == ImGuiDir_Left to move the color button on the left side (regression introduced in 1.88 WIP 2022/02/28). (#5912) - Backends: GLFW: cancel out errors emitted by glfwGetKeyName() when a name is missing. (#5908) diff --git a/imgui.cpp b/imgui.cpp index 51a1cf180..0fac87306 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -8694,6 +8694,8 @@ void ImGui::ErrorCheckUsingSetCursorPosToExtendParentBoundaries() #ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS if (window->DC.CursorPos.x <= window->DC.CursorMaxPos.x && window->DC.CursorPos.y <= window->DC.CursorMaxPos.y) return; + if (window->SkipItems) + return; IM_ASSERT(0 && "Code uses SetCursorPos()/SetCursorScreenPos() to extend window/parent boundaries. Please submit an item e.g. Dummy() to validate extent."); #else window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); From ffe0abbfc2672b1d44a51f7f7b36c9075e4409f4 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 23 Nov 2022 16:05:16 +0100 Subject: [PATCH 4/8] Internals: added basic localization system (#5895) --- imgui.cpp | 40 +++++++++++++++++++++++++++++++++------- imgui_internal.h | 39 +++++++++++++++++++++++++++++++++++++++ imgui_tables.cpp | 8 ++++---- 3 files changed, 76 insertions(+), 11 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 0fac87306..9d463dc11 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -80,7 +80,8 @@ CODE // [SECTION] DRAG AND DROP // [SECTION] LOGGING/CAPTURING // [SECTION] SETTINGS -// [SECTION] VIEWPORTS +// [SECTION] LOCALIZATION +// [SECTION] VIEWPORTS, PLATFORM WINDOWS // [SECTION] PLATFORM DEPENDENT HELPERS // [SECTION] METRICS/DEBUGGER WINDOW // [SECTION] DEBUG LOG WINDOW @@ -4772,12 +4773,24 @@ void ImGui::NewFrame() CallContextHooks(&g, ImGuiContextHookType_NewFramePost); } +// IMPORTANT: ###xxx suffixes must be same in ALL languages +static const ImGuiLocEntry GLocalizationEntriesEnUS[] = +{ + { ImGuiLocKey_TableSizeOne, "Size column to fit###SizeOne" }, + { ImGuiLocKey_TableSizeAllFit, "Size all columns to fit###SizeAll" }, + { ImGuiLocKey_TableSizeAllDefault, "Size all columns to default###SizeAll" }, + { ImGuiLocKey_TableResetOrder, "Reset order###ResetOrder" }, + { ImGuiLocKey_WindowingMainMenuBar, "(Main menu bar)" }, + { ImGuiLocKey_WindowingPopup, "(Popup)" }, + { ImGuiLocKey_WindowingUntitled, "(Untitled)" }, +}; + void ImGui::Initialize() { ImGuiContext& g = *GImGui; IM_ASSERT(!g.Initialized && !g.SettingsLoaded); - // Add .ini handle for ImGuiWindow type + // Add .ini handle for ImGuiWindow and ImGuiTable types { ImGuiSettingsHandler ini_handler; ini_handler.TypeName = "Window"; @@ -4789,10 +4802,11 @@ void ImGui::Initialize() ini_handler.WriteAllFn = WindowSettingsHandler_WriteAll; AddSettingsHandler(&ini_handler); } - - // Add .ini handle for ImGuiTable type TableSettingsAddSettingsHandler(); + // Setup default localization table + LocalizeRegisterEntries(GLocalizationEntriesEnUS, IM_ARRAYSIZE(GLocalizationEntriesEnUS)); + // Create default viewport ImGuiViewportP* viewport = IM_NEW(ImGuiViewportP)(); g.Viewports.push_back(viewport); @@ -11660,10 +11674,10 @@ static void ImGui::NavUpdateWindowing() static const char* GetFallbackWindowNameForWindowingList(ImGuiWindow* window) { if (window->Flags & ImGuiWindowFlags_Popup) - return "(Popup)"; + return ImGui::LocalizeGetMsg(ImGuiLocKey_WindowingPopup); if ((window->Flags & ImGuiWindowFlags_MenuBar) && strcmp(window->Name, "##MainMenuBar") == 0) - return "(Main menu bar)"; - return "(Untitled)"; + return ImGui::LocalizeGetMsg(ImGuiLocKey_WindowingMainMenuBar); + return ImGui::LocalizeGetMsg(ImGuiLocKey_WindowingUntitled); } // Overlay displayed when using CTRL+TAB. Called by EndFrame(). @@ -12593,6 +12607,18 @@ static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandl } +//----------------------------------------------------------------------------- +// [SECTION] LOCALIZATION +//----------------------------------------------------------------------------- + +void ImGui::LocalizeRegisterEntries(const ImGuiLocEntry* entries, int count) +{ + ImGuiContext& g = *GImGui; + for (int n = 0; n < count; n++) + g.LocalizationTable[entries[n].Key] = entries[n].Text; +} + + //----------------------------------------------------------------------------- // [SECTION] VIEWPORTS, PLATFORM WINDOWS //----------------------------------------------------------------------------- diff --git a/imgui_internal.h b/imgui_internal.h index 5c09ce493..015f6b657 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -26,6 +26,7 @@ Index of this file: // [SECTION] Docking support // [SECTION] Viewport support // [SECTION] Settings support +// [SECTION] Localization support // [SECTION] Metrics, Debug tools // [SECTION] Generic context hooks // [SECTION] ImGuiContext (main imgui context) @@ -121,6 +122,7 @@ struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDat struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup() struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box struct ImGuiLastItemData; // Status storage for last submitted items +struct ImGuiLocEntry; // A localization entry. struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only struct ImGuiNavItemData; // Result of a gamepad/keyboard directional navigation move query result struct ImGuiMetricsConfig; // Storage for ShowMetricsWindow() and DebugNodeXXX() functions @@ -144,8 +146,12 @@ struct ImGuiWindow; // Storage for one window struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame, in practice we currently keep it for each window) struct ImGuiWindowSettings; // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session) +// Enumerations // Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists. +enum ImGuiLocKey : int; // -> enum ImGuiLocKey // Enum: a localization entry for translation. typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical + +// Flags typedef int ImGuiActivateFlags; // -> enum ImGuiActivateFlags_ // Flags: for navigation/focus function (will be for ActivateItem() later) typedef int ImGuiDebugLogFlags; // -> enum ImGuiDebugLogFlags_ // Flags: for ShowDebugLogWindow(), g.DebugLogFlags typedef int ImGuiInputFlags; // -> enum ImGuiInputFlags_ // Flags: for IsKeyPressed(), IsMouseClicked(), SetKeyOwner(), SetItemKeyOwner() etc. @@ -1608,6 +1614,30 @@ struct ImGuiSettingsHandler ImGuiSettingsHandler() { memset(this, 0, sizeof(*this)); } }; +//----------------------------------------------------------------------------- +// [SECTION] Localization support +//----------------------------------------------------------------------------- + +// This is experimental and not officially supported, it'll probably fall short of features, if/when it does we may backtrack. +enum ImGuiLocKey : int +{ + ImGuiLocKey_TableSizeOne, + ImGuiLocKey_TableSizeAllFit, + ImGuiLocKey_TableSizeAllDefault, + ImGuiLocKey_TableResetOrder, + ImGuiLocKey_WindowingMainMenuBar, + ImGuiLocKey_WindowingPopup, + ImGuiLocKey_WindowingUntitled, + ImGuiLocKey_COUNT +}; + +struct ImGuiLocEntry +{ + ImGuiLocKey Key; + const char* Text; +}; + + //----------------------------------------------------------------------------- // [SECTION] Metrics, Debug Tools //----------------------------------------------------------------------------- @@ -1938,6 +1968,9 @@ struct ImGuiContext ImVector Hooks; // Hooks for extensions (e.g. test engine) ImGuiID HookIdNext; // Next available HookId + // Localization + const char* LocalizationTable[ImGuiLocKey_COUNT]; + // Capture/Logging bool LogEnabled; // Currently capturing ImGuiLogType LogType; // Capture target @@ -2109,6 +2142,8 @@ struct ImGuiContext SettingsDirtyTimer = 0.0f; HookIdNext = 0; + memset(LocalizationTable, 0, sizeof(LocalizationTable)); + LogEnabled = false; LogType = ImGuiLogType_None; LogNextPrefix = LogNextSuffix = NULL; @@ -2725,6 +2760,10 @@ namespace ImGui IMGUI_API void RemoveSettingsHandler(const char* type_name); IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name); + // Localization + IMGUI_API void LocalizeRegisterEntries(const ImGuiLocEntry* entries, int count); + inline const char* LocalizeGetMsg(ImGuiLocKey key) { ImGuiContext& g = *GImGui; const char* msg = g.LocalizationTable[key]; return msg ? msg : "*Missing Text*"; } + // Scrolling IMGUI_API void SetScrollX(ImGuiWindow* window, float scroll_x); IMGUI_API void SetScrollY(ImGuiWindow* window, float scroll_y); diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 53aafc479..66a46573b 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -3070,15 +3070,15 @@ void ImGui::TableDrawContextMenu(ImGuiTable* table) if (column != NULL) { const bool can_resize = !(column->Flags & ImGuiTableColumnFlags_NoResize) && column->IsEnabled; - if (MenuItem("Size column to fit###SizeOne", NULL, false, can_resize)) + if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableSizeOne), NULL, false, can_resize)) // "###SizeOne" TableSetColumnWidthAutoSingle(table, column_n); } const char* size_all_desc; if (table->ColumnsEnabledFixedCount == table->ColumnsEnabledCount && (table->Flags & ImGuiTableFlags_SizingMask_) != ImGuiTableFlags_SizingFixedSame) - size_all_desc = "Size all columns to fit###SizeAll"; // All fixed + size_all_desc = LocalizeGetMsg(ImGuiLocKey_TableSizeAllFit); // "###SizeAll" All fixed else - size_all_desc = "Size all columns to default###SizeAll"; // All stretch or mixed + size_all_desc = LocalizeGetMsg(ImGuiLocKey_TableSizeAllDefault); // "###SizeAll" All stretch or mixed if (MenuItem(size_all_desc, NULL)) TableSetColumnWidthAutoAll(table); want_separator = true; @@ -3087,7 +3087,7 @@ void ImGui::TableDrawContextMenu(ImGuiTable* table) // Ordering if (table->Flags & ImGuiTableFlags_Reorderable) { - if (MenuItem("Reset order", NULL, false, !table->IsDefaultDisplayOrder)) + if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableResetOrder), NULL, false, !table->IsDefaultDisplayOrder)) table->IsResetDisplayOrderRequest = true; want_separator = true; } From 856c6314ec33c3dc463ca17ad68b8e42a7dce06d Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 23 Nov 2022 17:58:14 +0100 Subject: [PATCH 5/8] Drag and Drop: fixed GetDragDropPayload() returning a non-NULL value before payload is submitted. (#5910, #143) + Added test "widgets_dragdrop_new_payloads" in Test Suite. --- docs/CHANGELOG.txt | 3 +++ imgui.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 1dd5df4be..ed6ff97e6 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -42,6 +42,9 @@ HOW TO UPDATE? inside a collapsed/culled window and IMGUI_DISABLE_OBSOLETE_FUNCTIONS is enabled. (#5548, #5911) - ColorEdit: fixed label overlapping when using style.ColorButtonPosition == ImGuiDir_Left to move the color button on the left side (regression introduced in 1.88 WIP 2022/02/28). (#5912) +- Drag and Drop: fixed GetDragDropPayload() returning a non-NULL value if a drag source is + active but a payload hasn't been submitted yet. This is convenient to detect new payload + from within a drag source handler. (#5910, #143) - Backends: GLFW: cancel out errors emitted by glfwGetKeyName() when a name is missing. (#5908) diff --git a/imgui.cpp b/imgui.cpp index 9d463dc11..89ba21944 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -12023,7 +12023,7 @@ void ImGui::RenderDragDropTargetRect(const ImRect& bb) const ImGuiPayload* ImGui::GetDragDropPayload() { ImGuiContext& g = *GImGui; - return g.DragDropActive ? &g.DragDropPayload : NULL; + return (g.DragDropActive && g.DragDropPayload.DataFrameCount != -1) ? &g.DragDropPayload : NULL; } // We don't really use/need this now, but added it for the sake of consistency and because we might need it later. From 233d7ad3f2234919aca2e78b974a7982ab71c249 Mon Sep 17 00:00:00 2001 From: kdchambers Date: Wed, 23 Nov 2022 15:58:02 -0500 Subject: [PATCH 6/8] Backends: WebGPU: fixed validation error with default depth buffer settings. (#5869, #5914) (initialize WGPUCompareFunction params to valid values) --- backends/imgui_impl_wgpu.cpp | 4 ++++ docs/CHANGELOG.txt | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backends/imgui_impl_wgpu.cpp b/backends/imgui_impl_wgpu.cpp index c4bc5c76c..3282cf364 100644 --- a/backends/imgui_impl_wgpu.cpp +++ b/backends/imgui_impl_wgpu.cpp @@ -13,6 +13,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2022-11-24: Fixed validation error with default depth buffer settings. // 2022-11-10: Fixed rendering when a depth buffer is enabled. Added 'WGPUTextureFormat depth_format' parameter to ImGui_ImplWGPU_Init(). // 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11. // 2021-11-29: Passing explicit buffer sizes to wgpuRenderPassEncoderSetVertexBuffer()/wgpuRenderPassEncoderSetIndexBuffer(). @@ -606,6 +607,9 @@ bool ImGui_ImplWGPU_CreateDeviceObjects() WGPUDepthStencilState depth_stencil_state = {}; depth_stencil_state.format = g_depthStencilFormat; depth_stencil_state.depthWriteEnabled = false; + depth_stencil_state.depthCompare = WGPUCompareFunction_Always; + depth_stencil_state.stencilFront.compare = WGPUCompareFunction_Always; + depth_stencil_state.stencilBack.compare = WGPUCompareFunction_Always; // Configure disabled depth-stencil state graphics_pipeline_desc.depthStencil = g_depthStencilFormat == WGPUTextureFormat_Undefined ? nullptr : &depth_stencil_state; diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index ed6ff97e6..885bdbabe 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -46,6 +46,7 @@ HOW TO UPDATE? active but a payload hasn't been submitted yet. This is convenient to detect new payload from within a drag source handler. (#5910, #143) - Backends: GLFW: cancel out errors emitted by glfwGetKeyName() when a name is missing. (#5908) +- Backends: WebGPU: fixed validation error with default depth buffer settings. (#5869, #5914) [@kdchambers] ----------------------------------------------------------------------- @@ -114,7 +115,6 @@ Breaking changes: - Removed support for 1.42-era IMGUI_DISABLE_INCLUDE_IMCONFIG_H / IMGUI_INCLUDE_IMCONFIG_H. (#255) They only made sense before we could use IMGUI_USER_CONFIG. - Other Changes: - Popups & Modals: fixed nested Begin() inside a popup being erroneously input-inhibited. From 27c58c394657ef2ecc0afa4fc620be20d849202a Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 24 Nov 2022 17:40:51 +0100 Subject: [PATCH 7/8] Scrolling, Focus, Combo: fixed SetKeyboardFocusHere()/SetItemDefaultFocus()/ScrollToRectEx() during an appearing form not centering item. (#5902, #2812, #4242, #2900) Amend 44f801186 and 8f495e554 --- docs/CHANGELOG.txt | 4 ++++ imgui.cpp | 16 ++++++++++------ imgui.h | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 885bdbabe..ec661cabe 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -35,11 +35,15 @@ HOW TO UPDATE? VERSION 1.89.1 WIP (In Progress) ----------------------------------------------------------------------- +- Scrolling, Focus: fixed SetKeyboardFocusHere()/SetItemDefaultFocus() during a window-appearing + frame (and associated lower-level functions e.g. ScrollToRectEx()) from not centering item. (#5902) - Inputs: fixed moving a window or drag and dropping from preventing input-owner-unaware code from accessing keys. (#5888, #4921, #456) - Inputs: fixed moving a window or drag and dropping from capturing mods. (#5888, #4921, #456) - Layout: fixed End()/EndChild() incorrectly asserting if users manipulates cursor position inside a collapsed/culled window and IMGUI_DISABLE_OBSOLETE_FUNCTIONS is enabled. (#5548, #5911) +- Combo: fixed selected item (marked with SetItemDefaultFocus()) from not being centered when + the combo window initially appears. (#5902). - ColorEdit: fixed label overlapping when using style.ColorButtonPosition == ImGuiDir_Left to move the color button on the left side (regression introduced in 1.88 WIP 2022/02/28). (#5912) - Drag and Drop: fixed GetDragDropPayload() returning a non-NULL value if a drag source is diff --git a/imgui.cpp b/imgui.cpp index 89ba21944..164745963 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -9519,8 +9519,8 @@ ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGui const bool fully_visible_x = item_rect.Min.x >= window_rect.Min.x && item_rect.Max.x <= window_rect.Max.x; const bool fully_visible_y = item_rect.Min.y >= window_rect.Min.y && item_rect.Max.y <= window_rect.Max.y; - const bool can_be_fully_visible_x = (item_rect.GetWidth() + g.Style.ItemSpacing.x * 2.0f) <= window_rect.GetWidth(); - const bool can_be_fully_visible_y = (item_rect.GetHeight() + g.Style.ItemSpacing.y * 2.0f) <= window_rect.GetHeight(); + const bool can_be_fully_visible_x = (item_rect.GetWidth() + g.Style.ItemSpacing.x * 2.0f) <= window_rect.GetWidth() || (window->AutoFitFramesX > 0) || (window->Flags & ImGuiWindowFlags_AlwaysAutoResize) != 0; + const bool can_be_fully_visible_y = (item_rect.GetHeight() + g.Style.ItemSpacing.y * 2.0f) <= window_rect.GetHeight() || (window->AutoFitFramesY > 0) || (window->Flags & ImGuiWindowFlags_AlwaysAutoResize) != 0; if ((flags & ImGuiScrollFlags_KeepVisibleEdgeX) && !fully_visible_x) { @@ -9531,8 +9531,10 @@ ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGui } else if (((flags & ImGuiScrollFlags_KeepVisibleCenterX) && !fully_visible_x) || (flags & ImGuiScrollFlags_AlwaysCenterX)) { - float target_x = can_be_fully_visible_x ? ImFloor((item_rect.Min.x + item_rect.Max.x - window->InnerRect.GetWidth()) * 0.5f) : item_rect.Min.x; - SetScrollFromPosX(window, target_x - window->Pos.x, 0.0f); + if (can_be_fully_visible_x) + SetScrollFromPosX(window, ImFloor((item_rect.Min.x + item_rect.Max.y) * 0.5f) - window->Pos.x, 0.5f); + else + SetScrollFromPosX(window, item_rect.Min.x - window->Pos.x, 0.0f); } if ((flags & ImGuiScrollFlags_KeepVisibleEdgeY) && !fully_visible_y) @@ -9544,8 +9546,10 @@ ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGui } else if (((flags & ImGuiScrollFlags_KeepVisibleCenterY) && !fully_visible_y) || (flags & ImGuiScrollFlags_AlwaysCenterY)) { - float target_y = can_be_fully_visible_y ? ImFloor((item_rect.Min.y + item_rect.Max.y - window->InnerRect.GetHeight()) * 0.5f) : item_rect.Min.y; - SetScrollFromPosY(window, target_y - window->Pos.y, 0.0f); + if (can_be_fully_visible_y) + SetScrollFromPosY(window, ImFloor((item_rect.Min.y + item_rect.Max.y) * 0.5f) - window->Pos.y, 0.5f); + else + SetScrollFromPosY(window, item_rect.Min.y - window->Pos.y, 0.0f); } ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(window); diff --git a/imgui.h b/imgui.h index a626c79f4..e3a7c8531 100644 --- a/imgui.h +++ b/imgui.h @@ -23,7 +23,7 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345') #define IMGUI_VERSION "1.89.1 WIP" -#define IMGUI_VERSION_NUM 18903 +#define IMGUI_VERSION_NUM 18904 #define IMGUI_HAS_TABLE /* From a8df192df022ed6ac447e7b7ada718c4c4824b41 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 24 Nov 2022 21:24:33 +0100 Subject: [PATCH 8/8] Version 1.89.1 --- docs/CHANGELOG.txt | 4 +++- imgui.cpp | 2 +- imgui.h | 4 ++-- imgui_demo.cpp | 2 +- imgui_draw.cpp | 2 +- imgui_internal.h | 2 +- imgui_tables.cpp | 2 +- imgui_widgets.cpp | 2 +- 8 files changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index ec661cabe..46f4fde0a 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -32,9 +32,11 @@ HOW TO UPDATE? ----------------------------------------------------------------------- - VERSION 1.89.1 WIP (In Progress) + VERSION 1.89.1 (Released 2022-11-24) ----------------------------------------------------------------------- +Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.89.1 + - Scrolling, Focus: fixed SetKeyboardFocusHere()/SetItemDefaultFocus() during a window-appearing frame (and associated lower-level functions e.g. ScrollToRectEx()) from not centering item. (#5902) - Inputs: fixed moving a window or drag and dropping from preventing input-owner-unaware code diff --git a/imgui.cpp b/imgui.cpp index 164745963..d17903903 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.90 WIP +// dear imgui, v1.89.1 // (main code and documentation) // Help: diff --git a/imgui.h b/imgui.h index e3a7c8531..03eb0ca9f 100644 --- a/imgui.h +++ b/imgui.h @@ -1,4 +1,4 @@ -// dear imgui, v1.89.1 WIP +// dear imgui, v1.89.1 // (headers) // Help: @@ -23,7 +23,7 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345') #define IMGUI_VERSION "1.89.1 WIP" -#define IMGUI_VERSION_NUM 18904 +#define IMGUI_VERSION_NUM 18910 #define IMGUI_HAS_TABLE /* diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 560586933..636c7b879 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.89.1 WIP +// dear imgui, v1.89.1 // (demo code) // Help: diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 859b62e7e..1203af8e3 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.89.1 WIP +// dear imgui, v1.89.1 // (drawing and font code) /* diff --git a/imgui_internal.h b/imgui_internal.h index 015f6b657..816141e40 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1,4 +1,4 @@ -// dear imgui, v1.89.1 WIP +// dear imgui, v1.89.1 // (internal structures/api) // You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility! diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 66a46573b..503c098e9 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.89.1 WIP +// dear imgui, v1.89.1 // (tables and columns code) /* diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index ec4830d4a..5ecb182ef 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.89.1 WIP +// dear imgui, v1.89.1 // (widgets code) /*