rive_rs/animation/
state_machine_trigger.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 std::cell::Cell;
6
7use crate::animation::StateMachineInput;
8use crate::core::{Core, ObjectRef, OnAdded};
9
10#[derive(Debug, Default)]
11pub struct StateMachineTrigger {
12    state_machine_input: StateMachineInput,
13    is_fired: Cell<bool>,
14}
15
16impl ObjectRef<'_, StateMachineTrigger> {
17    pub fn reset(&self) {
18        self.is_fired.set(false);
19    }
20
21    pub fn fire(&self) {
22        self.is_fired.set(true);
23    }
24}
25
26impl Core for StateMachineTrigger {
27    parent_types![(state_machine_input, StateMachineInput)];
28
29    properties!(state_machine_input);
30}
31
32impl OnAdded for ObjectRef<'_, StateMachineTrigger> {
33    on_added!(StateMachineInput);
34}