rive_rs/animation/
animation.rs

1// Copyright 2021 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::animation::LinearAnimation;
6use crate::core::{Core, CoreContext, ObjectRef, OnAdded, Property};
7use crate::status_code::StatusCode;
8
9#[derive(Debug, Default)]
10pub struct Animation {
11    name: Property<String>,
12}
13
14impl ObjectRef<'_, Animation> {
15    pub fn name(&self) -> String {
16        self.name.get()
17    }
18
19    pub fn set_name(&self, name: String) {
20        self.name.set(name);
21    }
22}
23
24impl Core for Animation {
25    properties![(55, name, set_name)];
26}
27
28impl OnAdded for ObjectRef<'_, Animation> {
29    on_added!([import]);
30
31    fn on_added_dirty(&self, context: &dyn CoreContext) -> StatusCode {
32        if let Some(linear_animation) = self.try_cast::<LinearAnimation>() {
33            return linear_animation.on_added_dirty(context);
34        }
35
36        StatusCode::Ok
37    }
38
39    fn on_added_clean(&self, context: &dyn CoreContext) -> StatusCode {
40        if let Some(linear_animation) = self.try_cast::<LinearAnimation>() {
41            return linear_animation.on_added_clean(context);
42        }
43
44        StatusCode::Ok
45    }
46}