mirror of
https://github.com/ocornut/imgui.git
synced 2025-11-11 13:05:30 +00:00
Debug Tools: Tweaked layout of ID Stack Tool and always display full path. (#4631)
This commit is contained in:
@@ -110,6 +110,7 @@ Other changes:
|
|||||||
One case where it would manifest was calling Combo() with an out of range index. (#8450)
|
One case where it would manifest was calling Combo() with an out of range index. (#8450)
|
||||||
- Debug Tools: Added io.ConfigDebugHighlightIdConflictsShowItemPicker (defaults to true)
|
- Debug Tools: Added io.ConfigDebugHighlightIdConflictsShowItemPicker (defaults to true)
|
||||||
to allow disabled Item Picker suggestion in user facing builds. (#7961, #7669)
|
to allow disabled Item Picker suggestion in user facing builds. (#7961, #7669)
|
||||||
|
- Debug Tools: Tweaked layout of ID Stack Tool and always display full path. (#4631)
|
||||||
- Misc: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursors
|
- Misc: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursors
|
||||||
(busy/wait/hourglass shape, with or without an arrow cursor).
|
(busy/wait/hourglass shape, with or without an arrow cursor).
|
||||||
- Demo: Reorganized "Widgets" section to be alphabetically ordered and split in more functions.
|
- Demo: Reorganized "Widgets" section to be alphabetically ordered and split in more functions.
|
||||||
|
|||||||
50
imgui.cpp
50
imgui.cpp
@@ -16924,42 +16924,44 @@ void ImGui::ShowIDStackToolWindow(bool* p_open)
|
|||||||
|
|
||||||
// Display hovered/active status
|
// Display hovered/active status
|
||||||
ImGuiIDStackTool* tool = &g.DebugIDStackTool;
|
ImGuiIDStackTool* tool = &g.DebugIDStackTool;
|
||||||
const ImGuiID hovered_id = g.HoveredIdPreviousFrame;
|
|
||||||
const ImGuiID active_id = g.ActiveId;
|
// Build and display path
|
||||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
tool->ResultPathBuf.resize(0);
|
||||||
Text("HoveredId: 0x%08X (\"%s\"), ActiveId: 0x%08X (\"%s\")", hovered_id, hovered_id ? ImGuiTestEngine_FindItemDebugLabel(&g, hovered_id) : "", active_id, active_id ? ImGuiTestEngine_FindItemDebugLabel(&g, active_id) : "");
|
for (int stack_n = 0; stack_n < tool->Results.Size; stack_n++)
|
||||||
#else
|
{
|
||||||
Text("HoveredId: 0x%08X, ActiveId: 0x%08X", hovered_id, active_id);
|
char level_desc[256];
|
||||||
#endif
|
StackToolFormatLevelInfo(tool, stack_n, false, level_desc, IM_ARRAYSIZE(level_desc));
|
||||||
|
tool->ResultPathBuf.append(stack_n == 0 ? "//" : "/");
|
||||||
|
for (int n = 0; level_desc[n]; n++)
|
||||||
|
{
|
||||||
|
if (level_desc[n] == '/')
|
||||||
|
tool->ResultPathBuf.append("\\");
|
||||||
|
tool->ResultPathBuf.append(level_desc + n, level_desc + n + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text("0x%08X", tool->QueryId);
|
||||||
SameLine();
|
SameLine();
|
||||||
MetricsHelpMarker("Hover an item with the mouse to display elements of the ID Stack leading to the item's final ID.\nEach level of the stack correspond to a PushID() call.\nAll levels of the stack are hashed together to make the final ID of a widget (ID displayed at the bottom level of the stack).\nRead FAQ entry about the ID stack for details.");
|
MetricsHelpMarker("Hover an item with the mouse to display elements of the ID Stack leading to the item's final ID.\nEach level of the stack correspond to a PushID() call.\nAll levels of the stack are hashed together to make the final ID of a widget (ID displayed at the bottom level of the stack).\nRead FAQ entry about the ID stack for details.");
|
||||||
|
|
||||||
// CTRL+C to copy path
|
// CTRL+C to copy path
|
||||||
const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime;
|
const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime;
|
||||||
Checkbox("Ctrl+C: copy path to clipboard", &tool->CopyToClipboardOnCtrlC);
|
SameLine();
|
||||||
|
PushStyleVarY(ImGuiStyleVar_FramePadding, 0.0f); Checkbox("Ctrl+C: copy path", &tool->CopyToClipboardOnCtrlC); PopStyleVar();
|
||||||
SameLine();
|
SameLine();
|
||||||
TextColored((time_since_copy >= 0.0f && time_since_copy < 0.75f && ImFmod(time_since_copy, 0.25f) < 0.25f * 0.5f) ? ImVec4(1.f, 1.f, 0.3f, 1.f) : ImVec4(), "*COPIED*");
|
TextColored((time_since_copy >= 0.0f && time_since_copy < 0.75f && ImFmod(time_since_copy, 0.25f) < 0.25f * 0.5f) ? ImVec4(1.f, 1.f, 0.3f, 1.f) : ImVec4(), "*COPIED*");
|
||||||
if (tool->CopyToClipboardOnCtrlC && Shortcut(ImGuiMod_Ctrl | ImGuiKey_C, ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused))
|
if (tool->CopyToClipboardOnCtrlC && Shortcut(ImGuiMod_Ctrl | ImGuiKey_C, ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused))
|
||||||
{
|
{
|
||||||
tool->CopyToClipboardLastTime = (float)g.Time;
|
tool->CopyToClipboardLastTime = (float)g.Time;
|
||||||
char* p = g.TempBuffer.Data;
|
SetClipboardText(tool->ResultPathBuf.c_str());
|
||||||
char* p_end = p + g.TempBuffer.Size;
|
|
||||||
for (int stack_n = 0; stack_n < tool->Results.Size && p + 3 < p_end; stack_n++)
|
|
||||||
{
|
|
||||||
*p++ = '/';
|
|
||||||
char level_desc[256];
|
|
||||||
StackToolFormatLevelInfo(tool, stack_n, false, level_desc, IM_ARRAYSIZE(level_desc));
|
|
||||||
for (int n = 0; level_desc[n] && p + 2 < p_end; n++)
|
|
||||||
{
|
|
||||||
if (level_desc[n] == '/')
|
|
||||||
*p++ = '\\';
|
|
||||||
*p++ = level_desc[n];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*p = '\0';
|
|
||||||
SetClipboardText(g.TempBuffer.Data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text("- Path \"%s\"", tool->ResultPathBuf.c_str());
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
|
Text("- Label \"%s\"", tool->QueryId ? ImGuiTestEngine_FindItemDebugLabel(&g, tool->QueryId) : "");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Separator();
|
||||||
|
|
||||||
// Display decorated stack
|
// Display decorated stack
|
||||||
tool->LastActiveFrame = g.FrameCount;
|
tool->LastActiveFrame = g.FrameCount;
|
||||||
if (tool->Results.Size > 0 && BeginTable("##table", 3, ImGuiTableFlags_Borders))
|
if (tool->Results.Size > 0 && BeginTable("##table", 3, ImGuiTableFlags_Borders))
|
||||||
|
|||||||
1
imgui.h
1
imgui.h
@@ -2604,6 +2604,7 @@ struct ImGuiTextBuffer
|
|||||||
int size() const { return Buf.Size ? Buf.Size - 1 : 0; }
|
int size() const { return Buf.Size ? Buf.Size - 1 : 0; }
|
||||||
bool empty() const { return Buf.Size <= 1; }
|
bool empty() const { return Buf.Size <= 1; }
|
||||||
void clear() { Buf.clear(); }
|
void clear() { Buf.clear(); }
|
||||||
|
void resize(int size) { IM_ASSERT(size == 0); if (Buf.Size > 0) Buf.Data[0] = 0; Buf.resize(0); } // Similar to resize(0) on ImVector: empty string but don't free buffer. Only resize(0) supported for now.
|
||||||
void reserve(int capacity) { Buf.reserve(capacity); }
|
void reserve(int capacity) { Buf.reserve(capacity); }
|
||||||
const char* c_str() const { return Buf.Data ? Buf.Data : EmptyString; }
|
const char* c_str() const { return Buf.Data ? Buf.Data : EmptyString; }
|
||||||
IMGUI_API void append(const char* str, const char* str_end = NULL);
|
IMGUI_API void append(const char* str, const char* str_end = NULL);
|
||||||
|
|||||||
@@ -2030,6 +2030,7 @@ struct ImGuiIDStackTool
|
|||||||
ImVector<ImGuiStackLevelInfo> Results;
|
ImVector<ImGuiStackLevelInfo> Results;
|
||||||
bool CopyToClipboardOnCtrlC;
|
bool CopyToClipboardOnCtrlC;
|
||||||
float CopyToClipboardLastTime;
|
float CopyToClipboardLastTime;
|
||||||
|
ImGuiTextBuffer ResultPathBuf;
|
||||||
|
|
||||||
ImGuiIDStackTool() { memset(this, 0, sizeof(*this)); CopyToClipboardLastTime = -FLT_MAX; }
|
ImGuiIDStackTool() { memset(this, 0, sizeof(*this)); CopyToClipboardLastTime = -FLT_MAX; }
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user