mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-29 03:00:05 +00:00
This commit is contained in:
parent
f39b138487
commit
0ba02a4ed6
4 changed files with 36 additions and 0 deletions
25
imgui.cpp
25
imgui.cpp
|
|
@ -4263,6 +4263,12 @@ void ImGui::Initialize()
|
|||
#ifdef IMGUI_HAS_DOCK
|
||||
#endif
|
||||
|
||||
// Print a debug message when running with debug feature IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS because it is very slow.
|
||||
// DO NOT COMMENT OUT THIS MESSAGE. IT IS DESIGNED TO REMIND YOU THAT IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS SHOULD ONLY BE TEMPORARILY ENABLED.
|
||||
#ifdef IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS
|
||||
DebugLog("IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS is enabled.\nMust disable after use! Otherwise Dear ImGui will run slower.\n");
|
||||
#endif
|
||||
|
||||
// ImDrawList/ImFontAtlas are designed to function without ImGui, and 99% of it works without an ImGui context.
|
||||
// But this link allows us to facilitate/handle a few edge cases better.
|
||||
ImFontAtlas* atlas = g.IO.Fonts;
|
||||
|
|
@ -11012,6 +11018,21 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
|
|||
// Empty identifier are valid and useful in a small amount of cases, but 99.9% of the time you want to use "##something".
|
||||
// READ THE FAQ: https://dearimgui.com/faq
|
||||
IM_ASSERT(id != window->ID && "Cannot have an empty ID at the root of a window. If you need an empty label, use ## and read the FAQ about how the ID Stack works!");
|
||||
|
||||
// [DEBUG] Highlight all conflicts WITHOUT needing to hover. THIS WILL SLOW DOWN DEAR IMGUI. DON'T KEEP ACTIVATED.
|
||||
// This will only work for items submitted with ItemAdd(). Some very rare/odd/unrecommended code patterns are calling ButtonBehavior() without ItemAdd().
|
||||
#ifdef IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS
|
||||
if ((g.LastItemData.ItemFlags & ImGuiItemFlags_AllowDuplicateId) == 0)
|
||||
{
|
||||
int* p_alive = g.DebugDrawIdConflictsAliveCount.GetIntRef(id, -1); // Could halve lookups if we knew ImGuiStorage can store 64-bit, or by storing FrameCount as 30-bits + highlight as 2-bits. But the point is that we should not pretend that this is fast.
|
||||
int* p_highlight = g.DebugDrawIdConflictsHighlightSet.GetIntRef(id, -1);
|
||||
if (*p_alive == g.FrameCount)
|
||||
*p_highlight = g.FrameCount;
|
||||
*p_alive = g.FrameCount;
|
||||
if (*p_highlight >= g.FrameCount - 1)
|
||||
window->DrawList->AddRect(bb.Min - ImVec2(1, 1), bb.Max + ImVec2(1, 1), IM_COL32(255, 0, 0, 255), 0.0f, ImDrawFlags_None, 2.0f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
//if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG]
|
||||
//if ((g.LastItemData.ItemFlags & ImGuiItemFlags_NoNav) == 0)
|
||||
|
|
@ -16126,6 +16147,10 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||
}
|
||||
};
|
||||
|
||||
#ifdef IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS
|
||||
TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS is enabled.\nMust disable after use! Otherwise Dear ImGui will run slower.\n");
|
||||
#endif
|
||||
|
||||
// Tools
|
||||
if (TreeNode("Tools"))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue