mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-11-04 01:34:32 +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)
 | 
			
		||||
- Debug Tools: Added io.ConfigDebugHighlightIdConflictsShowItemPicker (defaults to true)
 | 
			
		||||
  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
 | 
			
		||||
  (busy/wait/hourglass shape, with or without an arrow cursor).
 | 
			
		||||
- 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
 | 
			
		||||
    ImGuiIDStackTool* tool = &g.DebugIDStackTool;
 | 
			
		||||
    const ImGuiID hovered_id = g.HoveredIdPreviousFrame;
 | 
			
		||||
    const ImGuiID active_id = g.ActiveId;
 | 
			
		||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
 | 
			
		||||
    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) : "");
 | 
			
		||||
#else
 | 
			
		||||
    Text("HoveredId: 0x%08X, ActiveId:  0x%08X", hovered_id, active_id);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    // Build and display path
 | 
			
		||||
    tool->ResultPathBuf.resize(0);
 | 
			
		||||
    for (int stack_n = 0; stack_n < tool->Results.Size; stack_n++)
 | 
			
		||||
    {
 | 
			
		||||
        char level_desc[256];
 | 
			
		||||
        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();
 | 
			
		||||
    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
 | 
			
		||||
    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();
 | 
			
		||||
    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))
 | 
			
		||||
    {
 | 
			
		||||
        tool->CopyToClipboardLastTime = (float)g.Time;
 | 
			
		||||
        char* p = g.TempBuffer.Data;
 | 
			
		||||
        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);
 | 
			
		||||
        SetClipboardText(tool->ResultPathBuf.c_str());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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
 | 
			
		||||
    tool->LastActiveFrame = g.FrameCount;
 | 
			
		||||
    if (tool->Results.Size > 0 && BeginTable("##table", 3, ImGuiTableFlags_Borders))
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								imgui.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								imgui.h
									
									
									
									
									
								
							@@ -2600,10 +2600,11 @@ struct ImGuiTextBuffer
 | 
			
		||||
    ImGuiTextBuffer()   { }
 | 
			
		||||
    inline char         operator[](int i) const { IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; }
 | 
			
		||||
    const char*         begin() const           { return Buf.Data ? &Buf.front() : EmptyString; }
 | 
			
		||||
    const char*         end() const             { return Buf.Data ? &Buf.back() : EmptyString; }   // Buf is zero-terminated, so end() will point on the zero-terminator
 | 
			
		||||
    const char*         end() const             { return Buf.Data ? &Buf.back() : EmptyString; } // Buf is zero-terminated, so end() will point on the zero-terminator
 | 
			
		||||
    int                 size() const            { return Buf.Size ? Buf.Size - 1 : 0; }
 | 
			
		||||
    bool                empty() const           { return Buf.Size <= 1; }
 | 
			
		||||
    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); }
 | 
			
		||||
    const char*         c_str() const           { return Buf.Data ? Buf.Data : EmptyString; }
 | 
			
		||||
    IMGUI_API void      append(const char* str, const char* str_end = NULL);
 | 
			
		||||
 
 | 
			
		||||
@@ -2030,6 +2030,7 @@ struct ImGuiIDStackTool
 | 
			
		||||
    ImVector<ImGuiStackLevelInfo> Results;
 | 
			
		||||
    bool                    CopyToClipboardOnCtrlC;
 | 
			
		||||
    float                   CopyToClipboardLastTime;
 | 
			
		||||
    ImGuiTextBuffer         ResultPathBuf;
 | 
			
		||||
 | 
			
		||||
    ImGuiIDStackTool()      { memset(this, 0, sizeof(*this)); CopyToClipboardLastTime = -FLT_MAX; }
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user