Skip to content

Add support to the animated_field! macro for tuple structs #16736

@yonzebu

Description

@yonzebu

What problem does this solve or what need does it fill?

Components like TextColor and BackgroundColor cannot currently be easily animated without creating a custom AnimatableProperty.

What solution would you like?

Add support to the animated_field! macro (and consequently AnimatedField) for tuple structs. I'm not sure what the cleanest way to do this is from an implementation perspective, since the $ident pattern doesn't match tuple struct field indices and I'm not sure if it makes sense to use $literal, as that matches more than just field indices.

What alternative(s) have you considered?

  • Add an alternative easy way to animate tuple structs (e.g. a separate macro/type)
  • Maybe something could be done with Deref and a blanket implementation of AnimatableProperty? But this puts the burden on components to implement Deref, only works for tuple structs with single fields, and also introduces potential conflicts with trait implementations because it would be a blanket implementation

Additional context

I was specifically trying to animate UI color alpha when I ran into this, and I wonder if it's worth considering if there should be easy ways to get a &mut to a Color's alpha and also possibly animate individual fields of a component's fields (e.g. animating Transform::translation::x), but that's a separate issue and probably a little more complicated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AnimationMake things move and change over timeC-FeatureA new feature, making something new possibleS-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions