rive_rs/bones/
root_bone.rsuse crate::bones::Bone;
use crate::core::{Core, CoreContext, ObjectRef, OnAdded, Property};
use crate::status_code::StatusCode;
use crate::transform_component::TransformComponent;
#[derive(Debug, Default)]
pub struct RootBone {
bone: Bone,
x: Property<f32>,
y: Property<f32>,
}
impl ObjectRef<'_, RootBone> {
pub fn x(&self) -> f32 {
self.x.get()
}
pub fn set_x(&self, x: f32) {
if self.x() == x {
return;
}
self.x.set(x);
self.cast::<TransformComponent>().mark_transform_dirty();
}
pub fn y(&self) -> f32 {
self.y.get()
}
pub fn set_y(&self, y: f32) {
if self.y() == y {
return;
}
self.y.set(y);
self.cast::<TransformComponent>().mark_transform_dirty();
}
}
impl Core for RootBone {
parent_types![(bone, Bone)];
properties![(90, x, set_x), (91, y, set_y), bone];
}
impl OnAdded for ObjectRef<'_, RootBone> {
on_added!([on_added_dirty, import], Bone);
fn on_added_clean(&self, context: &dyn CoreContext) -> StatusCode {
self.cast::<TransformComponent>().on_added_clean(context)
}
}