Add angle-aware interpolation modes for animations#10453
Add angle-aware interpolation modes for animations#10453task-jp wants to merge 4 commits intoslint-ui:masterfrom
Conversation
|
This seems like a cool idea. That said, I don't feel very comfortable with "interpolation" as enum name. That is very generic for something very specific. I wonder if another way would be to provide a filter function for the interpolation (a way for users to specify). After all this adjusts start/end and bounds, but the interpolation remains linear, no? |
|
Just wondering about how this makes the animation API more complex for all types, but this only helps angle animations? Although it puts the burden back to the developer, you can still achieve the desired animation today by using positive or negative angles? |
|
My usecase is to animate needles in analog clock. I took I would also like to add other types of animation such as color in various color spaces in the future. |
|
The animate keyword is associated with properties where the type is known. We could make it so that an |
ogoffart
left a comment
There was a problem hiding this comment.
I think this makes total sense, but it shouls be forbidden to use on any type but angle.
We also can bikeshed the naming
internal/compiler/object_tree.rs
Outdated
| let binding_expr = binding.BindingExpression(); | ||
| let Some(expr) = binding_expr.Expression() else { continue }; | ||
| let Some(qn) = expr.QualifiedName() else { continue }; | ||
| let mode = qn.text().to_string(); |
There was a problem hiding this comment.
This should also support things like interpolation: Something.foobar-interpolation
And we should IMHO say that we can't put any interpolation if the type is not angle.
Add `interpolation` property to animations with support for: - `linear` (default): Standard numeric interpolation - `angle-shorter`: Take the shorter arc for angle values - `angle-longer`: Take the longer arc for angle values - `angle-clockwise`: Always rotate clockwise - `angle-counterclockwise`: Always rotate counterclockwise This is useful for `transform-rotation` and other angle properties where the interpolation path matters. For example, animating from 10° to 350° with `angle-shorter` will rotate 20° counterclockwise instead of 340° clockwise. Similar to Qt's RotationAnimation.direction and CSS hue-interpolation-method.
Both easing_kind_identifier and interpolation_mode_identifier contain "linear", causing an unresolved conflict in tree-sitter parser generation. Add explicit conflict resolution to the grammar. This pattern is consistent with Slint's design where the same variant name can exist in multiple enums (e.g., Center in 5 alignment enums).
Add compile-time validation that angle-aware interpolation modes (angle-shorter, angle-longer, angle-clockwise, angle-counterclockwise) can only be used with properties of type `angle`. This prevents misuse of angle interpolation on non-angle properties like length or float, where the angle-specific behavior would not make sense.
96ac754 to
08fa0cc
Compare
Instead of checking individual angle-* interpolation mode values, reject the `interpolation` property entirely when the animated property is not of type angle. This is simpler and more robust since it handles all expression forms, not just literal identifiers.
dc8a55c to
df9343f
Compare
Add
interpolationproperty to animations with support for:linear(default): Standard numeric interpolationangle-shorter: Take the shorter arc for angle valuesangle-longer: Take the longer arc for angle valuesangle-clockwise: Always rotate clockwiseangle-counterclockwise: Always rotate counterclockwiseThis is useful for
transform-rotationand other angle properties where the interpolation path matters. For example, animating from 10° to 350° withangle-shorterwill rotate 20° counterclockwise instead of 340° clockwise.Similar to Qt's RotationAnimation.direction and CSS hue-interpolation-method.