Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down