1use std::fmt::Debug;
2
3use crate::platform_impl::PlatformBounds;
4
5#[derive(Debug, Clone, Default)]
8pub struct Bounds {
9 pub x: f64,
10 pub y: f64,
11 pub width: f64,
12 pub height: f64,
13}
14
15#[cfg(target_os = "macos")]
16impl From<PlatformBounds> for Bounds {
17 fn from(value: PlatformBounds) -> Self {
18 Bounds {
19 x: value.origin.x,
20 y: value.origin.y,
21 width: value.size.width,
22 height: value.size.height,
23 }
24 }
25}
26
27#[cfg(target_os = "macos")]
28impl From<Bounds> for PlatformBounds {
29 fn from(value: Bounds) -> Self {
30 PlatformBounds {
31 origin: objc2_core_foundation::CGPoint::new(value.x, value.y),
32 size: objc2_core_foundation::CGSize::new(value.width, value.height),
33 }
34 }
35}
36
37#[cfg(target_os = "windows")]
38impl From<PlatformBounds> for Bounds {
39 fn from(value: PlatformBounds) -> Self {
40 Self {
41 x: value.left as _,
42 y: value.top as _,
43 width: (value.right - value.left) as _,
44 height: (value.bottom - value.top) as _,
45 }
46 }
47}
48
49#[cfg(target_os = "windows")]
50impl From<Bounds> for PlatformBounds {
51 fn from(value: Bounds) -> Self {
52 PlatformBounds {
53 left: value.x as _,
54 top: value.y as _,
55 right: (value.x + value.width) as _,
56 bottom: (value.y + value.height) as _,
57 }
58 }
59}