diff --git a/crates/tek_core/src/space.rs b/crates/tek_core/src/space.rs index 5427c160..366f588c 100644 --- a/crates/tek_core/src/space.rs +++ b/crates/tek_core/src/space.rs @@ -133,16 +133,16 @@ pub trait Area: Copy { #[inline] fn split_fixed (&self, direction: Direction, a: N) -> ([N;4],[N;4]) { match direction { Direction::Up => ( - [self.x(), self.y() + self.h() - a, self.w(), a], - [self.x(), self.y(), self.w(), self.h() - a], + [self.x(), (self.y()+self.h()).minus(a), self.w(), a], + [self.x(), self.y(), self.w(), self.h().minus(a)], ), Direction::Down => ( [self.x(), self.y(), self.w(), a], - [self.x(), self.y() + a, self.w(), self.h() - a], + [self.x(), self.y() + a, self.w(), self.h().minus(a)], ), Direction::Right => ( [self.x(), self.y(), a, self.h()], - [self.x() + a, self.y(), self.w() - a, self.h()], + [self.x() + a, self.y(), self.w().minus(a), self.h()], ), _ => todo!(), } @@ -290,24 +290,14 @@ where } } -//`Layers<_, impl (Fn(&mut dyn FnMut(&dyn Widget) -> Result<(), Box<...>>) -> ... ) + Send + Sync>` -//`Layers) -> Result<(), Box<(dyn std::error::Error + 'static)>>) -> Result<(), Box<(dyn std::error::Error + 'static)>>) + Send + Sync + '_>` - -#[derive(Copy, Clone)] -pub enum Direction { - Up, - Down, - Left, - Right, -} - +#[derive(Copy, Clone, PartialEq)] +pub enum Direction { Up, Down, Left, Right, } impl Direction { - pub fn is_down (&self) -> bool { - match self { Self::Down => true, _ => false } - } - pub fn is_right (&self) -> bool { - match self { Self::Right => true, _ => false } - } + pub fn is_up (&self) -> bool { match self { Self::Up => true, _ => false } } + pub fn is_down (&self) -> bool { match self { Self::Down => true, _ => false } } + pub fn is_left (&self) -> bool { match self { Self::Left => true, _ => false } } + pub fn is_right (&self) -> bool { match self { Self::Right => true, _ => false } } + /// Return next direction clockwise pub fn cw (&self) -> Self { match self { Self::Up => Self::Right, @@ -316,6 +306,7 @@ impl Direction { Self::Right => Self::Down, } } + /// Return next direction counterclockwise pub fn ccw (&self) -> Self { match self { Self::Up => Self::Left,