From e2cd5b879eae7c00d084b0ead81d08470ca10eb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Wed, 22 Apr 2020 19:42:17 -0700 Subject: [PATCH] Updated ImGui. --- 3rdparty/dear-imgui/imgui.cpp | 39 ++++++++++++++++++++------- 3rdparty/dear-imgui/imgui.h | 2 +- 3rdparty/dear-imgui/imgui_internal.h | 18 ++++++------- 3rdparty/dear-imgui/imgui_widgets.cpp | 1 - 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/3rdparty/dear-imgui/imgui.cpp b/3rdparty/dear-imgui/imgui.cpp index c8781d49f..7c6042143 100644 --- a/3rdparty/dear-imgui/imgui.cpp +++ b/3rdparty/dear-imgui/imgui.cpp @@ -2891,6 +2891,10 @@ 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); ImGui::KeepAliveID(id); +#ifdef IMGUI_ENABLE_TEST_ENGINE + ImGuiContext& g = *GImGui; + IMGUI_TEST_ENGINE_ID_INFO2(id, ImGuiDataType_String, str, str_end); +#endif return id; } @@ -2899,6 +2903,10 @@ ImGuiID ImGuiWindow::GetID(const void* ptr) ImGuiID seed = IDStack.back(); ImGuiID id = ImHashData(&ptr, sizeof(void*), seed); ImGui::KeepAliveID(id); +#ifdef IMGUI_ENABLE_TEST_ENGINE + ImGuiContext& g = *GImGui; + IMGUI_TEST_ENGINE_ID_INFO(id, ImGuiDataType_Pointer, ptr); +#endif return id; } @@ -2907,25 +2915,44 @@ ImGuiID ImGuiWindow::GetID(int n) ImGuiID seed = IDStack.back(); ImGuiID id = ImHashData(&n, sizeof(n), seed); ImGui::KeepAliveID(id); +#ifdef IMGUI_ENABLE_TEST_ENGINE + ImGuiContext& g = *GImGui; + IMGUI_TEST_ENGINE_ID_INFO(id, ImGuiDataType_S32, (intptr_t)n); +#endif return id; } ImGuiID ImGuiWindow::GetIDNoKeepAlive(const char* str, const char* str_end) { ImGuiID seed = IDStack.back(); - return ImHashStr(str, str_end ? (str_end - str) : 0, seed); + ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); +#ifdef IMGUI_ENABLE_TEST_ENGINE + ImGuiContext& g = *GImGui; + IMGUI_TEST_ENGINE_ID_INFO2(id, ImGuiDataType_String, str, str_end); +#endif + return id; } ImGuiID ImGuiWindow::GetIDNoKeepAlive(const void* ptr) { ImGuiID seed = IDStack.back(); - return ImHashData(&ptr, sizeof(void*), seed); + ImGuiID id = ImHashData(&ptr, sizeof(void*), seed); +#ifdef IMGUI_ENABLE_TEST_ENGINE + ImGuiContext& g = *GImGui; + IMGUI_TEST_ENGINE_ID_INFO(id, ImGuiDataType_Pointer, ptr); +#endif + return id; } ImGuiID ImGuiWindow::GetIDNoKeepAlive(int n) { ImGuiID seed = IDStack.back(); - return ImHashData(&n, sizeof(n), seed); + ImGuiID id = ImHashData(&n, sizeof(n), seed); +#ifdef IMGUI_ENABLE_TEST_ENGINE + ImGuiContext& g = *GImGui; + IMGUI_TEST_ENGINE_ID_INFO(id, ImGuiDataType_S32, (intptr_t)n); +#endif + return id; } // This is only used in rare/specific situations to manufacture an ID out of nowhere. @@ -6599,7 +6626,6 @@ void ImGui::PushFocusScope(ImGuiID id) ImGuiWindow* window = g.CurrentWindow; window->IDStack.push_back(window->DC.NavFocusScopeIdCurrent); window->DC.NavFocusScopeIdCurrent = id; - IMGUI_TEST_ENGINE_PUSH_ID(id, ImGuiDataType_ID, NULL); } void ImGui::PopFocusScope() @@ -6655,7 +6681,6 @@ void ImGui::PushID(const char* str_id) ImGuiWindow* window = g.CurrentWindow; ImGuiID id = window->GetIDNoKeepAlive(str_id); window->IDStack.push_back(id); - IMGUI_TEST_ENGINE_PUSH_ID(id, ImGuiDataType_String, str_id); } void ImGui::PushID(const char* str_id_begin, const char* str_id_end) @@ -6664,7 +6689,6 @@ void ImGui::PushID(const char* str_id_begin, const char* str_id_end) ImGuiWindow* window = g.CurrentWindow; ImGuiID id = window->GetIDNoKeepAlive(str_id_begin, str_id_end); window->IDStack.push_back(id); - IMGUI_TEST_ENGINE_PUSH_ID2(id, ImGuiDataType_String, str_id_begin, str_id_end); } void ImGui::PushID(const void* ptr_id) @@ -6673,7 +6697,6 @@ void ImGui::PushID(const void* ptr_id) ImGuiWindow* window = g.CurrentWindow; ImGuiID id = window->GetIDNoKeepAlive(ptr_id); window->IDStack.push_back(id); - IMGUI_TEST_ENGINE_PUSH_ID(id, ImGuiDataType_Pointer, ptr_id); } void ImGui::PushID(int int_id) @@ -6682,7 +6705,6 @@ void ImGui::PushID(int int_id) ImGuiWindow* window = g.CurrentWindow; ImGuiID id = window->GetIDNoKeepAlive(int_id); window->IDStack.push_back(id); - IMGUI_TEST_ENGINE_PUSH_ID(id, ImGuiDataType_S32, (intptr_t)int_id); } // Push a given id value ignoring the ID stack as a seed. @@ -6691,7 +6713,6 @@ void ImGui::PushOverrideID(ImGuiID id) ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; window->IDStack.push_back(id); - IMGUI_TEST_ENGINE_PUSH_ID(id, ImGuiDataType_ID, NULL); } void ImGui::PopID() diff --git a/3rdparty/dear-imgui/imgui.h b/3rdparty/dear-imgui/imgui.h index 07d8c8b7a..394742891 100644 --- a/3rdparty/dear-imgui/imgui.h +++ b/3rdparty/dear-imgui/imgui.h @@ -1265,7 +1265,7 @@ enum ImGuiMouseCursor_ enum ImGuiCond_ { ImGuiCond_Always = 1 << 0, // Set the variable - ImGuiCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call with succeed) + ImGuiCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call will succeed) ImGuiCond_FirstUseEver = 1 << 2, // Set the variable if the object/window has no persistently saved data (no entry in .ini file) ImGuiCond_Appearing = 1 << 3 // Set the variable if the object/window is appearing after being hidden/inactive (or the first time) }; diff --git a/3rdparty/dear-imgui/imgui_internal.h b/3rdparty/dear-imgui/imgui_internal.h index 407b77ccb..d6ef765d4 100644 --- a/3rdparty/dear-imgui/imgui_internal.h +++ b/3rdparty/dear-imgui/imgui_internal.h @@ -1042,8 +1042,8 @@ struct ImGuiContext bool WithinFrameScope; // Set by NewFrame(), cleared by EndFrame() bool WithinFrameScopeWithImplicitWindow; // Set by NewFrame(), cleared by EndFrame() when the implicit debug window has been pushed bool WithinEndChild; // Set within EndChild() - bool TestEngineHookItems; // Will call test engine hooks ImGuiTestEngineHook_ItemAdd(), ImGuiTestEngineHook_ItemInfo(), ImGuiTestEngineHook_Log() - ImGuiID TestEngineHookPushId; + bool TestEngineHookItems; // Will call test engine hooks: ImGuiTestEngineHook_ItemAdd(), ImGuiTestEngineHook_ItemInfo(), ImGuiTestEngineHook_Log() + ImGuiID TestEngineHookIdInfo; // Will call test engine hooks: ImGuiTestEngineHook_IdInfo() from GetID() void* TestEngine; // Test engine user data // Windows state @@ -1253,7 +1253,7 @@ struct ImGuiContext FrameCountEnded = FrameCountRendered = -1; WithinFrameScope = WithinFrameScopeWithImplicitWindow = WithinEndChild = false; TestEngineHookItems = false; - TestEngineHookPushId = 0; + TestEngineHookIdInfo = 0; TestEngine = NULL; WindowsActiveCount = 0; @@ -1951,20 +1951,20 @@ extern void ImGuiTestEngineHook_PreNewFrame(ImGuiContext* ctx); extern void ImGuiTestEngineHook_PostNewFrame(ImGuiContext* ctx); extern void ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id); extern void ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, ImGuiItemStatusFlags flags); -extern void ImGuiTestEngineHook_PushID(ImGuiContext* ctx, ImGuiDataType data_type, ImGuiID id, const void* data_id); -extern void ImGuiTestEngineHook_PushID(ImGuiContext* ctx, ImGuiDataType data_type, ImGuiID id, const void* data_id, const void* data_id_end); +extern void ImGuiTestEngineHook_IdInfo(ImGuiContext* ctx, ImGuiDataType data_type, ImGuiID id, const void* data_id); +extern void ImGuiTestEngineHook_IdInfo(ImGuiContext* ctx, ImGuiDataType data_type, ImGuiID id, const void* data_id, const void* data_id_end); extern void ImGuiTestEngineHook_Log(ImGuiContext* ctx, const char* fmt, ...); #define IMGUI_TEST_ENGINE_ITEM_ADD(_BB,_ID) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemAdd(&g, _BB, _ID) // Register item bounding box #define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS) // Register item label and status flags (optional) #define IMGUI_TEST_ENGINE_LOG(_FMT,...) if (g.TestEngineHookItems) ImGuiTestEngineHook_Log(&g, _FMT, __VA_ARGS__) // Custom log entry from user land into test log -#define IMGUI_TEST_ENGINE_PUSH_ID(_ID,_TYPE,_DATA) if (g.TestEngineHookPushId == id) ImGuiTestEngineHook_PushID(&g, _TYPE, _ID, (const void*)(_DATA)); -#define IMGUI_TEST_ENGINE_PUSH_ID2(_ID,_TYPE,_DATA,_DATA2) if (g.TestEngineHookPushId == id) ImGuiTestEngineHook_PushID(&g, _TYPE, _ID, (const void*)(_DATA), (const void*)(_DATA2)); +#define IMGUI_TEST_ENGINE_ID_INFO(_ID,_TYPE,_DATA) if (g.TestEngineHookIdInfo == id) ImGuiTestEngineHook_IdInfo(&g, _TYPE, _ID, (const void*)(_DATA)); +#define IMGUI_TEST_ENGINE_ID_INFO2(_ID,_TYPE,_DATA,_DATA2) if (g.TestEngineHookIdInfo == id) ImGuiTestEngineHook_IdInfo(&g, _TYPE, _ID, (const void*)(_DATA), (const void*)(_DATA2)); #else #define IMGUI_TEST_ENGINE_ITEM_ADD(_BB,_ID) do { } while (0) #define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) do { } while (0) #define IMGUI_TEST_ENGINE_LOG(_FMT,...) do { } while (0) -#define IMGUI_TEST_ENGINE_PUSH_ID(_ID,_TYPE,_DATA) do { } while (0) -#define IMGUI_TEST_ENGINE_PUSH_ID2(_ID,_TYPE,_DATA,_DATA2) do { } while (0) +#define IMGUI_TEST_ENGINE_ID_INFO(_ID,_TYPE,_DATA) do { } while (0) +#define IMGUI_TEST_ENGINE_ID_INFO2(_ID,_TYPE,_DATA,_DATA2) do { } while (0) #endif #if defined(__clang__) diff --git a/3rdparty/dear-imgui/imgui_widgets.cpp b/3rdparty/dear-imgui/imgui_widgets.cpp index 8c7515e85..0ded58582 100644 --- a/3rdparty/dear-imgui/imgui_widgets.cpp +++ b/3rdparty/dear-imgui/imgui_widgets.cpp @@ -5513,7 +5513,6 @@ void ImGui::TreePushOverrideID(ImGuiID id) Indent(); window->DC.TreeDepth++; window->IDStack.push_back(id); - IMGUI_TEST_ENGINE_PUSH_ID(id, ImGuiDataType_ID, NULL); } void ImGui::TreePop()