Debug Tools: Debug Log: Clicking any filter with SHIFT held enables it for 2 frames only. (#5855)

This commit is contained in:
ocornut 2024-01-10 12:56:16 +01:00
parent a3eea8a75a
commit a5dec42866
4 changed files with 55 additions and 24 deletions

View File

@ -84,7 +84,9 @@ Other changes:
- Settings: Fixed an issue marking settings as dirty when merely clicking on a border or resize - Settings: Fixed an issue marking settings as dirty when merely clicking on a border or resize
grip without moving it. grip without moving it.
- Debug Tools: Added DebugFlashStyleColor() to identify a style color. Added to Style Editor. - Debug Tools: Added DebugFlashStyleColor() to identify a style color. Added to Style Editor.
- Debug Tools: Debug Log: Hide its own clipper log to reduce noise in the output. - Debug Tools: Debug Log: Hide its own clipper log to reduce noise in the output. (#5855)
- Debug Tools: Debug Log: Clicking any filter with SHIFT held enables it for 2 frames only,
making it easier when dealing with spammy logs. (#5855)
- Misc: Added IMGUI_USER_H_FILENAME to change the path included when using - Misc: Added IMGUI_USER_H_FILENAME to change the path included when using
IMGUI_INCLUDE_IMGUI_USER_H. (#7039) [@bryceberger] IMGUI_INCLUDE_IMGUI_USER_H. (#7039) [@bryceberger]
- Misc: Rework debug display of texture id in Metrics window to avoid compile-error when - Misc: Rework debug display of texture id in Metrics window to avoid compile-error when

View File

@ -4788,10 +4788,11 @@ void ImGui::NewFrame()
UpdateDebugToolFlashStyleColor(); UpdateDebugToolFlashStyleColor();
if (g.DebugLocateFrames > 0 && --g.DebugLocateFrames == 0) if (g.DebugLocateFrames > 0 && --g.DebugLocateFrames == 0)
g.DebugLocateId = 0; g.DebugLocateId = 0;
if (g.DebugLogClipperAutoDisableFrames > 0 && --g.DebugLogClipperAutoDisableFrames == 0) if (g.DebugLogAutoDisableFrames > 0 && --g.DebugLogAutoDisableFrames == 0)
{ {
DebugLog("(Debug Log: Auto-disabled ImGuiDebugLogFlags_EventClipper after 2 frames)\n"); DebugLog("(Debug Log: Auto-disabled some ImGuiDebugLogFlags after 2 frames)\n");
g.DebugLogFlags &= ~ImGuiDebugLogFlags_EventClipper; g.DebugLogFlags &= ~g.DebugLogAutoDisableFlags;
g.DebugLogAutoDisableFlags = ImGuiDebugLogFlags_None;
} }
// 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.
@ -14968,6 +14969,29 @@ void ImGui::DebugLogV(const char* fmt, va_list args)
#endif #endif
} }
// FIXME-LAYOUT: To be done automatically via layout mode once we rework ItemSize/ItemAdd into ItemLayout.
static void SameLineOrWrap(const ImVec2& size)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImVec2 pos(window->DC.CursorPosPrevLine.x + g.Style.ItemSpacing.x, window->DC.CursorPosPrevLine.y);
if (window->ClipRect.Contains(ImRect(pos, pos + size)))
ImGui::SameLine();
}
static void ShowDebugLogFlag(const char* name, ImGuiDebugLogFlags flags)
{
ImGuiContext& g = *GImGui;
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.
if (ImGui::CheckboxFlags(name, &g.DebugLogFlags, flags) && g.IO.KeyShift && (g.DebugLogFlags & flags) != 0)
{
g.DebugLogAutoDisableFrames = 2;
g.DebugLogAutoDisableFlags |= flags;
}
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)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
@ -14980,13 +15004,13 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
} }
CheckboxFlags("All", &g.DebugLogFlags, ImGuiDebugLogFlags_EventMask_); CheckboxFlags("All", &g.DebugLogFlags, ImGuiDebugLogFlags_EventMask_);
SameLine(); CheckboxFlags("ActiveId", &g.DebugLogFlags, ImGuiDebugLogFlags_EventActiveId); ShowDebugLogFlag("ActiveId", ImGuiDebugLogFlags_EventActiveId);
SameLine(); CheckboxFlags("Focus", &g.DebugLogFlags, ImGuiDebugLogFlags_EventFocus); ShowDebugLogFlag("Clipper", ImGuiDebugLogFlags_EventClipper);
SameLine(); CheckboxFlags("Popup", &g.DebugLogFlags, ImGuiDebugLogFlags_EventPopup); ShowDebugLogFlag("Focus", ImGuiDebugLogFlags_EventFocus);
SameLine(); CheckboxFlags("Nav", &g.DebugLogFlags, ImGuiDebugLogFlags_EventNav); ShowDebugLogFlag("IO", ImGuiDebugLogFlags_EventIO);
SameLine(); if (CheckboxFlags("Clipper", &g.DebugLogFlags, ImGuiDebugLogFlags_EventClipper)) { g.DebugLogClipperAutoDisableFrames = 2; } if (IsItemHovered()) SetTooltip("Clipper log auto-disabled after 2 frames"); ShowDebugLogFlag("Nav", ImGuiDebugLogFlags_EventNav);
//SameLine(); CheckboxFlags("Selection", &g.DebugLogFlags, ImGuiDebugLogFlags_EventSelection); ShowDebugLogFlag("Popup", ImGuiDebugLogFlags_EventPopup);
SameLine(); CheckboxFlags("IO", &g.DebugLogFlags, ImGuiDebugLogFlags_EventIO); //ShowDebugLogFlag("Selection", ImGuiDebugLogFlags_EventSelection);
if (SmallButton("Clear")) if (SmallButton("Clear"))
{ {

View File

@ -6685,10 +6685,12 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
if (!filter.PassFilter(name)) if (!filter.PassFilter(name))
continue; continue;
ImGui::PushID(i); ImGui::PushID(i);
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
if (ImGui::Button("?")) if (ImGui::Button("?"))
ImGui::DebugFlashStyleColor((ImGuiCol)i); ImGui::DebugFlashStyleColor((ImGuiCol)i);
ImGui::SetItemTooltip("Flash given color to identify places where it is used."); ImGui::SetItemTooltip("Flash given color to identify places where it is used.");
ImGui::SameLine(); ImGui::SameLine();
#endif
ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags); ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags);
if (memcmp(&style.Colors[i], &ref->Colors[i], sizeof(ImVec4)) != 0) if (memcmp(&style.Colors[i], &ref->Colors[i], sizeof(ImVec4)) != 0)
{ {

View File

@ -1788,9 +1788,10 @@ enum ImGuiDebugLogFlags_
ImGuiDebugLogFlags_EventClipper = 1 << 4, ImGuiDebugLogFlags_EventClipper = 1 << 4,
ImGuiDebugLogFlags_EventSelection = 1 << 5, ImGuiDebugLogFlags_EventSelection = 1 << 5,
ImGuiDebugLogFlags_EventIO = 1 << 6, ImGuiDebugLogFlags_EventIO = 1 << 6,
ImGuiDebugLogFlags_EventMask_ = ImGuiDebugLogFlags_EventActiveId | ImGuiDebugLogFlags_EventFocus | ImGuiDebugLogFlags_EventPopup | ImGuiDebugLogFlags_EventNav | ImGuiDebugLogFlags_EventClipper | ImGuiDebugLogFlags_EventSelection | ImGuiDebugLogFlags_EventIO, ImGuiDebugLogFlags_EventMask_ = ImGuiDebugLogFlags_EventActiveId | ImGuiDebugLogFlags_EventFocus | ImGuiDebugLogFlags_EventPopup | ImGuiDebugLogFlags_EventNav | ImGuiDebugLogFlags_EventClipper | ImGuiDebugLogFlags_EventSelection | ImGuiDebugLogFlags_EventIO,
ImGuiDebugLogFlags_OutputToTTY = 1 << 10, // Also send output to TTY ImGuiDebugLogFlags_OutputToTTY = 1 << 20, // Also send output to TTY
ImGuiDebugLogFlags_OutputToTestEngine = 1 << 11, // Also send output to Test Engine ImGuiDebugLogFlags_OutputToTestEngine = 1 << 21, // Also send output to Test Engine
}; };
struct ImGuiDebugAllocEntry struct ImGuiDebugAllocEntry
@ -2161,7 +2162,8 @@ struct ImGuiContext
ImGuiDebugLogFlags DebugLogFlags; ImGuiDebugLogFlags DebugLogFlags;
ImGuiTextBuffer DebugLogBuf; ImGuiTextBuffer DebugLogBuf;
ImGuiTextIndex DebugLogIndex; ImGuiTextIndex DebugLogIndex;
ImU8 DebugLogClipperAutoDisableFrames; ImGuiDebugLogFlags DebugLogAutoDisableFlags;
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.
ImS8 DebugBeginReturnValueCullDepth; // Cycle between 0..9 then wrap around. ImS8 DebugBeginReturnValueCullDepth; // Cycle between 0..9 then wrap around.
bool DebugItemPickerActive; // Item picker is active (started with DebugStartItemPicker()) bool DebugItemPickerActive; // Item picker is active (started with DebugStartItemPicker())
@ -2347,7 +2349,8 @@ struct ImGuiContext
DebugLogFlags = ImGuiDebugLogFlags_OutputToTTY; DebugLogFlags = ImGuiDebugLogFlags_OutputToTTY;
DebugLocateId = 0; DebugLocateId = 0;
DebugLogClipperAutoDisableFrames = 0; DebugLogAutoDisableFlags = ImGuiDebugLogFlags_None;
DebugLogAutoDisableFrames = 0;
DebugLocateFrames = 0; DebugLocateFrames = 0;
DebugBeginReturnValueCullDepth = -1; DebugBeginReturnValueCullDepth = -1;
DebugItemPickerActive = false; DebugItemPickerActive = false;