rive_rs/animation/
state_transition.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::StateMachineLayerComponent;
6use crate::core::{Core, ObjectRef, OnAdded, Property};
7
8#[derive(Debug, Default)]
9pub struct StateTransition {
10    state_machine_layer_component: StateMachineLayerComponent,
11    state_to_id: Property<u64>,
12    flags: Property<u64>,
13    duration: Property<u64>,
14}
15
16impl ObjectRef<'_, StateTransition> {
17    pub fn state_to_id(&self) -> u64 {
18        self.state_to_id.get()
19    }
20
21    pub fn set_state_to_id(&self, state_to_id: u64) {
22        self.state_to_id.set(state_to_id);
23    }
24
25    pub fn flags(&self) -> u64 {
26        self.flags.get()
27    }
28
29    pub fn set_flags(&self, flags: u64) {
30        self.flags.set(flags);
31    }
32
33    pub fn duration(&self) -> u64 {
34        self.duration.get()
35    }
36
37    pub fn set_duration(&self, duration: u64) {
38        self.duration.set(duration);
39    }
40}
41
42impl Core for StateTransition {
43    parent_types![(state_machine_layer_component, StateMachineLayerComponent)];
44
45    properties![
46        (151, state_to_id, set_state_to_id),
47        (152, flags, set_flags),
48        (158, duration, set_duration),
49        state_machine_layer_component,
50    ];
51}
52
53impl OnAdded for ObjectRef<'_, StateTransition> {
54    on_added!(StateMachineLayerComponent);
55}