MCPcopy Create free account
hub / github.com/AlexandreRouma/SDRPlusPlus / TreeNodeBehaviorIsOpen

Method TreeNodeBehaviorIsOpen

core/src/imgui/imgui_widgets.cpp:5658–5702  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5656}
5657
5658bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
5659{
5660 if (flags & ImGuiTreeNodeFlags_Leaf)
5661 return true;
5662
5663 // We only write to the tree storage if the user clicks (or explicitly use the SetNextItemOpen function)
5664 ImGuiContext& g = *GImGui;
5665 ImGuiWindow* window = g.CurrentWindow;
5666 ImGuiStorage* storage = window->DC.StateStorage;
5667
5668 bool is_open;
5669 if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasOpen)
5670 {
5671 if (g.NextItemData.OpenCond & ImGuiCond_Always)
5672 {
5673 is_open = g.NextItemData.OpenVal;
5674 storage->SetInt(id, is_open);
5675 }
5676 else
5677 {
5678 // We treat ImGuiCond_Once and ImGuiCond_FirstUseEver the same because tree node state are not saved persistently.
5679 const int stored_value = storage->GetInt(id, -1);
5680 if (stored_value == -1)
5681 {
5682 is_open = g.NextItemData.OpenVal;
5683 storage->SetInt(id, is_open);
5684 }
5685 else
5686 {
5687 is_open = stored_value != 0;
5688 }
5689 }
5690 }
5691 else
5692 {
5693 is_open = storage->GetInt(id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0;
5694 }
5695
5696 // When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior).
5697 // NB- If we are above max depth we still allow manually opened nodes to be logged.
5698 if (g.LogEnabled && !(flags & ImGuiTreeNodeFlags_NoAutoOpenOnLog) && (window->DC.TreeDepth - g.LogDepthRef) < g.LogDepthToExpand)
5699 is_open = true;
5700
5701 return is_open;
5702}
5703
5704bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end)
5705{

Callers

nothing calls this directly

Calls 2

SetIntMethod · 0.80
GetIntMethod · 0.80

Tested by

no test coverage detected