mirror of
https://github.com/ocornut/imgui.git
synced 2025-04-07 22:43:09 +00:00
Error Handling, Debug Log: added IMGUI_DEBUG_LOG_ERROR() with special handling. (#5855, #1651, #5654)
This commit is contained in:
parent
26785fd873
commit
2360061520
2 changed files with 19 additions and 2 deletions
17
imgui.cpp
17
imgui.cpp
|
@ -3979,8 +3979,9 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
||||||
LogDepthToExpand = LogDepthToExpandDefault = 2;
|
LogDepthToExpand = LogDepthToExpandDefault = 2;
|
||||||
|
|
||||||
DebugDrawIdConflictsCount = 0;
|
DebugDrawIdConflictsCount = 0;
|
||||||
DebugLogFlags = ImGuiDebugLogFlags_OutputToTTY;
|
DebugLogFlags = ImGuiDebugLogFlags_EventError | ImGuiDebugLogFlags_OutputToTTY;
|
||||||
DebugLocateId = 0;
|
DebugLocateId = 0;
|
||||||
|
DebugLogSkippedErrors = 0;
|
||||||
DebugLogAutoDisableFlags = ImGuiDebugLogFlags_None;
|
DebugLogAutoDisableFlags = ImGuiDebugLogFlags_None;
|
||||||
DebugLogAutoDisableFrames = 0;
|
DebugLogAutoDisableFrames = 0;
|
||||||
DebugLocateFrames = 0;
|
DebugLocateFrames = 0;
|
||||||
|
@ -16281,12 +16282,24 @@ static void ShowDebugLogFlag(const char* name, ImGuiDebugLogFlags flags)
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImVec2 size(ImGui::GetFrameHeight() + g.Style.ItemInnerSpacing.x + ImGui::CalcTextSize(name).x, ImGui::GetFrameHeight());
|
ImVec2 size(ImGui::GetFrameHeight() + g.Style.ItemInnerSpacing.x + ImGui::CalcTextSize(name).x, ImGui::GetFrameHeight());
|
||||||
SameLineOrWrap(size); // FIXME-LAYOUT: To be done automatically once we rework ItemSize/ItemAdd into ItemLayout.
|
SameLineOrWrap(size); // FIXME-LAYOUT: To be done automatically once we rework ItemSize/ItemAdd into ItemLayout.
|
||||||
|
|
||||||
|
bool highlight_errors = (flags == ImGuiDebugLogFlags_EventError && g.DebugLogSkippedErrors > 0);
|
||||||
|
if (highlight_errors)
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Text, ImLerp(g.Style.Colors[ImGuiCol_Text], ImVec4(1.0f, 0.0f, 0.0f, 1.0f), 0.30f));
|
||||||
if (ImGui::CheckboxFlags(name, &g.DebugLogFlags, flags) && g.IO.KeyShift && (g.DebugLogFlags & flags) != 0)
|
if (ImGui::CheckboxFlags(name, &g.DebugLogFlags, flags) && g.IO.KeyShift && (g.DebugLogFlags & flags) != 0)
|
||||||
{
|
{
|
||||||
g.DebugLogAutoDisableFrames = 2;
|
g.DebugLogAutoDisableFrames = 2;
|
||||||
g.DebugLogAutoDisableFlags |= flags;
|
g.DebugLogAutoDisableFlags |= flags;
|
||||||
}
|
}
|
||||||
|
if (highlight_errors)
|
||||||
|
{
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
ImGui::SetItemTooltip("%d past errors skipped.", g.DebugLogSkippedErrors);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
ImGui::SetItemTooltip("Hold SHIFT when clicking to enable for 2 frames only (useful for spammy log entries)");
|
ImGui::SetItemTooltip("Hold SHIFT when clicking to enable for 2 frames only (useful for spammy log entries)");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::ShowDebugLogWindow(bool* p_open)
|
void ImGui::ShowDebugLogWindow(bool* p_open)
|
||||||
|
@ -16304,6 +16317,7 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
|
||||||
CheckboxFlags("All", &g.DebugLogFlags, all_enable_flags);
|
CheckboxFlags("All", &g.DebugLogFlags, all_enable_flags);
|
||||||
SetItemTooltip("(except InputRouting which is spammy)");
|
SetItemTooltip("(except InputRouting which is spammy)");
|
||||||
|
|
||||||
|
ShowDebugLogFlag("Errors", ImGuiDebugLogFlags_EventError);
|
||||||
ShowDebugLogFlag("ActiveId", ImGuiDebugLogFlags_EventActiveId);
|
ShowDebugLogFlag("ActiveId", ImGuiDebugLogFlags_EventActiveId);
|
||||||
ShowDebugLogFlag("Clipper", ImGuiDebugLogFlags_EventClipper);
|
ShowDebugLogFlag("Clipper", ImGuiDebugLogFlags_EventClipper);
|
||||||
ShowDebugLogFlag("Focus", ImGuiDebugLogFlags_EventFocus);
|
ShowDebugLogFlag("Focus", ImGuiDebugLogFlags_EventFocus);
|
||||||
|
@ -16317,6 +16331,7 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
|
||||||
{
|
{
|
||||||
g.DebugLogBuf.clear();
|
g.DebugLogBuf.clear();
|
||||||
g.DebugLogIndex.clear();
|
g.DebugLogIndex.clear();
|
||||||
|
g.DebugLogSkippedErrors = 0;
|
||||||
}
|
}
|
||||||
SameLine();
|
SameLine();
|
||||||
if (SmallButton("Copy"))
|
if (SmallButton("Copy"))
|
||||||
|
|
|
@ -217,6 +217,7 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer
|
||||||
#else
|
#else
|
||||||
#define IMGUI_DEBUG_LOG(...) ((void)0)
|
#define IMGUI_DEBUG_LOG(...) ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
#define IMGUI_DEBUG_LOG_ERROR(...) do { ImGuiContext& g2 = *GImGui; if (g2.DebugLogFlags & ImGuiDebugLogFlags_EventError) IMGUI_DEBUG_LOG(__VA_ARGS__); else g2.DebugLogSkippedErrors++; } while (0)
|
||||||
#define IMGUI_DEBUG_LOG_ACTIVEID(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventActiveId) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
#define IMGUI_DEBUG_LOG_ACTIVEID(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventActiveId) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||||
#define IMGUI_DEBUG_LOG_FOCUS(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventFocus) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
#define IMGUI_DEBUG_LOG_FOCUS(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventFocus) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||||
#define IMGUI_DEBUG_LOG_POPUP(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventPopup) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
#define IMGUI_DEBUG_LOG_POPUP(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventPopup) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||||
|
@ -2321,6 +2322,7 @@ struct ImGuiContext
|
||||||
ImGuiDebugLogFlags DebugLogFlags;
|
ImGuiDebugLogFlags DebugLogFlags;
|
||||||
ImGuiTextBuffer DebugLogBuf;
|
ImGuiTextBuffer DebugLogBuf;
|
||||||
ImGuiTextIndex DebugLogIndex;
|
ImGuiTextIndex DebugLogIndex;
|
||||||
|
int DebugLogSkippedErrors;
|
||||||
ImGuiDebugLogFlags DebugLogAutoDisableFlags;
|
ImGuiDebugLogFlags DebugLogAutoDisableFlags;
|
||||||
ImU8 DebugLogAutoDisableFrames;
|
ImU8 DebugLogAutoDisableFrames;
|
||||||
ImU8 DebugLocateFrames; // For DebugLocateItemOnHover(). This is used together with DebugLocateId which is in a hot/cached spot above.
|
ImU8 DebugLocateFrames; // For DebugLocateItemOnHover(). This is used together with DebugLocateId which is in a hot/cached spot above.
|
||||||
|
|
Loading…
Add table
Reference in a new issue