Skip to main content

polyhorn_ios_sys/polykit/
layout_event.rs

1use objc::runtime::*;
2use objc::*;
3
4use crate::coregraphics::CGRect;
5use crate::Raw;
6
7/// Event that is generated by `UIView.layoutSubviews()` and that contains the
8/// frame of a view in screen coordinates (if mounted, otherwise in local
9/// coordinates).
10pub struct PLYLayoutEvent {
11    object: *mut Object,
12}
13
14impl PLYLayoutEvent {
15    /// Returns the frame of the view that generated this layout event.
16    pub fn frame(&self) -> CGRect {
17        unsafe { msg_send![self.object, frame] }
18    }
19}
20
21impl Raw for PLYLayoutEvent {
22    unsafe fn from_raw(object: *mut Object) -> Self {
23        PLYLayoutEvent { object }
24    }
25
26    unsafe fn as_raw(&self) -> *mut Object {
27        self.object
28    }
29}
30
31impl Drop for PLYLayoutEvent {
32    fn drop(&mut self) {
33        unsafe { objc_release(self.object) }
34    }
35}