mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-13 15:16:41 +01:00
don't crash on add track/scene
This commit is contained in:
parent
5a9ec0a63d
commit
6a738375e2
9 changed files with 205 additions and 207 deletions
|
|
@ -1,6 +1,4 @@
|
|||
use crate::core::*;
|
||||
use crate::model::*;
|
||||
use crate::view::{*, Direction};
|
||||
use crate::{core::*, model::*, view::*};
|
||||
|
||||
pub struct ChainView<'a> {
|
||||
pub track: Option<&'a Track>,
|
||||
|
|
@ -58,42 +56,3 @@ impl<'a> Render for ChainView<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
type Renderables<'a> = &'a [JackDevice];
|
||||
|
||||
impl<'a> Direction {
|
||||
fn split_focus (&self, index: usize, items: Renderables<'a>, style: Style) -> SplitFocus<'a> {
|
||||
SplitFocus(*self, index, items, style)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SplitFocus<'a>(pub Direction, pub usize, pub Renderables<'a>, pub Style);
|
||||
|
||||
impl<'a> Render for SplitFocus<'a> {
|
||||
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let Rect { mut x, mut y, mut width, mut height } = area;
|
||||
let mut results = vec![];
|
||||
for item in self.2.iter() {
|
||||
if width == 0 || height == 0 {
|
||||
break
|
||||
}
|
||||
let result = item.render(buf, Rect { x, y, width, height })?;
|
||||
results.push(result);
|
||||
match self.0 {
|
||||
Direction::Down => {
|
||||
y = y + result.height;
|
||||
height = height.saturating_sub(result.height);
|
||||
},
|
||||
Direction::Right => {
|
||||
x = x + result.width;
|
||||
width = width.saturating_sub(result.width);
|
||||
},
|
||||
}
|
||||
}
|
||||
results
|
||||
.get(self.1)
|
||||
.map(|focused|Lozenge(self.3).draw(buf, Rect { width, ..*focused }))
|
||||
.transpose()?;
|
||||
Ok(area)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue