use crate::PhySize;
use windows_sys::Win32::Foundation::RECT;
#[derive(Copy, Clone)]
pub struct Rect(pub RECT);
impl Rect {
pub const EMPTY: Self = Self(RECT { left: 0, top: 0, right: 0, bottom: 0 });
pub fn size(&self) -> PhySize {
PhySize {
width: self.0.right.abs_diff(self.0.left),
height: self.0.top.abs_diff(self.0.bottom),
}
}
}
impl From<PhySize> for Rect {
fn from(size: PhySize) -> Self {
Self(RECT {
left: 0,
top: 0,
right: size.width.try_into().unwrap_or(i32::MAX),
bottom: size.height.try_into().unwrap_or(i32::MAX),
})
}
}