MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / TreeNodeBehaviorIsOpen

Method TreeNodeBehaviorIsOpen

plugins/Cardinal/src/DearImGui/imgui_widgets.cpp:5828–5872  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5826}
5827
5828bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
5829{
5830 if (flags & ImGuiTreeNodeFlags_Leaf)
5831 return true;
5832
5833 // We only write to the tree storage if the user clicks (or explicitly use the SetNextItemOpen function)
5834 ImGuiContext& g = *GImGui;
5835 ImGuiWindow* window = g.CurrentWindow;
5836 ImGuiStorage* storage = window->DC.StateStorage;
5837
5838 bool is_open;
5839 if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasOpen)
5840 {
5841 if (g.NextItemData.OpenCond & ImGuiCond_Always)
5842 {
5843 is_open = g.NextItemData.OpenVal;
5844 storage->SetInt(id, is_open);
5845 }
5846 else
5847 {
5848 // We treat ImGuiCond_Once and ImGuiCond_FirstUseEver the same because tree node state are not saved persistently.
5849 const int stored_value = storage->GetInt(id, -1);
5850 if (stored_value == -1)
5851 {
5852 is_open = g.NextItemData.OpenVal;
5853 storage->SetInt(id, is_open);
5854 }
5855 else
5856 {
5857 is_open = stored_value != 0;
5858 }
5859 }
5860 }
5861 else
5862 {
5863 is_open = storage->GetInt(id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0;
5864 }
5865
5866 // When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior).
5867 // NB- If we are above max depth we still allow manually opened nodes to be logged.
5868 if (g.LogEnabled && !(flags & ImGuiTreeNodeFlags_NoAutoOpenOnLog) && (window->DC.TreeDepth - g.LogDepthRef) < g.LogDepthToExpand)
5869 is_open = true;
5870
5871 return is_open;
5872}
5873
5874bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end)
5875{

Callers

nothing calls this directly

Calls 2

SetIntMethod · 0.80
GetIntMethod · 0.80

Tested by

no test coverage detected