Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImGuiTreeNodeFlags: Framed flag makes Leaf/Bullet flags become ignored (unnecessarily) #2159

Closed
goran-w opened this issue Oct 30, 2018 · 8 comments
Labels
tree tree nodes

Comments

@goran-w
Copy link
Contributor

goran-w commented Oct 30, 2018

Version/Branch of Dear ImGui:

1.65

Back-end file/Renderer/OS:

Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
OS: Windows 10
Compiler: Visual Studio 2017 (if the question is related to building)

My Issue/Question:

Hi! I'd like to be able to render a CollapsingHeader() without an arrow or with a bullet (for use as a plain separator etc). I tried calling TreeNodeEx() and passing ImGuiTreeNodeFlags of CollapsingHeader and Leaf/Bullet, but the latter flag was ignored.

I looked at the code for ImGui::TreeNodeBehavior() and found that in the "if (display_frame)" path, RenderArrow() is called without looking at flags ImGuiTreeNodeFlags_Bullet and ImGuiTreeNodeFlags_Leaf, while the "else" path handles these as expected.

Do you think this could be changed? There doesn't seem to be many other differences between the framed and unframed cases...

Standalone, minimal, complete and verifiable example:

Screenshots/Video

@ocornut ocornut added the tree tree nodes label Oct 30, 2018
@ocornut
Copy link
Owner

ocornut commented Oct 30, 2018

Do you think this could be changed? There doesn't seem to be many other differences between the framed and unframed cases...

Yes. It's a little bit of a faff but if you can make a nice PR for it I would merge that.

@goran-w
Copy link
Contributor Author

goran-w commented Oct 30, 2018

Thanks! I'll look into that, then. It would be a minimal change, but I'll have to try it out first.
/Göran

@goran-w
Copy link
Contributor Author

goran-w commented Oct 30, 2018

I made some tests, to see how it would look. The only change is in the Leaf and/or Bullet headers in the screenshot below. It's straight forward and matches what's already there for tree nodes, except for the "Leaf header" where I left-adjusted the text to match any unindented Text sub-/sibling items.

image

(BTW, I noted that Leaf implies that the tree node or header is always open, so any (logically) nested sub-items are always visible. Convenient!)

@goran-w
Copy link
Contributor Author

goran-w commented Oct 30, 2018

To apply the Bullet/Leaf flags I used TreeNodeEx(), since CollapsingHeader() does not accept flags.

Left-adjusting the text for (non-Bullet) Leaf headers (as in my screenshot) means we are a bit less consistent with normal (non-Framed) tree nodes, but I think it looks better in the Framed context and it also aligns better with NoTreePushOnOpen (which is the default for CollapsingHeader).

@goran-w
Copy link
Contributor Author

goran-w commented Oct 30, 2018

Alright, I made a pull request: #2160
(Please bear with me, I'm new to GitHub... ;)

@ocornut
Copy link
Owner

ocornut commented Oct 30, 2018

Thank you Goran!
I’ll be unavailable for a few days so please bear with me if I can’t react about this so soon. Will try next week!

@goran-w
Copy link
Contributor Author

goran-w commented Oct 30, 2018

As a bonus, we can now do this:

image

(I'm using Font Awesome in a Leaf header TreeNodeEx() here... ;)

ocornut pushed a commit that referenced this issue Sep 24, 2019
…uiTreeNodeFlags_Leaf on framed nodes. (#2159, #2160)

The Bullet and Leaf ImGuiTreeNodeFlags are now taken into account for Framed/CollapsingHeader tree nodes as well. TreeNodeEx() can be used to specify these flags. A choice was made to left-adjust the Framed text when no Bullet/Arrow is rendered, since this was deemed to look better in the Framed context (especially when considering that CollapsingHeader is drawn using NoTreePushOnOpen, so child/sibling Text items etc will often be non-indented).
@ocornut
Copy link
Owner

ocornut commented Sep 24, 2019

Merged now, sorry for the late reaction!

@ocornut ocornut closed this as completed Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tree tree nodes
Projects
None yet
Development

No branches or pull requests

2 participants