wip: sequencer edit mode

This commit is contained in:
🪞👃🪞 2024-10-17 22:20:36 +03:00
parent eac8986548
commit 0af5f97244
5 changed files with 72 additions and 147 deletions

View file

@ -9,6 +9,11 @@ pub trait FocusGrid<T: Copy + PartialEq> {
let (x, y) = self.cursor();
&self.layout()[y][x]
}
fn focus (&mut self, target: T) {
while self.focused() != &target {
self.focus_next()
}
}
fn focus_up (&mut self) {
let layout = self.layout();
let (x, y) = self.cursor();

View file

@ -130,124 +130,52 @@ impl<N: Number> Area<N> for [N;4] {
}
pub trait Layout<E: Engine>: Widget<Engine = E> + Sized {
fn align_center (self) -> Align<Self> {
Align::Center(self)
}
fn align_w (self) -> Align<Self> {
Align::W(self)
}
fn align_e (self) -> Align<Self> {
Align::E(self)
}
fn align_x (self) -> Align<Self> {
Align::X(self)
}
fn align_y (self) -> Align<Self> {
Align::Y(self)
}
fn fixed_x (self, x: E::Unit) -> Fixed<E::Unit, Self> {
Fixed::X(x, self)
}
fn fixed_y (self, y: E::Unit) -> Fixed<E::Unit, Self> {
Fixed::Y(y, self)
}
fn fixed_xy (self, x: E::Unit, y: E::Unit) -> Fixed<E::Unit, Self> {
Fixed::XY(x, y, self)
}
fn min_x (self, x: E::Unit) -> Min<E::Unit, Self> {
Min::X(x, self)
}
fn min_y (self, y: E::Unit) -> Min<E::Unit, Self> {
Min::Y(y, self)
}
fn min_xy (self, x: E::Unit, y: E::Unit) -> Min<E::Unit, Self> {
Min::XY(x, y, self)
}
fn max_x (self, x: E::Unit) -> Max<E::Unit, Self> {
Max::X(x, self)
}
fn max_y (self, y: E::Unit) -> Max<E::Unit, Self> {
Max::Y(y, self)
}
fn max_xy (self, x: E::Unit, y: E::Unit) -> Max<E::Unit, Self> {
Max::XY(x, y, self)
}
fn push_x (self, x: E::Unit) -> Push<E::Unit, Self> {
Push::X(x, self)
}
fn push_y (self, y: E::Unit) -> Push<E::Unit, Self> {
Push::Y(y, self)
}
fn push_xy (self, x: E::Unit, y: E::Unit) -> Push<E::Unit, Self> {
Push::XY(x, y, self)
}
fn pull_x (self, x: E::Unit) -> Pull<E::Unit, Self> {
Pull::X(x, self)
}
fn pull_y (self, y: E::Unit) -> Pull<E::Unit, Self> {
Pull::Y(y, self)
}
fn pull_xy (self, x: E::Unit, y: E::Unit) -> Pull<E::Unit, Self> {
Pull::XY(x, y, self)
}
fn grow_x (self, x: E::Unit) -> Grow<E::Unit, Self> {
Grow::X(x, self)
}
fn grow_y (self, y: E::Unit) -> Grow<E::Unit, Self> {
Grow::Y(y, self)
}
fn grow_xy (self, x: E::Unit, y: E::Unit) -> Grow<E::Unit, Self> {
Grow::XY(x, y, self)
}
fn shrink_x (self, x: E::Unit) -> Shrink<E::Unit, Self> {
Shrink::X(x, self)
}
fn shrink_y (self, y: E::Unit) -> Shrink<E::Unit, Self> {
Shrink::Y(y, self)
}
fn shrink_xy (self, x: E::Unit, y: E::Unit) -> Shrink<E::Unit, Self> {
Shrink::XY(x, y, self)
}
fn inset_x (self, x: E::Unit) -> Inset<E::Unit, Self> {
Inset::X(x, self)
}
fn inset_y (self, y: E::Unit) -> Inset<E::Unit, Self> {
Inset::Y(y, self)
}
fn inset_xy (self, x: E::Unit, y: E::Unit) -> Inset<E::Unit, Self> {
Inset::XY(x, y, self)
}
fn outset_x (self, x: E::Unit) -> Outset<E::Unit, Self> {
Outset::X(x, self)
}
fn outset_y (self, y: E::Unit) -> Outset<E::Unit, Self> {
Outset::Y(y, self)
}
fn outset_xy (self, x: E::Unit, y: E::Unit) -> Outset<E::Unit, Self> {
Outset::XY(x, y, self)
}
fn fill_x (self) -> Fill<E, Self> {
Fill::X(self)
}
fn fill_y (self) -> Fill<E, Self> {
Fill::Y(self)
}
fn fill_xy (self) -> Fill<E, Self> {
Fill::XY(self)
}
fn debug (self) -> DebugOverlay<E, Self> {
DebugOverlay(self)
}
fn align_center (self) -> Align<Self> { Align::Center(self) }
fn align_nw (self) -> Align<Self> { Align::NW(self) }
fn align_w (self) -> Align<Self> { Align::W(self) }
fn align_sw (self) -> Align<Self> { Align::SW(self) }
fn align_ne (self) -> Align<Self> { Align::NE(self) }
fn align_e (self) -> Align<Self> { Align::E(self) }
fn align_se (self) -> Align<Self> { Align::SE(self) }
fn align_x (self) -> Align<Self> { Align::X(self) }
fn align_y (self) -> Align<Self> { Align::Y(self) }
fn fixed_x (self, x: E::Unit) -> Fixed<E::Unit, Self> { Fixed::X(x, self) }
fn fixed_y (self, y: E::Unit) -> Fixed<E::Unit, Self> { Fixed::Y(y, self) }
fn fixed_xy (self, x: E::Unit, y: E::Unit) -> Fixed<E::Unit, Self> { Fixed::XY(x, y, self) }
fn min_x (self, x: E::Unit) -> Min<E::Unit, Self> { Min::X(x, self) }
fn min_y (self, y: E::Unit) -> Min<E::Unit, Self> { Min::Y(y, self) }
fn min_xy (self, x: E::Unit, y: E::Unit) -> Min<E::Unit, Self> { Min::XY(x, y, self) }
fn max_x (self, x: E::Unit) -> Max<E::Unit, Self> { Max::X(x, self) }
fn max_y (self, y: E::Unit) -> Max<E::Unit, Self> { Max::Y(y, self) }
fn max_xy (self, x: E::Unit, y: E::Unit) -> Max<E::Unit, Self> { Max::XY(x, y, self) }
fn push_x (self, x: E::Unit) -> Push<E::Unit, Self> { Push::X(x, self) }
fn push_y (self, y: E::Unit) -> Push<E::Unit, Self> { Push::Y(y, self) }
fn push_xy (self, x: E::Unit, y: E::Unit) -> Push<E::Unit, Self> { Push::XY(x, y, self) }
fn pull_x (self, x: E::Unit) -> Pull<E::Unit, Self> { Pull::X(x, self) }
fn pull_y (self, y: E::Unit) -> Pull<E::Unit, Self> { Pull::Y(y, self) }
fn pull_xy (self, x: E::Unit, y: E::Unit) -> Pull<E::Unit, Self> { Pull::XY(x, y, self) }
fn grow_x (self, x: E::Unit) -> Grow<E::Unit, Self> { Grow::X(x, self) }
fn grow_y (self, y: E::Unit) -> Grow<E::Unit, Self> { Grow::Y(y, self) }
fn grow_xy (self, x: E::Unit, y: E::Unit) -> Grow<E::Unit, Self> { Grow::XY(x, y, self) }
fn shrink_x (self, x: E::Unit) -> Shrink<E::Unit, Self> { Shrink::X(x, self) }
fn shrink_y (self, y: E::Unit) -> Shrink<E::Unit, Self> { Shrink::Y(y, self) }
fn shrink_xy (self, x: E::Unit, y: E::Unit) -> Shrink<E::Unit, Self> { Shrink::XY(x, y, self) }
fn inset_x (self, x: E::Unit) -> Inset<E::Unit, Self> { Inset::X(x, self) }
fn inset_y (self, y: E::Unit) -> Inset<E::Unit, Self> { Inset::Y(y, self) }
fn inset_xy (self, x: E::Unit, y: E::Unit) -> Inset<E::Unit, Self> { Inset::XY(x, y, self) }
fn outset_x (self, x: E::Unit) -> Outset<E::Unit, Self> { Outset::X(x, self) }
fn outset_y (self, y: E::Unit) -> Outset<E::Unit, Self> { Outset::Y(y, self) }
fn outset_xy (self, x: E::Unit, y: E::Unit) -> Outset<E::Unit, Self> { Outset::XY(x, y, self) }
fn fill_x (self) -> Fill<E, Self> { Fill::X(self) }
fn fill_y (self) -> Fill<E, Self> { Fill::Y(self) }
fn fill_xy (self) -> Fill<E, Self> { Fill::XY(self) }
fn debug (self) -> DebugOverlay<E, Self> { DebugOverlay(self) }
fn split <W: Widget<Engine = E>> (
self, direction: Direction, amount: E::Unit, other: W
) -> Split<E, Self, W> {
Split::new(direction, amount, self, other)
}
) -> Split<E, Self, W> { Split::new(direction, amount, self, other) }
fn split_flip <W: Widget<Engine = E>> (
self, direction: Direction, amount: E::Unit, other: W
) -> Split<E, W, Self> {
Split::new(direction, amount, other, self)
}
) -> Split<E, W, Self> { Split::new(direction, amount, other, self) }
}
impl<E: Engine, W: Widget<Engine = E>> Layout<E> for W {}