mirror of
https://github.com/ocornut/imgui.git
synced 2026-10-29 07:54:40 +00:00
ImGui::TreeNodeGetOpen() doesn't handle default-open nodes correctly, reports false until they're interacted with #9569
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#9569
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version/Branch of Dear ImGui:
Version 1.92.0, Branch: docking (
adfa5364c)Back-ends:
imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler, OS:
Linux + GCC
Full config/build information:
Details:
My Issue/Question:
We're using
ImGui::TreeNodeGetOpen()to check open-ness of tree nodes, but our nodes have flagImGuiTreeNodeFlags_DefaultOpenset.When this flag is present,
TreeNodeGetOpenincorrectly reports false for those nodes until they're interacted with for the first time. After the first click, the value becomes correct (remains false after the first click, then toggles on each click).We're able to work around this by accessing
StateStoragedirectly and when this node is missing from it, treat it as open.One way to fix this is to give
TreeNodeGetOpena parameter for the default value, like, bool default_open = falsethat it returns if the node wasn't interacted with yet.Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
Notice how it initially says
A: falseB: false, even though B is actually open. After you click on it at least once,B:becomes correct.I was not sure what was the proper design and solution for this.
This is the evident answer but I didn't like this solution much, and wondered if
_ImGuiTreeNodeFlags_DefaultOpenshouldn't simply store the state.I was not sure what was the proper design and solution for this.
This is the evident answer but I didn't like this solution much, and wondered if
_ImGuiTreeNodeFlags_DefaultOpenshouldn't simply store the state.I was not sure what was the proper design and solution for this.
This is the evident answer but I didn't like this solution much, and wondered if
_ImGuiTreeNodeFlags_DefaultOpenshouldn't simply store the state.You mean
DefaultOpenwould write to the state as soon as it appears? I think I like the parameter more, because it would give the correct result for the first frame if called before the tree node.You mean
DefaultOpenwould write to the state as soon as it appears? I think I like the parameter more, because it would give the correct result for the first frame if called before the tree node.You mean
DefaultOpenwould write to the state as soon as it appears? I think I like the parameter more, because it would give the correct result for the first frame if called before the tree node.As a side note, would you be kind to explain how/you are using this data?
I was hesitant to provide this API as-is (vs a more generic API) and interested to hear about your usage.
As a side note, would you be kind to explain how/you are using this data?
I was hesitant to provide this API as-is (vs a more generic API) and interested to hear about your usage.
As a side note, would you be kind to explain how/you are using this data?
I was hesitant to provide this API as-is (vs a more generic API) and interested to hear about your usage.
We draw a scene tree view, and each node is selectable. There's a hotkey to select all visible nodes (visible = none of the parents are closed), or visible nodes in a certain range (clicking one, then shift-clicking another, like in file managers). Not the most intuitive behavior that hidden nodes are skipped, but I didn't write this code. 🙂
So when that hotkey is pressed, we loop over all nodes (which is separate from drawing them), and check their parents with
ImGui::TreeNodeGetOpen()(or with direct state access now).I guess we could merge the selection logic with drawing and do it all in one pass...
We draw a scene tree view, and each node is selectable. There's a hotkey to select all visible nodes (visible = none of the parents are closed), or visible nodes in a certain range (clicking one, then shift-clicking another, like in file managers). Not the most intuitive behavior that hidden nodes are skipped, but I didn't write this code. 🙂
So when that hotkey is pressed, we loop over all nodes (which is separate from drawing them), and check their parents with
ImGui::TreeNodeGetOpen()(or with direct state access now).I guess we could merge the selection logic with drawing and do it all in one pass...
I'm hesitant between:
bool TreeNodeGetOpen(ImGuiID storage_id, bool default_open = true);and
bool TreeNodeGetOpen(ImGuiID storage_id, ImGuiTreeNodeFlags flags = 0);bool:
trueflags:
I'm hesitant between:
bool TreeNodeGetOpen(ImGuiID storage_id, bool default_open = true);and
bool TreeNodeGetOpen(ImGuiID storage_id, ImGuiTreeNodeFlags flags = 0);bool:
trueflags:
Wouldn't it be
bool default_open = falseto match the default lack ofImGuiTreeNodeFlags_DefaultOpen?I think I like the flags version a bit more, but both are ok.