mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-01 05:10:41 +00:00
Icons in the tree #282
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#282
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?
Hi,
I wonder if it is currently possible to have custom icons in the tree view? (that would be infront of the text and for the folded/unfolded state)
Think of something like an explorer view/Visual Studio Workspace of files view
There's a few way you can do that but the correct one will have to wait until I make a change to TreeNode - I started it but shelved it.
Currently if you do
TreeNode("##hiddenlabel", ...); SameLine(0, 0);you can already add stuff.There's will several issues:
So what we need to do is:
You can temporarily hack around your way from those problems by passing a tree node label full of spaces to get a larger hit box, and moving the cursor
SetCursorPosX(GetCursorPosX() - 20.0f)after SameLine.Thanks for the reply.
I will go for your temporary hack for now.
If you use spaces for id remember to do a prior PushId/PopId to make the full-id unique.
Will do. Thanks!
Did you mean you wanted to remove the ">" thingie and draw an icon instead?
Btw you can rewrite a pretty much feature-identical custom tree node this way.
The main problem with that approach is that it is probably 10+ times slower than the version that pokes at data structure directly. (haven't measure, just guessed). Because of going through those public apis. Using imgui_internal.h would be beneficial.
(gifcam is creating undesired transparent color in the GIF, the color square should be green when it's not red)

And that's the exact same feature but using some internal data structure.
Perhaps I can turn part of this, or actually the underlying behavior which does a little more, into a TreeNodeBehavior().
Made some change so you can write a custom tree node that is more accurate in term of honoring Auto-Expand-Node-On-Logging and SetNextTreeNode** calls.
Until I add a mechanism to parametrize how far the hit-rectangle of a treenode.should reach, this is probably the best way to just make something fully custom, Not particularly great looking but it's not the type of code you would often look back at.
Neat :) Thanks!
Closing this afaik the original post is answered. Ideally we'd simplify the code for MyTreeNode() further and improve forward compatibility, but it's not too bad now.
(EDIT adding midly related attachment after the fact so I can link to it from another forum)
