diff --git a/imgui.cpp b/imgui.cpp index a7d03caa4301..166c370a2133 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -17384,7 +17384,20 @@ void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, con { if (pcmd->UserCallback) { - BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); + if (g.IO.DebugDrawCmdCallback) + { + char buf[300]; + g.IO.DebugDrawCmdCallback(NULL, draw_list, pcmd, false, false, buf, IM_ARRAYSIZE(buf)); + bool cb_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "Callback: %s", buf); + if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list) + g.IO.DebugDrawCmdCallback(fg_draw_list, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes, NULL, 0); + if (cb_node_open) + TreePop(); + } + else + { + BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); + } continue; } diff --git a/imgui.h b/imgui.h index 0d4995699f9b..9ae47c9bc6ee 100644 --- a/imgui.h +++ b/imgui.h @@ -287,6 +287,7 @@ typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData* data); typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data); // Callback function for ImGui::SetNextWindowSizeConstraints() typedef void* (*ImGuiMemAllocFunc)(size_t sz, void* user_data); // Function signature for ImGui::SetAllocatorFunctions() typedef void (*ImGuiMemFreeFunc)(void* ptr, void* user_data); // Function signature for ImGui::SetAllocatorFunctions() +typedef void (*ImGuiDebugDrawCmdCallbackFn)(ImDrawList* overlay_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb, char* out_text, int text_size); // Debug callback for custom draw commands // ImVec2: 2D vector used to store positions, sizes etc. [Compile-time configurable type] // - This is a frequently used type in the API. Consider using IM_VEC2_CLASS_EXTRA to create implicit cast from/to our preferred type. @@ -2510,6 +2511,11 @@ struct ImGuiIO // Option to audit .ini data bool ConfigDebugIniSettings; // = false // Save .ini data with extra comments (particularly helpful for Docking, but makes saving slower) + // Debug callback for custom draw commands (callbacks) in the Metrics/Debugger draw list viewer. + // When set, callback draw commands will show a tree node with descriptive text and mesh/bbox overlay on hover, + // instead of just "Callback %p, user_data %p". See ImGuiDebugDrawCmdCallbackFn typedef for parameters. + ImGuiDebugDrawCmdCallbackFn DebugDrawCmdCallback; // = NULL + //------------------------------------------------------------------ // Platform Identifiers // (the imgui_impl_xxxx backend files are setting those up for you)