Skip to content

Collapse groups in animation track editor#113479

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
Meorge:feat/collapse-anim-groups
Feb 24, 2026
Merged

Collapse groups in animation track editor#113479
Repiteo merged 1 commit into
godotengine:masterfrom
Meorge:feat/collapse-anim-groups

Conversation

@Meorge
Copy link
Copy Markdown
Contributor

@Meorge Meorge commented Dec 2, 2025

Closes godotengine/godot-proposals#10276 .

This PR adds a disclosure button on the left side of each track group in the Animation tab's track editor. Clicking it hides all of the child tracks:

CleanShot.2025-12-02.at.15.52.30.mp4

Collapsed group data is saved in Animation resources, so it persists across editing sessions. However, toggling the visibility of a group does not currently count as an action that dirties the scene/resource (i.e., it doesn't make it display as "unsaved" the way that moving a keyframe does).

TODOs

  • Find a better way of saving collapse states, likely as part of the EditorFolding class in editor/settings/editor_folding.cpp.
  • Investigate an error that sometimes occurs when performing a box selection (doesn't seem to break anything but the error message is annoying).
  • Auto-update the names of folded groups when the nodes they represent are renamed.

Copy link
Copy Markdown
Contributor

@mihe mihe left a comment

Choose a reason for hiding this comment

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

We're not part of the animation team, but me and @Arnklit looked this over, and this looks great from a functionality standpoint. We do have some concerns about the code though.

Comment thread editor/animation/animation_track_editor.cpp Outdated
Comment thread editor/animation/animation_track_editor.h Outdated
Comment thread editor/animation/animation_track_editor.h Outdated
Comment thread scene/resources/animation.cpp Outdated
Comment thread editor/animation/animation_track_editor.h Outdated
@Meorge
Copy link
Copy Markdown
Contributor Author

Meorge commented Dec 3, 2025

Thanks for the review! A lot of this was coded up in a bit of an excited hyperfocused frenzy, so there may be some sloppiness in the code that has to be addressed, haha 😅 .

I'll address each of the comments in their respective threads, but for the big point: I discussed handling how to save the collapse states with some folks in the RocketChat last night, and they suggested I use the same approach as Godot currently does for collapsing and uncollapsing nodes in scene views. Today I'm planning to work on figuring that out and implementing it here.

This definitely won't be ready in time for 4.6, but with all the time that'll be available, hopefully it'll make it in for 4.7 😄

@fire
Copy link
Copy Markdown
Member

fire commented Dec 4, 2025

I think mentioned that inspection editor collapse strategy is preferred. I suspect the node tree collapse in the scenetree is saved but we don’t want runtime impact. We discussed matching and concerns about runtime bloat and version control spam.

@Meorge
Copy link
Copy Markdown
Contributor Author

Meorge commented Dec 4, 2025

It looks to me like the scene tree fold state saving is implemented in editor/settings/editor_folding.cpp. I will soon try to add animation folding functionality to it, but given that this PR is now only a potential candidate for 4.7 at the latest, there's no big time crunch so it may not be as high-priority of an item for me.

@Meorge Meorge force-pushed the feat/collapse-anim-groups branch from 896a793 to 248e214 Compare December 8, 2025 04:53
@Meorge Meorge requested a review from a team December 8, 2025 04:53
@Meorge Meorge force-pushed the feat/collapse-anim-groups branch from 248e214 to 20c97e1 Compare December 8, 2025 19:18
Comment thread editor/settings/editor_folding.h Outdated
@@ -31,6 +31,7 @@
#pragma once

#include "scene/main/node.h"
#include "scene/resources/animation.h"
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.

Suggested change
#include "scene/resources/animation.h"
class Animation;

I'd say

@Meorge
Copy link
Copy Markdown
Contributor Author

Meorge commented Dec 8, 2025

Fold status is now saved in the editor config files, and is also updated when a node is renamed so that the underlying node keeps its fold status!

From my bit of testing, the node-renaming functionality worked, but I am a bit nervous that there could be edge cases with it that I'm unaware of, so feedback from people who've used the Animation system more extensively (or are more familiar with its internals) would be appreciated!

Copy link
Copy Markdown
Contributor

@mihe mihe left a comment

Choose a reason for hiding this comment

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

It's a bit of shame to have to add new methods to EditorFolding, seeing as how we already have Object::editor_section_folding, but obviously we can't really use that without having to save out the default value (true) for every single track of every single animation player.

Apart from the minor requested changes, this looks good to me and @Arnklit.

Comment thread editor/animation/animation_track_editor.cpp Outdated
Comment thread editor/animation/animation_track_editor.cpp Outdated
Comment thread editor/animation/animation_track_editor.cpp Outdated
Comment thread editor/settings/editor_folding.cpp Outdated
Comment thread scene/resources/animation.h Outdated
@Meorge
Copy link
Copy Markdown
Contributor Author

Meorge commented Jan 21, 2026

Wonderful, thanks! I'll try to get to these suggestions soon 🙂

Edit: Suggestions have been applied, thank you again!

@Meorge Meorge force-pushed the feat/collapse-anim-groups branch from 20c97e1 to 5527176 Compare January 22, 2026 04:13
Comment thread scene/resources/animation.h Outdated
Node *n = root->get_node_or_null(node);
if (n) {
editor_selection->add_node(n);
Rect2 fold_area_rect = Rect2(0, 0, get_size().height, get_size().height);
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.

I'd say this needs an explanation, using height for both looks odd without it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree, it does seem rather arbitrary. For now I've reworked it a bit to use the width of the left margin plus the width of the icon. I'm a little worried that this means the clickable area might change when the row is folded versus unfolded, but I tried toggling it a bit and it felt natural to me.

@Meorge Meorge force-pushed the feat/collapse-anim-groups branch from a2d3ee7 to 735838e Compare January 22, 2026 17:08
@KoBeWi
Copy link
Copy Markdown
Member

KoBeWi commented Feb 8, 2026

Looks like folding is only saved for animations stored in their own file. Is this intended? Usually the animations are built-in in the scene.
It's not really a problem though, the folding state is at least preserved until the scene is reloaded.

@Meorge
Copy link
Copy Markdown
Contributor Author

Meorge commented Feb 8, 2026

Hm, my recollection from testing was that for an animation as part of the scene, the file with the saved folding data would use a format like my_scene.tscn:f83g1cs to indicate it was a subresource. I'm not at my work computer right now so I can't test (and the format I described might not be entirely right as a result) but I thought the subresource-of-scene approach was what I'd tested...

@KoBeWi
Copy link
Copy Markdown
Member

KoBeWi commented Feb 8, 2026

folding data would use a format like my_scene.tscn:f83g1cs

That's not a valid filename.
There is scene folding file that has folding data for sub-resources, but does not include Animations.

@Meorge
Copy link
Copy Markdown
Contributor Author

Meorge commented Feb 8, 2026

I definitely remember having that same thought (about the file name not being valid) and taking a bit of a detour to try and resolve it. What platform are you testing on? I'm on macOS; I wonder if maybe it lets that kind of filename be used, but other platforms don't? Alternatively it's possible that something subtly broke in the rebase. Will test it again once I'm at my computer.

@KoBeWi
Copy link
Copy Markdown
Member

KoBeWi commented Feb 8, 2026

I'm on Windows.

@mihe
Copy link
Copy Markdown
Contributor

mihe commented Feb 9, 2026

I don't know if I just never looked at the actual file on disk, or if something changed since the review, but yeah, it ends up trying to write to:

res://.godot/editor/my_scene.tscn::MyAnimationPlayer_8r83o-folding-56226cc8557fb551fda7dcc390daaeda.cfg

... which ends up actually "working" on Linux somehow, but gets truncated to:

res://.godot/editor/-folding-56226cc8557fb551fda7dcc390daaeda.cfg

On Windows : is a reserved character, so would indeed make up an invalid filename, which might explain why it doesn't get written out at all there.

@Meorge
Copy link
Copy Markdown
Contributor Author

Meorge commented Feb 9, 2026

Just rebased and checked its behavior on macOS, and indeed it's writing to a funky filename:
CleanShot 2026-02-08 at 20 56 52@2x

Perhaps some filepath shenanigans are happening here due to the slashes replacing colons, that cause the scene.tscn part to disappear on Linux? Anyways, this might be fixable by just replacing the :: (or // as it seems to become on macOS) with some other separator, such as --?

@Meorge
Copy link
Copy Markdown
Contributor Author

Meorge commented Feb 14, 2026

It should now be updated so that, rather than creating a dedicated file for animation group folding, it does the following:

For animations that are built-in to a scene, the folded groups are stored similarly to resource_unfolds:

[folding]

node_unfolds=[NodePath("Sprite2D2"), PackedStringArray("Visibility", "Transform"), NodePath("Sprite2D3"), PackedStringArray("Visibility", "Material", "material")]
resource_unfolds=["res://scene.tscn::CanvasItemMaterial_ulcgi", PackedStringArray("Resource")]
nodes_folded=[]
animation_groups_folded=["res://scene.tscn::Animation_ulcgi", PackedStringArray("Sprite2D2", "Sprite2D3"), "res://scene.tscn::Animation_nxogm", PackedStringArray(), "res://scene.tscn::Animation_3253y", PackedStringArray()]

For animations that are in their own .tres file, the fold information is stored in the resource's folding file:

[folding]

sections_unfolded=PackedStringArray("Resource")
animation_groups_folded=PackedStringArray("Sprite2D2")

@KoBeWi
Copy link
Copy Markdown
Member

KoBeWi commented Feb 14, 2026

Got some error:

ERROR: Couldn't find the given section "8697bdede100cd0585b388a2ae84d30f" and key "folding", and no default was given.
   at: (C:\godot_source\core/io/config_file.cpp:60)

after saving a built-in animation to a file.

@Meorge
Copy link
Copy Markdown
Contributor Author

Meorge commented Feb 14, 2026

This appears to be an existing bug in Godot itself; just opening the "Manage Animations..." menu in the "Animation" tab, when running off the master branch (bf95b62) gives me the error as well (obviously the hash is different):

ERROR: Couldn't find the given section "4054d2969add7a50ce2579471516f900" and key "folding", and no default was given.
   at: get_value (./core/io/config_file.cpp:60)

This is on v4.7.dev.custom_build [bf95b62]. I'll look into filing an issue for it, but at the very least it doesn't seem to be caused by this feature PR.

Edit: Issue has been logged at #116293, and fix PR has been submitted at #116295

Comment thread scene/resources/animation.h
Comment thread editor/settings/editor_folding.cpp Outdated
Comment thread editor/docks/scene_tree_dock.cpp Outdated
Comment thread editor/docks/scene_tree_dock.cpp Outdated
@Meorge Meorge force-pushed the feat/collapse-anim-groups branch from 2b14ee3 to 5dfeef8 Compare February 14, 2026 20:48
@fire fire moved this to Ready for review in Animation Team Issue Triage Feb 16, 2026
Copy link
Copy Markdown
Member

@fire fire left a comment

Choose a reason for hiding this comment

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

Animation Meeting Discussion:

@TokageItLab Trusts @KoBeWi 's review.

Comment thread scene/resources/animation.h Outdated
… on left

Save group collapsed state during editing session

Save collapsed groups in Animation resource so they persist across sessions

Update editor/animation/animation_track_editor.h

Remove data duplication and unnecessary method

Prevent error about negative-sized Rect2

Move animation group folding to editor cfg files

Clean up length of some lines of code

Keep fold state of groups when renamed

Update scene/resources/animation.h

Make fold_area_rect calculation more accurate

Improve animation includes

Store animation fold state in scene folding file

Fix animation fold saving for independent resource animations

Apply suggestions from code review

Update scene/resources/animation.h

Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Co-authored-by: Mikael Hermansson <mikael@hermansson.io>
Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>
Co-authored-by: Thaddeus Crews <repiteo@outlook.com>
@Meorge Meorge force-pushed the feat/collapse-anim-groups branch from 6fdab10 to 5c4500a Compare February 23, 2026 18:48
@Repiteo Repiteo modified the milestones: 4.x, 4.7 Feb 24, 2026
@Repiteo Repiteo merged commit 15a4311 into godotengine:master Feb 24, 2026
20 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for review to Done in Animation Team Issue Triage Feb 24, 2026
@Repiteo
Copy link
Copy Markdown
Contributor

Repiteo commented Feb 24, 2026

Thanks!

@Meorge Meorge deleted the feat/collapse-anim-groups branch February 24, 2026 23:21
@VR-Rathod
Copy link
Copy Markdown

After collapseing Group can we add little hint or light gray animation length to astimate How this group has animation long!

Group 1  O----------- 5 sec -----------O (total length)
thing 1   O-- 2 sec --O <--->(empty space )
thing 2   (empty space first 3 sec )<---> O-- 2 sec --O

may be like this! or this already implimented?

sorry i don't have Computer so i sharing my though without checking this pr

@Meorge
Copy link
Copy Markdown
Contributor Author

Meorge commented Feb 25, 2026

As of right now, the groups do not show the "sum" of keyframes within them. I know this is behavior that other tools have (Blender, and I'm pretty sure Unity as well). It could be added in a follow-up PR, although at the moment I'm not sure if I'd have the time for it. If no one else is interested in implementing it though, I can add it to my to-do list 🙂

@mihe
Copy link
Copy Markdown
Contributor

mihe commented Feb 25, 2026

Another follow-up to this that would make a lot of sense is the ability to collapse groups in the bezier animation editor as well.

@mdtrooper
Copy link
Copy Markdown

Sorry, I see the resume of changes of the new version: https://godotengine.org/article/dev-snapshot-godot-4-7-dev-2/

And I think that the collapsed group in track editor should show the max time of the items in the group.

Such as my quick and dirty mockup:

imagen

@Meorge
Copy link
Copy Markdown
Contributor Author

Meorge commented Mar 4, 2026

@mdtrooper See #113479 (comment) - I agree I think that'd be a good feature to add, but I probably won't have time to work on it myself for at least a little while yet. If someone else is able to start working on it then that will be great, otherwise I may eventually be able to get to it 😅

@naturally-intelligent
Copy link
Copy Markdown

Sorry, I see the resume of changes of the new version: https://godotengine.org/article/dev-snapshot-godot-4-7-dev-2/

And I think that the collapsed group in track editor should show the max time of the items in the group.

Also had a similar thought, but think it should be greyed out when collapsed:

image

And if possible, bunched into one

@mdtrooper
Copy link
Copy Markdown

Sorry, I see the resume of changes of the new version: https://godotengine.org/article/dev-snapshot-godot-4-7-dev-2/
And I think that the collapsed group in track editor should show the max time of the items in the group.

Also had a similar thought, but think it should be greyed out when collapsed:
image

Sorry, I see the resume of changes of the new version: https://godotengine.org/article/dev-snapshot-godot-4-7-dev-2/
And I think that the collapsed group in track editor should show the max time of the items in the group.

Also had a similar thought, but think it should be greyed out when collapsed:
image

And if possible, bunched into one

Yes 👍 it is better your mockup the colour grey and show the points.

@mihe
Copy link
Copy Markdown
Contributor

mihe commented Mar 11, 2026

We put up a pull request to draw the keys on top of the collapsed groups: #117321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Implement node collapsing in the animation track editor