MCPcopy Create free account
hub / github.com/GPUOpen-LibrariesAndSDKs/Cauldron / TreeNodeBehaviorIsOpen

Method TreeNodeBehaviorIsOpen

libs/imgui/imgui.cpp:6611–6656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6609}
6610
6611bool 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
6658bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end)
6659{

Callers

nothing calls this directly

Calls 2

SetIntMethod · 0.80
GetIntMethod · 0.80

Tested by

no test coverage detected