MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / TreeNodeBehaviorIsOpen

Method TreeNodeBehaviorIsOpen

lib/imgui/imgui_widgets.cpp:5253–5297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5251}
5252
5253bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
5254{
5255 if (flags & ImGuiTreeNodeFlags_Leaf)
5256 return true;
5257
5258 // We only write to the tree storage if the user clicks (or explicitly use the SetNextItemOpen function)
5259 ImGuiContext& g = *GImGui;
5260 ImGuiWindow* window = g.CurrentWindow;
5261 ImGuiStorage* storage = window->DC.StateStorage;
5262
5263 bool is_open;
5264 if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasOpen)
5265 {
5266 if (g.NextItemData.OpenCond & ImGuiCond_Always)
5267 {
5268 is_open = g.NextItemData.OpenVal;
5269 storage->SetInt(id, is_open);
5270 }
5271 else
5272 {
5273 // We treat ImGuiCond_Once and ImGuiCond_FirstUseEver the same because tree node state are not saved persistently.
5274 const int stored_value = storage->GetInt(id, -1);
5275 if (stored_value == -1)
5276 {
5277 is_open = g.NextItemData.OpenVal;
5278 storage->SetInt(id, is_open);
5279 }
5280 else
5281 {
5282 is_open = stored_value != 0;
5283 }
5284 }
5285 }
5286 else
5287 {
5288 is_open = storage->GetInt(id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0;
5289 }
5290
5291 // When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior).
5292 // NB- If we are above max depth we still allow manually opened nodes to be logged.
5293 if (g.LogEnabled && !(flags & ImGuiTreeNodeFlags_NoAutoOpenOnLog) && (window->DC.TreeDepth - g.LogDepthRef) < g.LogDepthToExpand)
5294 is_open = true;
5295
5296 return is_open;
5297}
5298
5299bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end)
5300{

Callers

nothing calls this directly

Calls 2

SetIntMethod · 0.80
GetIntMethod · 0.80

Tested by

no test coverage detected