Skip to content

Commit

Permalink
Added GetTreeNodeToLabelSpacing() helper - tentative name (#581, #324)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocornut committed May 1, 2016
1 parent b93040e commit 13df466
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 13df466

Please sign in to comment.