| 6609 | } |
| 6610 | |
| 6611 | bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags) |
| 6612 | { |
| 6613 | if (flags & ImGuiTreeNodeFlags_Leaf) |
| 6614 | return true; |
| 6615 | |
| 6616 | // We only write to the tree storage if the user clicks (or explicitely use SetNextTreeNode*** functions) |
| 6617 | ImGuiContext& g = *GImGui; |
| 6618 | ImGuiWindow* window = g.CurrentWindow; |
| 6619 | ImGuiStorage* storage = window->DC.StateStorage; |
| 6620 | |
| 6621 | bool is_open; |
| 6622 | if (g.SetNextTreeNodeOpenCond != 0) |
| 6623 | { |
| 6624 | if (g.SetNextTreeNodeOpenCond & ImGuiCond_Always) |
| 6625 | { |
| 6626 | is_open = g.SetNextTreeNodeOpenVal; |
| 6627 | storage->SetInt(id, is_open); |
| 6628 | } |
| 6629 | else |
| 6630 | { |
| 6631 | // We treat ImGuiCond_Once and ImGuiCond_FirstUseEver the same because tree node state are not saved persistently. |
| 6632 | const int stored_value = storage->GetInt(id, -1); |
| 6633 | if (stored_value == -1) |
| 6634 | { |
| 6635 | is_open = g.SetNextTreeNodeOpenVal; |
| 6636 | storage->SetInt(id, is_open); |
| 6637 | } |
| 6638 | else |
| 6639 | { |
| 6640 | is_open = stored_value != 0; |
| 6641 | } |
| 6642 | } |
| 6643 | g.SetNextTreeNodeOpenCond = 0; |
| 6644 | } |
| 6645 | else |
| 6646 | { |
| 6647 | is_open = storage->GetInt(id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0; |
| 6648 | } |
| 6649 | |
| 6650 | // When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior). |
| 6651 | // NB- If we are above max depth we still allow manually opened nodes to be logged. |
| 6652 | if (g.LogEnabled && !(flags & ImGuiTreeNodeFlags_NoAutoOpenOnLog) && window->DC.TreeDepth < g.LogAutoExpandMaxDepth) |
| 6653 | is_open = true; |
| 6654 | |
| 6655 | return is_open; |
| 6656 | } |
| 6657 | |
| 6658 | bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end) |
| 6659 | { |