Skip to content

Commit

Permalink
Merge branch 'master' into docking
Browse files Browse the repository at this point in the history
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	docs/CHANGELOG.txt
#	imgui.cpp
  • Loading branch information
ocornut committed Mar 14, 2023
2 parents 9937660 + f3f6295 commit 9e30fb0
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 46 deletions.
8 changes: 5 additions & 3 deletions backends/imgui_impl_glfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2023-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2023-03-14: Emscripten: Avoid using glfwGetError() and glfwGetGamepadState() which are not correctly implemented in Emscripten emulation. (#6240)
// 2023-02-03: Emscripten: Registering custom low-level mouse wheel handler to get more accurate scrolling impulses on Emscripten. (#4019, #6096)
// 2023-01-18: Handle unsupported glfwGetVideoMode() call on e.g. Emscripten.
// 2023-01-04: Inputs: Fixed mods state on Linux when using Alt-GR text input (e.g. German keyboard layout), could lead to broken text input. Revert a 2022/01/17 change were we resumed using mods provided by GLFW, turns out they were faulty.
Expand Down Expand Up @@ -115,6 +116,7 @@
#endif
#define GLFW_HAS_GAMEPAD_API (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetGamepadState() new api
#define GLFW_HAS_GETKEYNAME (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwGetKeyName()
#define GLFW_HAS_GETERROR (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetError()

// GLFW data
enum GlfwClientApi
Expand Down Expand Up @@ -353,7 +355,7 @@ static int ImGui_ImplGlfw_TranslateUntranslatedKey(int key, int scancode)
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)
#if GLFW_HAS_GETERROR && !defined(__EMSCRIPTEN__) // Eat errors (see #5908)
(void)glfwGetError(NULL);
#endif
if (key_name && key_name[0] != 0 && key_name[1] == 0)
Expand Down Expand Up @@ -582,7 +584,7 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
#endif
glfwSetErrorCallback(prev_error_callback);
#if (GLFW_VERSION_COMBINED >= 3300) // Eat errors (see #5785)
#if GLFW_HAS_GETERROR && !defined(__EMSCRIPTEN__) // Eat errors (see #5908)
(void)glfwGetError(NULL);
#endif

Expand Down Expand Up @@ -763,7 +765,7 @@ static void ImGui_ImplGlfw_UpdateGamepads()
return;

io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
#if GLFW_HAS_GAMEPAD_API
#if GLFW_HAS_GAMEPAD_API && !defined(__EMSCRIPTEN__)
GLFWgamepadstate gamepad;
if (!glfwGetGamepadState(GLFW_JOYSTICK_1, &gamepad))
return;
Expand Down
32 changes: 26 additions & 6 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Other changes:


-----------------------------------------------------------------------
VERSION 1.89.4 WIP (In Progress)
VERSION 1.89.4 (Released 2023-03-14)
-----------------------------------------------------------------------

Breaking Changes:
Expand All @@ -109,19 +109,30 @@ Breaking Changes:
- Moved the optional "courtesy maths operators" implementation from imgui_internal.h in imgui.h.
Even though we encourage using your own maths types and operators by setting up IM_VEC2_CLASS_EXTRA,
it has been frequently requested by people to use our own. We had an opt-in define which was
previously fulfilled in imgui_internal.h. It is now fulfilled in imgui.h. (#6164, #6137, #5966, #2832)
previously fulfilled by imgui_internal.h. It is now fulfilled by imgui.h. (#6164, #6137, #5966, #2832)
OK: #define IMGUI_DEFINE_MATH_OPERATORS / #include "imgui.h" / #include "imgui_internal.h"
Error: #include "imgui.h" / #define IMGUI_DEFINE_MATH_OPERATORS / #include "imgui_internal.h"
Added a dedicated compile-time check message to help diagnose this.
- Tooltips: Added 'bool' return value to BeginTooltip() for API consistency.
Please only submit contents and call EndTooltip() if BeginTooltip() returns true.
In reality the function will _currently_ always return true, but further changes down the
line may change this, best to clarify API sooner. Updated demo code accordingly.
- Commented out redirecting enums/functions names that were marked obsolete two years ago:
- ImGuiSliderFlags_ClampOnInput -> use ImGuiSliderFlags_AlwaysClamp
- ImGuiInputTextFlags_AlwaysInsertMode -> use ImGuiInputTextFlags_AlwaysOverwrite
- ImDrawList::AddBezierCurve() -> use ImDrawList::AddBezierCubic()
- ImDrawList::PathBezierCurveTo() -> use ImDrawList::PathBezierCubicCurveTo()

Other changes:

- Nav: Tabbing now cycles through all items when ImGuiConfigFlags_NavEnableKeyboard is set.
(#3092, #5759, #787)
While this was generally desired and requested by many, note that its addition means
that some types of UI may become more fastidious to use TAB key with, if the navigation
cursor cycles through too many items. You can mark items items as not tab-spottable:
- Public API: PushTabStop(false) / PopTabStop()
- Internal: PushItemFlag(ImGuiItemFlags_NoTabStop, true);
- Internal: Directly pass ImGuiItemFlags_NoTabStop to ItemAdd() for custom widgets.
- Nav: Tabbing/Shift-Tabbing can more reliably be used to step out of an item that is not
tab-stoppable. (#3092, #5759, #787)
- Nav: Made Enter key submit the same type of Activation event as Space key,
Expand All @@ -131,23 +142,32 @@ Other changes:
- Nav: Fixed an issue with Gamepad navigation when the movement lead to a scroll and
frame time > repeat rate. Triggering a new move request on the same frame as a move
result lead to an incorrect calculation and loss of navigation id. (#6171)
- Nav: Fixed SetItemDefaultFocus() from not scrolling when item is partially visible.
(#2814, #2812) [@DomGries]
- Tables: Fixed an issue where user's Y cursor movement within a hidden column would
have side-effects.
- IO: Lifted constraint to call io.AddEventXXX functions from current context. (#4921, #5856, #6199)
- InputText: Fixed not being able to use CTRL+Tab while an InputText() using Tab
for completion or textinput is active (regresion from 1.89).
for completion or text data is active (regression from 1.89).
- Drag and Drop: Fixed handling of overlapping targets when smaller one is submitted
before and can accept the same data type. (#6183).
- Drag and Drop: Clear drag and drop state as soon as delivery is accepted in order to
avoid inteferences. (#5817, #6183) [@DimaKoltun]
avoid interferences. (#5817, #6183) [@DimaKoltun]
- Debug Tools: Added io.ConfigDebugBeginReturnValueOnce / io.ConfigDebugBeginReturnValueLoop
options to simulate Begin/BeginChild returning false to facilitate debugging user behavior.
- Demo: Updated to test return value of BeginTooltip().
- Backends: OpenGL3: Fixed restoration of a potentially deleted OpenGL program. If an active
program was pending deletion, attempting to restore it would error. (#6220, #6224) [@Cyphall]
- Backends: Win32: Use WM_NCMOUSEMOVE / WM_NCMOUSELEAVE to track mouse positions over
non-client area (e.g. OS decorations) when app is not focused. (#6045, #6162)
- Backends: SDL2, SDL3: Accept SDL_GetPerformanceCounter() not returning a monotonically
- Backends: SDL2, SDL3: Accept SDL_GetPerformanceCounter() not returning a monotonically
increasing value. (#6189, #6114, #3644) [@adamkewley]
- Backends: GLFW: Avoid using glfwGetError() and glfwGetGamepadState() on Emscripten, which
recently updated its GLFW emulation layer to GLFW 3.3 without supporting those. (#6240)
- Examples: Android: Fixed example build for Gradle 8. (#6229, #6227) [@duddel]
- Examples: Updated all examples application to enable ImGuiConfigFlags_NavEnableKeyboard
and ImGuiConfigFlags_NavEnableGamepad by default. (#787)
- Demo: Updated to test return value of BeginTooltip().
- Internals: Misc tweaks to facilitate applying an explicit-context patch. (#5856) [@Dragnalith]

-----------------------------------------------------------------------
VERSION 1.89.3 (Released 2023-02-14)
Expand Down
2 changes: 2 additions & 0 deletions examples/example_emscripten_wgpu/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ static bool InitWGPU()

static void MainLoopStep(void* window)
{
ImGuiIO& io = ImGui::GetIO();

glfwPollEvents();

int width, height;
Expand Down
48 changes: 39 additions & 9 deletions imgui.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dear imgui, v1.89.4 WIP
// dear imgui, v1.89.4
// (main code and documentation)

// Help:
Expand Down Expand Up @@ -399,12 +399,17 @@ CODE
You can read releases logs https://github.com/ocornut/imgui/releases for more details.

(Docking/Viewport Branch)
- 2023/XX/XX (1.XX) - when multi-viewports are enabled, all positions will be in your natural OS coordinates space. It means that:
- reference to hard-coded positions such as in SetNextWindowPos(ImVec2(0,0)) are probably not what you want anymore.
you may use GetMainViewport()->Pos to offset hard-coded positions, e.g. SetNextWindowPos(GetMainViewport()->Pos)
- likewise io.MousePos and GetMousePos() will use OS coordinates.
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.

- 2023/XX/XX (1.XXXX) - when multi-viewports are enabled, all positions will be in your natural OS coordinates space. It means that:
- reference to hard-coded positions such as in SetNextWindowPos(ImVec2(0,0)) are probably not what you want anymore.
you may use GetMainViewport()->Pos to offset hard-coded positions, e.g. SetNextWindowPos(GetMainViewport()->Pos)
- likewise io.MousePos and GetMousePos() will use OS coordinates.
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.

- 2023/03/14 (1.89.4) - commented out redirecting enums/functions names that were marked obsolete two years ago:
- ImGuiSliderFlags_ClampOnInput -> use ImGuiSliderFlags_AlwaysClamp
- ImGuiInputTextFlags_AlwaysInsertMode -> use ImGuiInputTextFlags_AlwaysOverwrite
- ImDrawList::AddBezierCurve() -> use ImDrawList::AddBezierCubic()
- ImDrawList::PathBezierCurveTo() -> use ImDrawList::PathBezierCubicCurveTo()
- 2023/03/09 (1.89.4) - renamed PushAllowKeyboardFocus()/PopAllowKeyboardFocus() to PushTabStop()/PopTabStop(). Kept inline redirection functions (will obsolete).
- 2023/03/09 (1.89.4) - tooltips: Added 'bool' return value to BeginTooltip() for API consistency. Please only submit contents and call EndTooltip() if BeginTooltip() returns true. In reality the function will _currently_ always return true, but further changes down the line may change this, best to clarify API sooner.
- 2023/02/15 (1.89.4) - moved the optional "courtesy maths operators" implementation from imgui_internal.h in imgui.h.
Expand Down Expand Up @@ -1266,6 +1271,8 @@ ImGuiIO::ImGuiIO()
ConfigWindowsResizeFromEdges = true;
ConfigWindowsMoveFromTitleBarOnly = false;
ConfigMemoryCompactTimer = 60.0f;
ConfigDebugBeginReturnValueOnce = false;
ConfigDebugBeginReturnValueLoop = false;

// Platform Functions
// Note: Initialize() will setup default clipboard/ime handlers.
Expand Down Expand Up @@ -4791,6 +4798,13 @@ void ImGui::NewFrame()
Begin("Debug##Default");
IM_ASSERT(g.CurrentWindow->IsFallbackWindow == true);

// [DEBUG] When io.ConfigDebugBeginReturnValue is set, we make Begin()/BeginChild() return false at different level of the window-stack,
// allowing to validate correct Begin/End behavior in user code.
if (g.IO.ConfigDebugBeginReturnValueLoop)
g.DebugBeginReturnValueCullDepth = (g.DebugBeginReturnValueCullDepth == -1) ? 0 : ((g.DebugBeginReturnValueCullDepth + ((g.FrameCount % 4) == 0 ? 1 : 0)) % 10);
else
g.DebugBeginReturnValueCullDepth = -1;

CallContextHooks(&g, ImGuiContextHookType_NewFramePost);
}

Expand Down Expand Up @@ -7260,6 +7274,15 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
IM_ASSERT(window->Appearing == false); // Please report on GitHub if this triggers: https://github.com/ocornut/imgui/issues/4177
}

// [DEBUG] io.ConfigDebugBeginReturnValue override return value to test Begin/End and BeginChild/EndChild behaviors.
// (The implicit fallback window is NOT automatically ended allowing it to always be able to receive commands without crashing)
if (!window->IsFallbackWindow && ((g.IO.ConfigDebugBeginReturnValueOnce && window_just_created) || (g.IO.ConfigDebugBeginReturnValueLoop && g.DebugBeginReturnValueCullDepth == g.CurrentWindowStack.Size)))
{
if (window->AutoFitFramesX > 0) { window->AutoFitFramesX++; }
if (window->AutoFitFramesY > 0) { window->AutoFitFramesY++; }
return false;
}

return !window->SkipItems;
}

Expand Down Expand Up @@ -8104,7 +8127,7 @@ void ImGui::SetItemDefaultFocus()
NavUpdateAnyRequestFlag();

// Scroll could be done in NavInitRequestApplyResult() via an opt-in flag (we however don't want regular init requests to scroll)
if (!IsItemVisible())
if (!window->ClipRect.Contains(g.LastItemData.Rect))
ScrollToRectEx(window, g.LastItemData.Rect, ImGuiScrollFlags_None);
}

Expand Down Expand Up @@ -9643,7 +9666,9 @@ static void ImGui::ErrorCheckEndFrameSanityChecks()
{
if (g.CurrentWindowStack.Size > 1)
{
ImGuiWindow* window = g.CurrentWindowStack.back().Window; // <-- This window was not Ended!
IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size == 1, "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?");
IM_UNUSED(window);
while (g.CurrentWindowStack.Size > 1)
End();
}
Expand Down Expand Up @@ -10591,7 +10616,8 @@ void ImGui::EndTooltip()

void ImGui::SetTooltipV(const char* fmt, va_list args)
{
BeginTooltipEx(ImGuiTooltipFlags_OverridePreviousTooltip, ImGuiWindowFlags_None);
if (!BeginTooltipEx(ImGuiTooltipFlags_OverridePreviousTooltip, ImGuiWindowFlags_None))
return;
TextV(fmt, args);
EndTooltip();
}
Expand Down Expand Up @@ -18972,6 +18998,10 @@ void ImGui::ShowMetricsWindow(bool* p_open)
}
}

Checkbox("Debug Begin/BeginChild return value", &io.ConfigDebugBeginReturnValueLoop);
SameLine();
MetricsHelpMarker("Some calls to Begin()/BeginChild() will return false.\n\nWill cycle through window depths then repeat. Windows should be flickering while running.");

TreePop();
}

Expand Down
Loading

0 comments on commit 9e30fb0

Please sign in to comment.