2022-01-02 21:35:12 +11:00
|
|
|
use core_graphics::base::CGFloat;
|
|
|
|
|
|
|
|
use objc::runtime::{Class, Object};
|
2022-07-16 00:14:02 +10:00
|
|
|
use objc::{msg_send, sel, sel_impl};
|
2022-01-02 21:35:12 +11:00
|
|
|
use objc_id::ShareId;
|
|
|
|
|
|
|
|
use crate::foundation::id;
|
|
|
|
|
|
|
|
/// A wrapper for an animation proxy object in Cocoa that supports basic animations.
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub struct ViewAnimatorProxy(pub ShareId<Object>);
|
|
|
|
|
|
|
|
impl ViewAnimatorProxy {
|
|
|
|
pub fn new(proxy: id) -> Self {
|
2022-07-16 00:14:02 +10:00
|
|
|
Self(unsafe { ShareId::from_ptr(msg_send![proxy, animator]) })
|
2022-01-02 21:35:12 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Sets the alpha value for the view being animated.
|
|
|
|
pub fn set_alpha(&self, value: CGFloat) {
|
|
|
|
unsafe {
|
2022-07-16 00:14:02 +10:00
|
|
|
let _: () = msg_send![&*self.0, setAlphaValue: value];
|
2022-01-02 21:35:12 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|