mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
prevent crash in split_fixed
This commit is contained in:
parent
be7501b08c
commit
d94aa8c8ac
1 changed files with 12 additions and 21 deletions
|
|
@ -133,16 +133,16 @@ pub trait Area<N: Coordinate>: 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<Engine = _>) -> Result<(), Box<...>>) -> ... ) + Send + Sync>`
|
||||
//`Layers<Tui, impl (Fn(&mut dyn FnMut(&dyn Widget<Engine = Tui>) -> 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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue