mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-13 08:19:55 +02:00
Debug Tools: Debug Log: Clicking any filter with SHIFT held enables it for 2 frames only. (#5855)
This commit is contained in:
44
imgui.cpp
44
imgui.cpp
@ -4788,10 +4788,11 @@ void ImGui::NewFrame()
|
||||
UpdateDebugToolFlashStyleColor();
|
||||
if (g.DebugLocateFrames > 0 && --g.DebugLocateFrames == 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");
|
||||
g.DebugLogFlags &= ~ImGuiDebugLogFlags_EventClipper;
|
||||
DebugLog("(Debug Log: Auto-disabled some ImGuiDebugLogFlags after 2 frames)\n");
|
||||
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.
|
||||
@ -14968,6 +14969,29 @@ void ImGui::DebugLogV(const char* fmt, va_list args)
|
||||
#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)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -14980,13 +15004,13 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
|
||||
}
|
||||
|
||||
CheckboxFlags("All", &g.DebugLogFlags, ImGuiDebugLogFlags_EventMask_);
|
||||
SameLine(); CheckboxFlags("ActiveId", &g.DebugLogFlags, ImGuiDebugLogFlags_EventActiveId);
|
||||
SameLine(); CheckboxFlags("Focus", &g.DebugLogFlags, ImGuiDebugLogFlags_EventFocus);
|
||||
SameLine(); CheckboxFlags("Popup", &g.DebugLogFlags, ImGuiDebugLogFlags_EventPopup);
|
||||
SameLine(); CheckboxFlags("Nav", &g.DebugLogFlags, ImGuiDebugLogFlags_EventNav);
|
||||
SameLine(); if (CheckboxFlags("Clipper", &g.DebugLogFlags, ImGuiDebugLogFlags_EventClipper)) { g.DebugLogClipperAutoDisableFrames = 2; } if (IsItemHovered()) SetTooltip("Clipper log auto-disabled after 2 frames");
|
||||
//SameLine(); CheckboxFlags("Selection", &g.DebugLogFlags, ImGuiDebugLogFlags_EventSelection);
|
||||
SameLine(); CheckboxFlags("IO", &g.DebugLogFlags, ImGuiDebugLogFlags_EventIO);
|
||||
ShowDebugLogFlag("ActiveId", ImGuiDebugLogFlags_EventActiveId);
|
||||
ShowDebugLogFlag("Clipper", ImGuiDebugLogFlags_EventClipper);
|
||||
ShowDebugLogFlag("Focus", ImGuiDebugLogFlags_EventFocus);
|
||||
ShowDebugLogFlag("IO", ImGuiDebugLogFlags_EventIO);
|
||||
ShowDebugLogFlag("Nav", ImGuiDebugLogFlags_EventNav);
|
||||
ShowDebugLogFlag("Popup", ImGuiDebugLogFlags_EventPopup);
|
||||
//ShowDebugLogFlag("Selection", ImGuiDebugLogFlags_EventSelection);
|
||||
|
||||
if (SmallButton("Clear"))
|
||||
{
|
||||
|
Reference in New Issue
Block a user