1use crate::bridge::ffi;
5
6#[derive(Debug, Clone, Copy, PartialEq)]
9pub struct Rect {
10 pub left: f32,
12 pub top: f32,
14 pub right: f32,
16 pub bottom: f32,
18}
19
20impl Rect {
21 pub const fn new(left: f32, top: f32, right: f32, bottom: f32) -> Self {
23 Self {
24 left,
25 top,
26 right,
27 bottom,
28 }
29 }
30
31 pub fn width(&self) -> f32 {
33 self.right - self.left
34 }
35
36 pub fn height(&self) -> f32 {
38 self.bottom - self.top
39 }
40
41 pub fn is_empty(&self) -> bool {
43 self.left >= self.right || self.top >= self.bottom
44 }
45}
46
47impl From<Rect> for ffi::Rect {
48 fn from(r: Rect) -> Self {
49 ffi::Rect {
50 fLeft: r.left,
51 fTop: r.top,
52 fRight: r.right,
53 fBottom: r.bottom,
54 }
55 }
56}
57
58impl From<ffi::Rect> for Rect {
59 fn from(r: ffi::Rect) -> Self {
60 Self {
61 left: r.fLeft,
62 top: r.fTop,
63 right: r.fRight,
64 bottom: r.fBottom,
65 }
66 }
67}