Skip to content

Add sticky tree item support - #115697

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
dugramen:sticky-tree-canvas-item
Jun 19, 2026
Merged

Add sticky tree item support#115697
Repiteo merged 1 commit into
godotengine:masterfrom
dugramen:sticky-tree-canvas-item

Conversation

@dugramen

@dugramen dugramen commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

addresses godotengine/godot-proposals#13998 for Trees

Video demo:

2026-01-31.20-06-23.mp4

@dugramen
dugramen requested a review from a team as a code owner February 1, 2026 01:56
@dugramen
dugramen requested a review from a team February 1, 2026 01:56
@dugramen
dugramen requested a review from a team as a code owner February 1, 2026 01:56
@llama-nl

llama-nl commented Feb 1, 2026

Copy link
Copy Markdown

tested it on Android, I am having a problem when use multiple nested node:

az_recorder_20260201_082540_edited.mp4

@dugramen

dugramen commented Feb 1, 2026

Copy link
Copy Markdown
Contributor Author

Ah right. It currently sticks at an unlimited depth. Maybe I can just hard cap it to the last few elements. Or maybe up to like half of the full height

Edit: looks like it's not horizontally scrolling either. I'll have to fix that

@AdriaandeJongh

Copy link
Copy Markdown
Contributor

if you cap the depth and that depth is reached, will from that point on the sticky headers also scroll again as if normal? because if they remain sticky, that might be very confusing…

@dugramen

dugramen commented Feb 1, 2026

Copy link
Copy Markdown
Contributor Author

I think they could show another scroll hint shadow at the top, to indicate there's more sticky elements. Or maybe have like a ... item at the top?

Edit: nvm I realize the issue with capping to the last elements. It would make items jump to the top. It's probably better to cap to the first few elements instead

@dugramen
dugramen force-pushed the sticky-tree-canvas-item branch from f68a535 to d818429 Compare February 1, 2026 15:26
@dugramen

dugramen commented Feb 1, 2026

Copy link
Copy Markdown
Contributor Author

Ok I changed the setting to enable sticky items to an int, providing the maximum number of sticky elements. Horizontal scrolling should also work now.

2026-02-01.10-20-54.mp4

@dugramen
dugramen force-pushed the sticky-tree-canvas-item branch from d818429 to 8f6ee21 Compare February 1, 2026 15:39
Comment thread scene/gui/tree.cpp Outdated
@@ -6847,6 +6923,9 @@ void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_auto_tooltip", "enable"), &Tree::set_auto_tooltip);
ClassDB::bind_method(D_METHOD("is_auto_tooltip_enabled"), &Tree::is_auto_tooltip_enabled);

ClassDB::bind_method(D_METHOD("set_max_sticky_items", "enable"), &Tree::set_max_sticky_items);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ClassDB::bind_method(D_METHOD("set_max_sticky_items", "enable"), &Tree::set_max_sticky_items);
ClassDB::bind_method(D_METHOD("set_max_sticky_items", "count"), &Tree::set_max_sticky_items);

Comment thread doc/classes/Tree.xml Outdated
@@ -383,6 +383,9 @@
<member name="hide_root" type="bool" setter="set_hide_root" getter="is_root_hidden" default="false">
If [code]true[/code], the tree's root is hidden.
</member>
<member name="max_sticky_items" type="int" setter="set_max_sticky_items" getter="get_max_sticky_items" default="0">
The maximum number of tree items allowed to stick to the top while its children are still in view.

@Naros Naros Feb 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If setting this to 0 is to imply the feature is disabled, there should be a note and/or sentence here that indicates calling the method with 0 disables the feature, and the Tree works as it did prior to this feature being added, particularly for EditorPlugin authors who may not want this to be enabled.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it could be nice to specify that explicitly. However, unless I'm misunderstanding, I think that would be the implied result of this being 0 anyways? As in, zero tree items would be allowed to stick to the top while children are in view?

Comment thread scene/gui/tree.h Outdated
Comment thread scene/gui/tree.h Outdated
Comment thread scene/gui/tree.cpp Outdated
Comment thread scene/gui/tree.cpp Outdated
Comment thread scene/gui/tree.cpp Outdated
Comment thread doc/classes/Tree.xml Outdated
@dugramen
dugramen force-pushed the sticky-tree-canvas-item branch from 8f6ee21 to 7f407d7 Compare February 3, 2026 17:02
@dugramen

dugramen commented Feb 3, 2026

Copy link
Copy Markdown
Contributor Author

pushed the changes and explicitly mentioned that a max of 0 disables sticking, just in case

@Naros Naros left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll defer to AThousandShips on the language, but LGTM.

@Repiteo
Repiteo requested a review from a team as a code owner February 17, 2026 20:09
@Kazox61

Kazox61 commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Tested the latest version and it works as expected.

@AdriaandeJongh
AdriaandeJongh self-requested a review February 26, 2026 11:02

@AdriaandeJongh AdriaandeJongh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Played around with this and think this is a great feature in general. A few notes:

  • I was unable to raise the sticky count above 6. Why not? IMO it should be able to go to a large number just because it will enable this UX improvement on various specific workflows. Even in Rift Riff's settings screen I easily hit 6 layers of organization deep and it wasn't enough. I suggest having a maximum of 16.

  • Looking at the trees in my commercial-game-grade projects, I think the default maximum sticky items of 3 is too low making the sticky headers less useful than they can be. The point of that number is to avoid infinite sticky items and filling the entire panel with stickies making the panel unusable.
    -- It's not trivial to land on a better number without making assumptions about some sort of median height of Godot user's scene panel.
    -- ... but making assumptions based on my experience with the editor, 5 would be a better default.

  • I'm not sure yet whether this should be improved and how it even could be improved, but at the core of the sticky header is that it 'hides' all the in-between nodes that are not the shortest path to root. However, there is currently no visual indication of when there are nodes in between the sticky ones or not. For example, in the video below, there is no visual indication that Control1 exists when Control2 sticks to the top:

Screen.Recording.2026-02-27.at.10.57.21.mp4

But like I said, I'm not sure we can and should address this. My first thought would be to add a tiny indicator like this one Image and stick it in between all the edges that hide nodes... but it'll very soon can crammed with all those icons, so I don't even like that solution much.

  • And finally, here's a few screenshots of a bunch of trees in Rift Riff showing how much more readable the tree becomes after this change – as well as notice that a few more stickied items above 6 would have been convenient for us:
Image Image Image

Comment thread editor/settings/editor_settings.cpp Outdated
Comment thread doc/classes/Tree.xml Outdated
Comment thread doc/classes/EditorSettings.xml Outdated
@dugramen
dugramen force-pushed the sticky-tree-canvas-item branch from 7f407d7 to 3756d07 Compare February 27, 2026 15:35
@dugramen

Copy link
Copy Markdown
Contributor Author

I pushed the suggestions. As for indicating when it reached its sticking limit, I feel like the difference in indentation between the normal and stuck content kind of does that already. Though there might be some cases / configurations that make it less clear, not sure

@AdriaandeJongh

Copy link
Copy Markdown
Contributor

hey yeah sorry i was unclear! see the image below, an annotated screencap of my video above: i was talking about the nodes hidden at the red arrow, while you’re talking about the itens hidden by the orange arrow. i agree that the items hidden by the orange item are fine as the indentation plus the drop shadow are a clear giveaway. however, nothing indicates there are nodes in between Control and Control2, where the red arrow is.

IMG_0629

again, i’m still not sure if we could even fix or address this.

@dugramen

Copy link
Copy Markdown
Contributor Author

Ah that makes sense. Maybe it could add shadows there too. It might look weird if there's a lot of shadows, but I can try it

@AdriaandeJongh

Copy link
Copy Markdown
Contributor

adding another shadow will make it unclear where the scroll container starts, so that’s probably not gonna work… hmm yeah idk.

@AdriaandeJongh

Copy link
Copy Markdown
Contributor

I tried a few things like putting lines and icons in between but their either have to be extremely small making it unreadable, or it's still kind of unclear why there is a line in there all of a sudden. The best I could come up with was this simple line giving at least some indication of there being something in between.... but I'm not sure it's all that clarifying. What do you think?

555892863-eb7d63cc-0395-4c6d-95ab-02fa94f5b474

@dugramen

Copy link
Copy Markdown
Contributor Author

Oh ok thanks. I updated visual studio recently, maybe that messed some stuff up

@AThousandShips

Copy link
Copy Markdown
Member

Turns out this was actually the account you made all your previous contributions with, and it's "invalid", i.e. it's not actually linked to your GitHub profile, so you're still a first time contributor, this being merged would make you count as a contributor (no contributions to this repo has been counted because you didn't use a proper account to sign the commit)

@dugramen

Copy link
Copy Markdown
Contributor Author

Lol a lot of weirdness going on today. Thanks for letting me know, and sorry for the trouble

@dugramen

Copy link
Copy Markdown
Contributor Author

It seems #118733 added a new canvas item stylebox_ci, introducing buggy visuals in this PR. I'll have to fix it in the morning

@dugramen
dugramen force-pushed the sticky-tree-canvas-item branch from dc9c0be to f0fcfd2 Compare April 22, 2026 17:25
@dugramen

Copy link
Copy Markdown
Contributor Author

Ok bugs should be fixed now

@dugramen
dugramen force-pushed the sticky-tree-canvas-item branch from f0fcfd2 to 6211f83 Compare April 22, 2026 17:41
@KoBeWi

KoBeWi commented Apr 22, 2026

Copy link
Copy Markdown
Member

Some glitched overlap

image
godot.windows.editor.dev.x86_64_FDmVCY5xAM.mp4

@KoBeWi KoBeWi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the above (which is a minor thing tbh) looks fine.

@KoBeWi KoBeWi modified the milestones: 4.x, 4.8 Apr 22, 2026
@dugramen
dugramen force-pushed the sticky-tree-canvas-item branch from 6211f83 to 452783c Compare April 22, 2026 18:11
@dugramen

Copy link
Copy Markdown
Contributor Author

That should fix it

@Repiteo
Repiteo merged commit 918a4e6 into godotengine:master Jun 19, 2026
20 checks passed
@Repiteo

Repiteo commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Thanks! Congratulations on your first merged contribution! 🎉

@passivestar

Copy link
Copy Markdown
Contributor

Congratulations on your first merged contribution!

dugramen has 22 merged PRs 😂

@AdriaandeJongh

Copy link
Copy Markdown
Contributor

this pr comes in as the first best pr though!!! 😂

@passivestar

Copy link
Copy Markdown
Contributor

idk the condensed inspector was kinda fire too but it's close haha

@dugramen

Copy link
Copy Markdown
Contributor Author

😅 Thanks guys. Yeah my GitHub and local git emails got unsynced at some point, so GitHub thinks it's a different author

@TokageItLab

TokageItLab commented Jul 5, 2026

Copy link
Copy Markdown
Member

This PR seems to be corrupting Skeleton3DEditor joint tree (issue #120991). We may also need to check for regressions in other places within the Editor where TreeItem is used.

Image

We cannot know what is happening because there are no shadows. Also, I am not sure when the sticky behavior occurs.

The sticky behavior occurs when there are multiple siblings, but I believe it should not occur for siblings that have children while in the unfolded state.

For example, the following case is still understandable:

  • a
    • b
      • c
      • d
      • e
    • f
      • g

↓ sticky

  • a
    • b
      • e
    • f
      • g

However, I assume it should never occur in cases like the following (I think the #115697 (comment) probably has a similar perspective to mine):

  • a
    • b
      • c
        • d
      • e
        • f
      • g
        • h
    • i

@AdriaandeJongh

AdriaandeJongh commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

However, I assume it should never occur in cases like the following (I think the #115697 (comment) probably has a similar perspective to mine):

  • a

    • b

      • c

        • d
      • e

        • f
      • g

        • h
    • i

to clarify: assuming ‘i’ has a lot of children that you are currently viewing, then it is expected that everything between a and i would be skipped. or in other words, a and i stick, hiding the rest of the tree that did not make up part of the hierarchy that lead to the nodes you are viewing.

with no other children, the same scenario can also expected to look as follows if the widow height would force it: (c-f skipped)

  • a
    • b
      • g
        • h
    • i

@TokageItLab

TokageItLab commented Jul 6, 2026

Copy link
Copy Markdown
Member

Even if they are skipped, it seems strange for the sticky behavior to occur while bypassing the parent. The lack of shadows is the biggest factor exacerbating the issue, but in cases like the one below, it is difficult to immediately find the parent of LeftHandIndex2.

image

For example, VSCode displays hidden parent-child relationships by concatenating them with slashes, as shown below:

image image
fold.mp4

Since the currently merged sticky behavior lack such concatenation and end up looking like below, it causes a regression in terms of the visibility of the parent-child relationship.

image

BendyLand pushed a commit to BendyLand/voltaire that referenced this pull request Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.