1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-28 09:30:56 +01:00

Enclosed a few more remaining sections in ifndef IMGUI_DISABLE_DEBUG_TOOLS for completeness.

This commit is contained in:
ocornut 2024-01-17 15:55:36 +01:00
parent 33fabdf392
commit 1a48a63446

View File

@ -4147,17 +4147,19 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id, ImGuiItemFlags item_flag
return false; return false;
} }
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
if (id != 0) if (id != 0)
{ {
// [DEBUG] Item Picker tool! // [DEBUG] Item Picker tool!
// We perform the check here because SetHoveredID() is not frequently called (1~ time a frame), making // We perform the check here because reaching is path is rare (1~ time a frame),
// the cost of this tool near-zero. We can get slightly better call-stack and support picking non-hovered // making the cost of this tool near-zero! We could get better call-stack and support picking non-hovered
// items if we performed the test in ItemAdd(), but that would incur a small runtime cost. // items if we performed the test in ItemAdd(), but that would incur a bigger runtime cost.
if (g.DebugItemPickerActive && g.HoveredIdPreviousFrame == id) if (g.DebugItemPickerActive && g.HoveredIdPreviousFrame == id)
GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255)); GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255));
if (g.DebugItemPickerBreakId == id) if (g.DebugItemPickerBreakId == id)
IM_DEBUG_BREAK(); IM_DEBUG_BREAK();
} }
#endif
if (g.NavDisableMouseHover) if (g.NavDisableMouseHover)
return false; return false;
@ -4792,6 +4794,7 @@ void ImGui::NewFrame()
g.GroupStack.resize(0); g.GroupStack.resize(0);
// [DEBUG] Update debug features // [DEBUG] Update debug features
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
UpdateDebugToolItemPicker(); UpdateDebugToolItemPicker();
UpdateDebugToolStackQueries(); UpdateDebugToolStackQueries();
UpdateDebugToolFlashStyleColor(); UpdateDebugToolFlashStyleColor();
@ -4806,6 +4809,7 @@ void ImGui::NewFrame()
g.DebugLogFlags &= ~g.DebugLogAutoDisableFlags; g.DebugLogFlags &= ~g.DebugLogAutoDisableFlags;
g.DebugLogAutoDisableFlags = ImGuiDebugLogFlags_None; g.DebugLogAutoDisableFlags = ImGuiDebugLogFlags_None;
} }
#endif
// Create implicit/fallback window - which we will only render it if the user has added something to it. // Create implicit/fallback window - which we will only render it if the user has added something to it.
// We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags. // We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
@ -4817,10 +4821,12 @@ void ImGui::NewFrame()
// [DEBUG] When io.ConfigDebugBeginReturnValue is set, we make Begin()/BeginChild() return false at different level of the window-stack, // [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. // allowing to validate correct Begin/End behavior in user code.
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
if (g.IO.ConfigDebugBeginReturnValueLoop) if (g.IO.ConfigDebugBeginReturnValueLoop)
g.DebugBeginReturnValueCullDepth = (g.DebugBeginReturnValueCullDepth == -1) ? 0 : ((g.DebugBeginReturnValueCullDepth + ((g.FrameCount % 4) == 0 ? 1 : 0)) % 10); g.DebugBeginReturnValueCullDepth = (g.DebugBeginReturnValueCullDepth == -1) ? 0 : ((g.DebugBeginReturnValueCullDepth + ((g.FrameCount % 4) == 0 ? 1 : 0)) % 10);
else else
g.DebugBeginReturnValueCullDepth = -1; g.DebugBeginReturnValueCullDepth = -1;
#endif
CallContextHooks(&g, ImGuiContextHookType_NewFramePost); CallContextHooks(&g, ImGuiContextHookType_NewFramePost);
} }
@ -7059,12 +7065,15 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// [DEBUG] io.ConfigDebugBeginReturnValue override return value to test Begin/End and BeginChild/EndChild behaviors. // [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) // (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))) #ifndef IMGUI_DISABLE_DEBUG_TOOLS
if (!window->IsFallbackWindow)
if ((g.IO.ConfigDebugBeginReturnValueOnce && window_just_created) || (g.IO.ConfigDebugBeginReturnValueLoop && g.DebugBeginReturnValueCullDepth == g.CurrentWindowStack.Size))
{ {
if (window->AutoFitFramesX > 0) { window->AutoFitFramesX++; } if (window->AutoFitFramesX > 0) { window->AutoFitFramesX++; }
if (window->AutoFitFramesY > 0) { window->AutoFitFramesY++; } if (window->AutoFitFramesY > 0) { window->AutoFitFramesY++; }
return false; return false;
} }
#endif
return !window->SkipItems; return !window->SkipItems;
} }
@ -15561,9 +15570,6 @@ void ImGui::DebugLogV(const char*, va_list) {}
void ImGui::ShowDebugLogWindow(bool*) {} void ImGui::ShowDebugLogWindow(bool*) {}
void ImGui::ShowIDStackToolWindow(bool*) {} void ImGui::ShowIDStackToolWindow(bool*) {}
void ImGui::DebugHookIdInfo(ImGuiID, ImGuiDataType, const void*, const void*) {} void ImGui::DebugHookIdInfo(ImGuiID, ImGuiDataType, const void*, const void*) {}
void ImGui::UpdateDebugToolItemPicker() {}
void ImGui::UpdateDebugToolStackQueries() {}
void ImGui::UpdateDebugToolFlashStyleColor() {}
#endif // #ifndef IMGUI_DISABLE_DEBUG_TOOLS #endif // #ifndef IMGUI_DISABLE_DEBUG_TOOLS