Skip to main content

Tree Nodes

TreeNode functions return true when the node is open, in which case you need to also call TreePop() when you are finished displaying the tree node contents.

TreeNode

Simple tree node.
const char*
Node label (also used as ID)
bool
True when node is open

TreeNode (with format)

Helper variation to easily decorrelate the ID from the displayed string.
const char*
String identifier (not displayed)
const void*
Pointer identifier (not displayed)
const char*
Format string (printf-style)
bool
True when node is open

TreeNodeEx

Tree node with flags.
const char*
Node label
ImGuiTreeNodeFlags
default:"0"
Tree node flags (see ImGuiTreeNodeFlags_)
bool
True when node is open

TreePush / TreePop

TreePush() = Indent() + PushID(). Already called by TreeNode() when returning true, but you can call TreePush/TreePop yourself if desired.
const char*
String identifier
const void*
Pointer identifier

GetTreeNodeToLabelSpacing

Horizontal distance preceding label when using TreeNode*() or Bullet() == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode.
float
Spacing in pixels

Collapsing Headers

CollapsingHeader

If returning true the header is open. Doesn’t indent nor push on ID stack. User doesn’t have to call TreePop().
const char*
Header label
ImGuiTreeNodeFlags
default:"0"
Tree node flags
bool
True when header is open

CollapsingHeader (with close button)

When p_visible != NULL: if *p_visible==true display an additional small close button on upper right of the header which will set the bool to false when clicked. If *p_visible==false don’t display the header.
const char*
Header label
bool*
Pointer to visibility boolean
ImGuiTreeNodeFlags
default:"0"
Tree node flags
bool
True when header is open

Tree Control

SetNextItemOpen

Set next TreeNode/CollapsingHeader open state.
bool
Open state
ImGuiCond
default:"0"
Condition for setting (see ImGuiCond_)

SetNextItemStorageID

Set ID to use for open/close storage (default to same as item ID).
ImGuiID
Storage identifier

TreeNodeGetOpen

Retrieve tree node open/close state.
ImGuiID
Storage identifier
bool
True if node is open

Tree Node Flags

ImGuiTreeNodeFlags_

Flags for TreeNodeEx(), CollapsingHeader().

Display Options

Width Options

Tree Lines