@ -6195,7 +6195,8 @@ bool ImGui::TreeNode(const char* label)
ImGuiWindow * window = GetCurrentWindow ( ) ;
if ( window - > SkipItems )
return false ;
return TreeNodeBehavior ( window - > GetID ( label ) , 0 , label , NULL ) ;
ImGuiID id = window - > GetID ( label ) ;
return TreeNodeBehavior ( id , id , ImGuiTreeNodeFlags_None , label , NULL ) ;
}
bool ImGui : : TreeNodeV ( const char * str_id , const char * fmt , va_list args )
@ -6213,8 +6214,8 @@ bool ImGui::TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags)
ImGuiWindow * window = GetCurrentWindow ( ) ;
if ( window - > SkipItems )
return false ;
return TreeNodeBehavior ( window - > GetID ( label ) , flags , label , NULL ) ;
ImGuiID id = window - > GetID ( label ) ;
return TreeNodeBehavior ( id , id , flags , label , NULL ) ;
}
bool ImGui : : TreeNodeEx ( const char * str_id , ImGuiTreeNodeFlags flags , const char * fmt , . . . )
@ -6241,9 +6242,10 @@ bool ImGui::TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char
if ( window - > SkipItems )
return false ;
ImGuiID id = window - > GetID ( str_id ) ;
const char * label , * label_end ;
ImFormatStringToTempBufferV ( & label , & label_end , fmt , args ) ;
return TreeNodeBehavior ( window - > GetID ( str_id ) , flags , label , label_end ) ;
return TreeNodeBehavior ( id , id , flags , label , label_end ) ;
}
bool ImGui : : TreeNodeExV ( const void * ptr_id , ImGuiTreeNodeFlags flags , const char * fmt , va_list args )
@ -6252,26 +6254,27 @@ bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char
if ( window - > SkipItems )
return false ;
ImGuiID id = window - > GetID ( ptr_id ) ;
const char * label , * label_end ;
ImFormatStringToTempBufferV ( & label , & label_end , fmt , args ) ;
return TreeNodeBehavior ( window - > GetID ( ptr_id ) , flags , label , label_end ) ;
return TreeNodeBehavior ( id , id , flags , label , label_end ) ;
}
bool ImGui : : TreeNodeIsOpen ( ImGuiID id )
bool ImGui : : TreeNodeIsOpen ( ImGuiID storage_ id)
{
ImGuiContext & g = * GImGui ;
ImGuiStorage * storage = g . CurrentWindow - > DC . StateStorage ;
return storage - > GetInt ( id , 0 ) ! = 0 ;
return storage - > GetInt ( storage_ id, 0 ) ! = 0 ;
}
void ImGui : : TreeNodeSetOpen ( ImGuiID id , bool open )
void ImGui : : TreeNodeSetOpen ( ImGuiID storage_ id, bool open )
{
ImGuiContext & g = * GImGui ;
ImGuiStorage * storage = g . CurrentWindow - > DC . StateStorage ;
storage - > SetInt ( id , open ? 1 : 0 ) ;
storage - > SetInt ( storage_ id, open ? 1 : 0 ) ;
}
bool ImGui : : TreeNodeUpdateNextOpen ( ImGuiID id , ImGuiTreeNodeFlags flags )
bool ImGui : : TreeNodeUpdateNextOpen ( ImGuiID storage_ id, ImGuiTreeNodeFlags flags )
{
if ( flags & ImGuiTreeNodeFlags_Leaf )
return true ;
@ -6287,16 +6290,16 @@ bool ImGui::TreeNodeUpdateNextOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
if ( g . NextItemData . OpenCond & ImGuiCond_Always )
{
is_open = g . NextItemData . OpenVal ;
TreeNodeSetOpen ( id , is_open ) ;
TreeNodeSetOpen ( storage_ id, is_open ) ;
}
else
{
// We treat ImGuiCond_Once and ImGuiCond_FirstUseEver the same because tree node state are not saved persistently.
const int stored_value = storage - > GetInt ( id , - 1 ) ;
const int stored_value = storage - > GetInt ( storage_ id, - 1 ) ;
if ( stored_value = = - 1 )
{
is_open = g . NextItemData . OpenVal ;
TreeNodeSetOpen ( id , is_open ) ;
TreeNodeSetOpen ( storage_ id, is_open ) ;
}
else
{
@ -6306,7 +6309,7 @@ bool ImGui::TreeNodeUpdateNextOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
}
else
{
is_open = storage - > GetInt ( id , ( flags & ImGuiTreeNodeFlags_DefaultOpen ) ? 1 : 0 ) ! = 0 ;
is_open = storage - > GetInt ( storage_ id, ( flags & ImGuiTreeNodeFlags_DefaultOpen ) ? 1 : 0 ) ! = 0 ;
}
// When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior).
@ -6333,7 +6336,8 @@ static void TreeNodeStoreStackData(ImGuiTreeNodeFlags flags)
window - > DC . TreeHasStackDataDepthMask | = ( 1 < < window - > DC . TreeDepth ) ;
}
bool ImGui : : TreeNodeBehavior ( ImGuiID id , ImGuiTreeNodeFlags flags , const char * label , const char * label_end )
// When using public API, currently 'id == storage_id' is always true, but we separate the values to facilitate advanced user code doing storage queries outside of UI loop.
bool ImGui : : TreeNodeBehavior ( ImGuiID id , ImGuiID storage_id , ImGuiTreeNodeFlags flags , const char * label , const char * label_end )
{
ImGuiWindow * window = GetCurrentWindow ( ) ;
if ( window - > SkipItems )
@ -6386,7 +6390,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
}
// Compute open and multi-select states before ItemAdd() as it clear NextItem data.
bool is_open = TreeNodeUpdateNextOpen ( id , flags ) ;
bool is_open = TreeNodeUpdateNextOpen ( storage_ id, flags ) ;
bool item_add = ItemAdd ( interact_bb , id ) ;
g . LastItemData . StatusFlags | = ImGuiItemStatusFlags_HasDisplayRect ;
g . LastItemData . DisplayRect = frame_bb ;
@ -6498,7 +6502,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
if ( toggled )
{
is_open = ! is_open ;
window - > DC . StateStorage - > SetInt ( id , is_open ) ;
window - > DC . StateStorage - > SetInt ( storage_ id, is_open ) ;
g . LastItemData . StatusFlags | = ImGuiItemStatusFlags_ToggledOpen ;
}
}
@ -6639,8 +6643,8 @@ bool ImGui::CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags)
ImGuiWindow * window = GetCurrentWindow ( ) ;
if ( window - > SkipItems )
return false ;
return TreeNodeBehavior ( window - > GetID ( label ) , flags | ImGuiTreeNodeFlags_CollapsingHeader , label ) ;
ImGuiID id = window - > GetID ( label ) ;
return TreeNodeBehavior ( id , id , flags | ImGuiTreeNodeFlags_CollapsingHeader , label ) ;
}
// p_visible == NULL : regular collapsing header
@ -6660,7 +6664,7 @@ bool ImGui::CollapsingHeader(const char* label, bool* p_visible, ImGuiTreeNodeFl
flags | = ImGuiTreeNodeFlags_CollapsingHeader ;
if ( p_visible )
flags | = ImGuiTreeNodeFlags_AllowOverlap | ( ImGuiTreeNodeFlags ) ImGuiTreeNodeFlags_ClipLabelForTrailingButton ;
bool is_open = TreeNodeBehavior ( id , flags , label ) ;
bool is_open = TreeNodeBehavior ( id , id , flags , label ) ;
if ( p_visible ! = NULL )
{
// Create a small overlapping close button