X Tutup
Skip to content

Use dedicated canvas item to properly cull tree items#114572

Merged
akien-mga merged 1 commit intogodotengine:masterfrom
boozee:PR-114123--bug-with-tree-item-culling
Jan 10, 2026
Merged

Use dedicated canvas item to properly cull tree items#114572
akien-mga merged 1 commit intogodotengine:masterfrom
boozee:PR-114123--bug-with-tree-item-culling

Conversation

@boozee
Copy link
Contributor

@boozee boozee commented Jan 3, 2026

This PR fixes #114123 following the advice given here by the reporter @KoBeWi.

The culling window for tree items has been restricted to the proper rect up to the bottom of the tree, fixing the early exit that didn't account for the bottom margin and thus the issue itself.

That itself was not enough, as the same problem was showing on the top of the FileSystem tab, which lead me do find out it was a workaround to prevent items from rendering beyond the column headers.

So, as suggested in the linked comment, I introduced a separate canvas item for column headers in order to separate item culling from those, no matter the size of the item.

I'm attaching some videos as proof of the solution.

Details
DpamvqBPb8.mp4
godot.windows.editor.x86_64_wzhlsNdaW1.mp4
godot.windows.editor.x86_64_zhFaApCg6p.mp4

Bugsquad edit: Fixes #114140

@boozee boozee marked this pull request as ready for review January 3, 2026 20:10
@boozee boozee requested a review from a team as a code owner January 3, 2026 20:10
@KoBeWi KoBeWi modified the milestones: 4.x, 4.6 Jan 5, 2026
@KoBeWi
Copy link
Member

KoBeWi commented Jan 5, 2026

When column titles are visible, the scroll bar is wrongly covered:

godot.windows.editor.dev.x86_64_aQcqTrTGct.mp4

Also titles are not affected by self_modulate.

image

@boozee boozee force-pushed the PR-114123--bug-with-tree-item-culling branch 2 times, most recently from 1e7eeef to 13ed88f Compare January 8, 2026 21:44
@boozee boozee requested a review from KoBeWi January 8, 2026 21:55
@KoBeWi
Copy link
Member

KoBeWi commented Jan 8, 2026

Scroll hints have wrong color:
image
Likely from #114751, you need to rebase and fix your branch.

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

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

I skimmed over the code. You are performing lots of unnecessary updates for the internal CanvasItems. You should only set what is necessary (and do it once if it does not change), most of the stuff like visibility, modulate, transform is just inherited from Tree.

@boozee boozee force-pushed the PR-114123--bug-with-tree-item-culling branch 4 times, most recently from d0f1d63 to eef97f9 Compare January 9, 2026 21:15
Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

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

Tested, works fine overall. Though you are unnecessarily passing the canvas items as arguments to methods. They always use the same one.

Though before doing further changes, apply this patch:

0001-Fixup.patch

It removes some unnecessary code and disables clipping of custom drawing (it wasn't clipped in previous versions, so no reason to do it).

@boozee boozee force-pushed the PR-114123--bug-with-tree-item-culling branch from eef97f9 to 02c2dea Compare January 10, 2026 16:19
@boozee boozee force-pushed the PR-114123--bug-with-tree-item-culling branch from 02c2dea to bd54c55 Compare January 10, 2026 16:50
}
rendering_server->canvas_item_clear(header_ci);
rendering_server->canvas_item_set_custom_rect(header_ci, !is_visibility_clip_disabled(), header_clip_rect);
rendering_server->canvas_item_set_clip(header_ci, true);
Copy link
Member

Choose a reason for hiding this comment

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

Setting clip here should also be unnecessary, but from my testing it seems you have to set it every time for some reason. No idea how it works.

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

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

Looks good now.

@akien-mga akien-mga merged commit 836df3a into godotengine:master Jan 10, 2026
20 checks passed
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged Godot contribution 🎉

@boozee boozee deleted the PR-114123--bug-with-tree-item-culling branch January 11, 2026 08:54
rivie13 pushed a commit to rivie13/Phoenix-Agentic-Engine that referenced this pull request Feb 16, 2026
…-tree-item-culling

Use dedicated canvas item to properly cull tree items
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.

TreeItems disappear in the middle of the title when scrolling. Invalid Tree margin when scrolling

4 participants

X Tutup