Added GetTreeNodeToLabelSpacing() helper - tentative name (#581, #324)

This commit is contained in:
ocornut 2016-05-01 23:47:58 +02:00
parent b93040e600
commit 13df4668d1
2 changed files with 12 additions and 0 deletions

View File

@ -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;

View File

@ -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