TreeNodeGetOpen(): added flags parameter. (#9569, #9592, #3823, #9251)

This commit is contained in:
Yaki Blake 2026-10-27 15:20:31 +01:00 committed by ocornut
parent 048d7e10b5
commit 2f1552d4d5
3 changed files with 10 additions and 5 deletions

View File

@ -71,6 +71,9 @@ Other Changes:
the shape and look of arrows. Made default arrow stroked. (#5233, #2431, #2235, #6730, #8243)
Legacy arrow: size: (0.60f,0.70f), thickness: 0.0f
New arrow: size: (0.72f,0.40f), thickness: 0.30f
- TreeNode:
- TreeNodeGetOpen(): added flags parameter to allow passing `ImGuiTreeNodeFlags_DefaultOpen`
or `ImGuiTreeNodeFlags_Leaf`. (#9569, #9592, #3823, #9251) [@adalisk-emikhaylov, @Yaki-Blake]
- ImVec2: added a check for cases where a custom `IM_VEC2_CLASS_EXTRA` macro
adds an extra `operator=` to ImVec2. This isn't supported but should not
be needed as you should have a constructor to convert from your type to ImVec2.

View File

@ -769,7 +769,7 @@ namespace ImGui
IMGUI_API bool CollapsingHeader(const char* label, bool* p_visible, ImGuiTreeNodeFlags flags = 0); // when 'p_visible != NULL': if '*p_visible==true' display an additional small close button on upper right of the header which will set the bool to false when clicked, if '*p_visible==false' don't display the header.
IMGUI_API void SetNextItemOpen(bool is_open, ImGuiCond cond = 0); // set next TreeNode/CollapsingHeader open state.
IMGUI_API void SetNextItemStorageID(ImGuiID storage_id); // set id to use for open/close storage (default to same as item id).
IMGUI_API bool TreeNodeGetOpen(ImGuiID storage_id); // retrieve tree node open/close state.
IMGUI_API bool TreeNodeGetOpen(ImGuiID storage_id, ImGuiTreeNodeFlags flags = 0); // retrieve tree node open/close state.
// Widgets: Selectables
// - A selectable highlights when hovered, and can display another color when selected.

View File

@ -6931,13 +6931,15 @@ bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char
return TreeNodeBehavior(id, flags, label, label_end);
}
// The reason those two functions are not yet in public API is because I would like to design a more feature-full and generic API for this.
// They are otherwise function (cc: #3823, #9251, #7553, #6754, #5423, #2958, #2079, #1947, #1131, #722)
bool ImGui::TreeNodeGetOpen(ImGuiID storage_id)
// I would like to design a more feature-full and generic API for this.
// (cc: #3823, #9251, #7553, #6754, #5423, #2958, #2079, #1947, #1131, #722, #9569)
bool ImGui::TreeNodeGetOpen(ImGuiID storage_id, ImGuiTreeNodeFlags flags)
{
if (flags & ImGuiTreeNodeFlags_Leaf)
return true;
ImGuiContext& g = *GImGui;
ImGuiStorage* storage = g.CurrentWindow->DC.StateStorage;
return storage->GetInt(storage_id, 0) != 0;
return storage->GetInt(storage_id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0;
}
void ImGui::TreeNodeSetOpen(ImGuiID storage_id, bool is_open)