use crate::geometry::*; use std::fmt::Debug; pub const X_CLOCKWISE_RIGHT_ANGLE: i16 = -90 * 64; pub trait SideExt { fn to_x_angle(&self) -> i16; } impl SideExt for Side { fn to_x_angle(&self) -> i16 { match self { Side::Top => 90 * 64, Side::Right => 0, Side::Bottom => 270 * 64, Side::Left => 180 * 64, } } } pub trait RectangleExt { fn to_x_rectangle(&self) -> xcb::x::Rectangle where T: TryInto + TryInto + Debug, >::Error: Debug, >::Error: Debug; fn to_x_arc(&self, angle1: i16, angle2: i16) -> xcb::x::Arc where T: TryInto + TryInto + Debug, >::Error: Debug, >::Error: Debug; } impl RectangleExt for Rectangle { fn to_x_rectangle(&self) -> xcb::x::Rectangle where T: TryInto + TryInto + Debug, >::Error: Debug, >::Error: Debug { xcb::x::Rectangle { x: self.left.try_into().unwrap(), y: self.top.try_into().unwrap(), width: self.width.try_into().unwrap(), height: self.height.try_into().unwrap() } } fn to_x_arc(&self, angle1: i16, angle2: i16) -> xcb::x::Arc where T: TryInto + TryInto + Debug, >::Error: Debug, >::Error: Debug { xcb::x::Arc { x: self.left.try_into().unwrap(), y: self.top.try_into().unwrap(), width: self.width.try_into().unwrap(), height: self.height.try_into().unwrap(), angle1: angle1.try_into().unwrap(), angle2: angle2.try_into().unwrap(), } } }