-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Add auto fit timeline and bezier scale on animation editor #87078
Conversation
Thank you for your contribution! I'd suggest you read this to see some of the style details for the code 🙂 |
9a0b259
to
3b77055
Compare
2a2ae88
to
3716959
Compare
Please use the format tool, see the link I sent 🙂 |
3716959
to
0e06b1c
Compare
Oh that's the point I missed, sorry, I'm really new to Open source project. I'm downloading LLVM right now and I'll try it. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the TrackEditor, this should be fine.
However, in the BezierEditor, this is similar in behavior to "focus" (Ctrl + F), so you can make a method with the range as an argument and "focus" and "auto fit" should share it.
Also, it performs a huge zoom when the vertical range is 0, so you must avoid the case as an exception, the same as with "focus". This should be avoidable by sharing methods.
@Hilderin are you still planning to finish this? Otherwise, I might help :) |
Yes, I was planning to work on it in the week to come. I was busy last week. Thanks for the offer @CookieBadger . |
@Hilderin great to hear, and I really dig your PR :) |
@Hilderin about the commits, as long as you did not accidentally delete anything that you weren't supposed to, squashing your commits should fix it, afaik |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, it works as expected.
However, when clicking the autofit button, the timeline horizontal scroll isn't put at the beginning. This means that if you zoom in towards the end of an animation, the animation will still be scrolled after clicking the autofit button. You need to manually scroll towards the left to see the entire animation. I'd expect this scrolling to happen automatically.
Very interesting suggestion... I did not thought about that!
This should work in Bezier Editor or not. b. for the time from the first keyframe to the animation end or the last keyframe, whichever is longer (+ buffer in the end) |
@Hilderin yes, that would work. Instead of scrolling to a |
I did make the modifications suggested. I did not known we could create keyframes before zero or after the animation end. Good to known! Thanks! I found why the scroll to the beginning was not working everytime. If the vertical and the horizontal zoom was updated at the same time, the modification on the timeline did not update the horizontal scrollbar before the hscroll->set_value was called. I created a _scroll_to_start which I can call deferred and the problem was fixed. Is it a good way to fix this? |
I thought about it and realized that I did not add shortcut for the new button. The text I used for the tooltip was too long and unclear so I renamed it for "Fit to panel", like in a text editor (ex: Google Docs, zoom: Fit). I choose Ctrl-Shift-F for the default keys, it does not seems to be in conflict with other shortcuts and the usage of the F key that is used for Focus seems appropriate. What do you think? |
I love the fact that it has a shortcut, I was actually going to suggest that. Maybe Ctrl+F or Shift+F would be more accessible? |
I changed the default shortcut for Ctrl-F, it's easier to use and still no conflict with others shortcuts (I think). I'm just waiting on the answer of @TokageItLab about the minimum vertical height (CMP_EPSILON or something else). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Please squash the PR into one commit as follow Pull request workflow.
69614d3
to
3bfa943
Compare
I was able to squash my commits and made corrections on my comments. |
Add a button at the bottom of the animation editor that change the zoom based on the animation length and the bezier scale based on the values and handles of the displayed tracks. The icon and the tooltip of the button change depending if the bezier editor is displayed or not. Some refactor was made in animation_track_editor.cpp to remove code duplication with the visibility check of the tracks. This should help with the issue godotengine#85826
3bfa943
to
b46d0a6
Compare
Add auto fit timeline and bezier scale on animation editor
06abc86
Thanks! And congrats for your first merged Godot contribution 🎉 |
Thanks!! And thanks all of you for your help and support :) |
A much-needed UI improvement, great job :) |
Add a button at the bottom of the animation editor that change the zoom based on the animation length and the bezier scale based on the values and handles of the displayed tracks. The icon and the tooltip of the button change depending if the bezier editor is displayed or not.
Some refactor was made in animation_track_editor.cpp to remove code duplication with the visibility check of the tracks.
This should help with the issue #85826
The objective was to help animation editor, above all the bezier editor which always starts with a strange scale. For small values, we always need to ctrl+alt+mouse wheel to see the cursves correctly. The auto fit helps a lot with that.
Auto fit button (outside bezier editor):
If you change the animation length, the zoom of the timeline can now be automatically updated based on the new length:
The size of the editor, the tracks names, etc... are taken into account exactly how it's done in the drawing of the timeline.
When i start Godot and open the Bezier editor for the first time, it looks like that:
The button is now updated with a different icon and tooltip for bezier:
After I pressed the new button:
It uses the min/max values of the keys and the handle positions. Only the visible tracks (not hidden and filtered) are used. That's why i refactored a little bit the code where the visibility of the tracks was made.
Tested with version 4.3.dev on Windows 11