Add box scaling to value tracks#112488
Conversation
|
I realise now that this might collide with the work in #105151 I had not realised someone else was working on this. EDIT: Having a look at that PR, it looks like it was decided to go with an implementation more similar to what I have done here, so it might make sense to supercede. |
d3fcf69 to
4d99bcb
Compare
4d99bcb to
1135d7d
Compare
|
Based on some feedback I got from @mihe on chat I did a few fixes. I also rebased it again. A few to notes for anyone reviewing this:
hscroll->connect(SceneStringName(value_changed), callable_mp(this, &AnimationTrackEditor::_h_scroll_changed));
|
Calinou
left a comment
There was a problem hiding this comment.
Tested locally, it works as expected (including undo/redo).
In terms of UX, I like how it works.
Visually, I would prefer the scaling lines to match the accent color (blue) so it feels more in line with the selected keyframe colors. Also, I think the lines could stand be made a tad thinner (one pixel thinner than currently would be good). They can easily overlap most of a keyframe icon right now:
The change would be visual only, it wouldn't impact the "hitbox" of the line so to speak.
I noticed two issues:
- Editing is still allowed in read-only (i.e. imported) Animation resources, even though dragging individual keyframes is already prevented:
animation_box_scale_read_only.mp4
- When scaling down to a near-zero value, the selection will constantly flicker back-and-forth. This occurs both with snapping enabled and disabled, but it's more noticeable with snapping enabled as shown here:
animation_box_scale_flicker.mp4
1135d7d to
8b537af
Compare
|
@Calinou thanks for the review. I changed the lines to blue and made it thinner and fixed the read-only issue and the issue with flickering when scaling close to 0. godot.windows.editor.dev.x86_64_cRYUSFIuu9.mp4
|
c60bec4 to
375024f
Compare
|
I believe I fixed the issue I was seeing before. The issue is in master as well and has to do with how the "string limit" is calculated for when to clip a keys rendering based on the next key, especially important for the function keys. The issue as far as I could tell was that limit was found by searching the next two keys, but didn't take into account that the order of the key could be completely different during a transformation event. Current Master behavior when moving keys can cause other keys to hide: godot.windows.editor.dev.x86_64_iWSjAQEiwh.mp4The code that calculated the limit: int limit_string = (editor->is_key_selected(track, i + 1) && editor->is_moving_selection()) ? int(offset_last) : int(offset_n);
if (editor->is_key_selected(track, i) && editor->is_moving_selection()) {
limit_string = int(MAX(limit_end, offset_last));
}My solution, which does require a loop: float next_visual_pos = limit_end;
if (editor->is_moving_selection() || editor->is_scaling_selection()) {
for (int j = 0; j < animation->track_get_key_count(track); j++) {
if (j == i) {
continue;
}
float test_offset = animation->track_get_key_time(track, j) - timeline->get_value();
test_offset = test_offset * scale + limit;
if (test_offset > offset && test_offset < next_visual_pos) {
next_visual_pos = test_offset;
}
}
next_visual_pos = MIN(next_visual_pos, limit_end);
} else {
next_visual_pos = offset_n;
}
int limit_string = int(next_visual_pos);The new correct behaviour: godot.windows.editor.dev.x86_64_itxib0V1wl.mp4 |
Calinou
left a comment
There was a problem hiding this comment.
Works great now 🙂 Code looks good to me.
I think it's good to go from an UX perspective.
|
I don't know if there is an animation meeting this Friday because of thanksgiving. @lyuma @TokageItLab but maybe we can check and approve async. |
375024f to
9a608df
Compare
|
I ended up going through the PR on more time with @mihe and making a handful of other small improvements and rebasing it. I think it's in a really good place now if the Animation team can look it over in their upcoming meeting. The biggest change was that we changed how the limit_string is calculated again and simply don't show the function names when any key on that track is being moved, since the code was complicated and never worked perfectly for updating the clipping while moving keys anyway. |
9a608df to
9dbe92e
Compare
|
Fixed failed check due to shadowed variable. |
|
This looks good to me from a UX perspective. I haven't seen the code tho. |
|
Setting this back to draft as there is a good bit of work left to do with some of the stuff Tokage pointed out. Hopefully I'll find some time to work on it soon :) |
9dbe92e to
211e9c0
Compare
1f0c417 to
c2e83bb
Compare
|
@TokageItLab I believe I resolved all the issues now. The only issue I have not resolved is that you can still scale keys into negative space, I feel like its a bit outside this PR to block transforming keys into negative space, but if you feel it makes the most sense that I include that in the PR I'll add that in for both scaling and moving. |
c2e83bb to
6c0ef6b
Compare
6c0ef6b to
620754b
Compare
|
I've rebased this. Note I did some related fixes in #113903 that got merged into 4.6. This should be ready for a re-review @TokageItLab when you have time. I think it's in a really good state now. EDIT: The one additional force push I did after this was a small change of a Vector into a LocalVector as it wasn't used anywhere else. |
620754b to
48cb92a
Compare
|
Animation Meeting Discussion: @TokageItLab Will review and report back the next animation meeting. |
48cb92a to
4881538
Compare
|
rebased |
4881538 to
7ded43c
Compare
|
Rebased and fixed an alignment issue. The alignment issue came from #114634 The issue seems to have arisen from margins being added to the timeline so the timeline control and the box_selection_container no longer align on the x-axis. I made a hacky fix. that just finds the margin by comparing the two. const float timeline_margin_left = timeline->get_global_position().x - box_selection_container->get_global_position().x;
...
key_rect.position.x = offset + timeline_margin_left;@YeldhamDev would you have a moment to look this over and see what the best way to make sure all of this aligns correctly? Maybe the way I set up the scale_control can be changed around or maybe this margin can just be safely fetched from the theme and used, but I am very unsure of the best way to do this and how to make sure it doesn't break with RTL. |
|
First of all, the best way to get the value of those margins correctly, even with RTL, is by simply repeating what the Second, if necessary, you could simply make so that |
7ded43c to
b0f9c9b
Compare
|
Sorry, putting this back to draft, I keep finding small issues that cropped up after the last upstream changes. I will set it back to ready for review and ping Tokage when I've resolved them. |
b0f9c9b to
df61959
Compare
df61959 to
8288374
Compare
|
OK, I have fixed all misalignment issues as far as I can tell. @TokageItLab if you have a chance to take another look? I don't know if it's possible for this to make it into 4.7, but I'd love to try and aim for that so I'll try and resolve any other issues raised as quick as possible. |
This adds box scaling to the Value Tracks Editor, similar to what was added to the Bezier Track Editor
This would resolve godotengine/godot-proposals#3532
godot.windows.editor.dev.x86_64_CuTQ7kKVd0.mp4
This ended up being a bit of a bigger PR than I had hoped, so it needs a thorough review. I'll set it for draft now until I've had the chance to give it a thorough lookover myself.
Edit: OK this should be ready for a review.