Struct oxygengine_user_interface::raui::core::animator::AnimatorStates[][src]

pub struct AnimatorStates(pub HashMap<String, AnimatorState, RandomState>);
Expand description

The current state of animations in a component

The AnimatorStates can be accessed from the WidgetContext to get information about the current state of all component animations.

Example

fn my_widget(context: WidgetContext) -> WidgetNode {
    // Get the animator from our context
    let WidgetContext { animator, .. } = context;
     
    // Create the properties for a size box
    let size_box_props = Props::new(SizeBoxProps {
        transform: Transform {
            // Get the `scale` value of the `my_anim` animation or and
            // scale our button based on the animation progress
            scale: Vec2::from(animator.value_progress_factor_or("my_anim", "scale", 1.)),
            ..Default::default()
        },
        ..Default::default()
    });

    // Wrap our button in our animated size box
    widget! { (size_box: {size_box_props} {
        content = (my_button)
    }) }
}

Animations & Values

A component may have any number of different animations identified by a string anim_id. Additionally each animation can have more than one value that is animated and each of these values has a value_name that can be used to get the animated value.

Tuple Fields

0: HashMap<String, AnimatorState, RandomState>

Implementations

Returns whether or not any of the animations for this component are in-progress

Returns true if none of this component’s animations are currently running

Returns true if the widget has an animation with the given anim_id

Get the current progress of the animation of a given value

This will return None if the value is not currently being animated.

Get the current progress factor of the animation of a given value

If the value is currently being animated this will return Some Scalar between 0 and 1 with 0 meaning just started and 1 meaning finished.

If the value is not currently being animated None will be returned

Same as value_progress_factor but returning default instead of None

Same as value_progress_factor but returning 0 instead of None

Update the animation with the given anim_id

If animation is None the animation will be removed.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.