diff --git a/imgui.cpp b/imgui.cpp index b4fa6c0d..b1ffa3e3 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5871,6 +5871,17 @@ bool ImGui::TreeNode(const char* label) return TreeNodeBehavior(window->GetID(label), 0, label, NULL); } +float ImGui::GetTreeNodeToLabelSpacing(ImGuiTreeNodeFlags flags) +{ + ImGuiState& g = *GImGui; + float off_from_start; + if (flags & ImGuiTreeNodeFlags_Framed) + off_from_start = g.FontSize + (g.Style.FramePadding.x * 3.0f) - ((float)(int)(g.CurrentWindow->WindowPadding.x*0.5f) - 1); + else + off_from_start = g.FontSize + (g.Style.FramePadding.x * 2.0f); + return off_from_start; +} + void ImGui::SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond) { ImGuiState& g = *GImGui; diff --git a/imgui.h b/imgui.h index dd3c9fbf..0b76157b 100644 --- a/imgui.h +++ b/imgui.h @@ -321,6 +321,7 @@ namespace ImGui IMGUI_API void TreePush(const void* ptr_id = NULL); // " IMGUI_API void TreePop(); IMGUI_API void SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond = 0); // set next tree node/collapsing header to be opened. + IMGUI_API float GetTreeNodeToLabelSpacing(ImGuiTreeNodeFlags flags = 0); // return horizontal distance between cursor and text label due to collapsing node. == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode IMGUI_API bool CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags = 0); // if returning 'true' the header is open. user doesn't have to call TreePop(). IMGUI_API bool CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags = 0); // when 'p_open' isn't NULL, display an additional small close button on upper right of the header