mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
add widget dynamic helper and Split::up
This commit is contained in:
parent
038451e2f4
commit
97af45b576
4 changed files with 47 additions and 17 deletions
|
|
@ -94,6 +94,10 @@ pub trait Area<N: Number>: 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],
|
||||
),
|
||||
Direction::Down => (
|
||||
[self.x(), self.y(), self.w(), a],
|
||||
[self.x(), self.y() + a, self.w(), self.h() - a],
|
||||
|
|
@ -817,6 +821,18 @@ impl<E: Engine, A: Widget<Engine = E>, B: Widget<Engine = E>> Split<E, A, B> {
|
|||
pub fn new (direction: Direction, proportion: E::Unit, a: A, b: B) -> Self {
|
||||
Self(direction, proportion, a, b, Default::default())
|
||||
}
|
||||
pub fn up (proportion: E::Unit, a: A, b: B) -> Self {
|
||||
Self(Direction::Up, proportion, a, b, Default::default())
|
||||
}
|
||||
pub fn down (proportion: E::Unit, a: A, b: B) -> Self {
|
||||
Self(Direction::Down, proportion, a, b, Default::default())
|
||||
}
|
||||
pub fn left (proportion: E::Unit, a: A, b: B) -> Self {
|
||||
Self(Direction::Left, proportion, a, b, Default::default())
|
||||
}
|
||||
pub fn right (proportion: E::Unit, a: A, b: B) -> Self {
|
||||
Self(Direction::Right, proportion, a, b, Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Engine, A: Widget<Engine = E>, B: Widget<Engine = E>> Widget for Split<E, A, B> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue