mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
switch between sequences; layout unfucking
This commit is contained in:
parent
c18aa2cbbd
commit
185c6b5b34
7 changed files with 253 additions and 201 deletions
|
|
@ -5,6 +5,14 @@ pub struct Chain {
|
|||
focused: bool,
|
||||
focus: usize,
|
||||
items: Vec<Box<dyn Device>>,
|
||||
view: ChainView
|
||||
}
|
||||
|
||||
pub enum ChainView {
|
||||
Hidden,
|
||||
Compact,
|
||||
Row,
|
||||
Column,
|
||||
}
|
||||
|
||||
impl Chain {
|
||||
|
|
@ -14,6 +22,7 @@ impl Chain {
|
|||
focused: false,
|
||||
focus: 0,
|
||||
items,
|
||||
view: ChainView::Column
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
@ -26,44 +35,60 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
|||
-> Usually<Rect>
|
||||
{
|
||||
let Rect { x, y, .. } = area;
|
||||
let area = Rect { x, y, width: 40, height: 30 };
|
||||
let mut y = area.y;
|
||||
buf.set_string(area.x, y, "│", Style::default().black());
|
||||
buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
|
||||
buf.set_string(area.x + 2, y, "Input...", Style::default().dim());
|
||||
let mut x = 0u16;
|
||||
for (i, device) in state.items.iter().enumerate() {
|
||||
let result = device.render(buf, Rect {
|
||||
x: area.x,
|
||||
y,
|
||||
width: area.width,
|
||||
height: 21//area.height.saturating_sub(y)
|
||||
})?;
|
||||
if i == state.focus {
|
||||
if state.focused {
|
||||
draw_box_styled(buf, result, Some(Style::default().green().not_dim()))
|
||||
} else {
|
||||
draw_box_styled_dotted(buf, result, Some(Style::default().green().dim()))
|
||||
};
|
||||
};
|
||||
//let result = Rect { x: 0, y: 0, width: result.width, height: 21 };
|
||||
x = x.max(result.width);
|
||||
y = y + result.height;
|
||||
Ok(match state.view {
|
||||
ChainView::Hidden => Rect { x, y, width: 0, height: 0 },
|
||||
ChainView::Compact => {
|
||||
let area = Rect { x, y, width: (state.name.len() + 4) as u16, height: 3 };
|
||||
buf.set_string(area.x + 2, area.y + 1, &state.name, Style::default());
|
||||
draw_box_styled(buf, area, Some(Style::default().dim()))
|
||||
},
|
||||
ChainView::Row => {
|
||||
let (area, areas) = draw_row(&state.items, buf, area, 0)?;
|
||||
draw_box_styled(buf, area, Some(Style::default().dim()))
|
||||
},
|
||||
ChainView::Column => {
|
||||
let (area, areas) = draw_column(&state.items, buf, area, 0)?;
|
||||
draw_box_styled(buf, area, Some(Style::default().dim()))
|
||||
},
|
||||
})
|
||||
//let area = Rect { x, y, width: 40, height: 30 };
|
||||
//let mut y = area.y;
|
||||
//buf.set_string(area.x, y, "│", Style::default().black());
|
||||
//buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
|
||||
//buf.set_string(area.x + 2, y, "Input...", Style::default().dim());
|
||||
//let mut x = 0u16;
|
||||
//for (i, device) in state.items.iter().enumerate() {
|
||||
//let result = device.render(buf, Rect {
|
||||
//x: area.x,
|
||||
//y,
|
||||
//width: area.width,
|
||||
//height: 21//area.height.saturating_sub(y)
|
||||
//})?;
|
||||
//if i == state.focus {
|
||||
//if state.focused {
|
||||
//draw_box_styled(buf, result, Some(Style::default().green().not_dim()))
|
||||
//} else {
|
||||
//draw_box_styled_dotted(buf, result, Some(Style::default().green().dim()))
|
||||
//};
|
||||
//};
|
||||
////let result = Rect { x: 0, y: 0, width: result.width, height: 21 };
|
||||
//x = x.max(result.width);
|
||||
//y = y + result.height;
|
||||
////y = y + 1;
|
||||
//buf.set_string(area.x, y, "│", Style::default().black());
|
||||
//buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
|
||||
//buf.set_string(area.x + 2, y, " Patch in ┐ │ └ Patch out", Style::default().dim());
|
||||
//y = y + 1;
|
||||
buf.set_string(area.x, y, "│", Style::default().black());
|
||||
buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
|
||||
buf.set_string(area.x + 2, y, " Patch in ┐ │ └ Patch out", Style::default().dim());
|
||||
y = y + 1;
|
||||
//buf.set_string(area.x, y, format!("{y}---BOT---"), Style::default().red());
|
||||
//buf.set_string(area.x + area.width - 1, area.y + 1, "│", Style::default().black());
|
||||
//buf.set_string(area.x + 2, y, "Patch...", Style::default().dim());
|
||||
}
|
||||
Ok(draw_box(buf, Rect {
|
||||
x: area.x,
|
||||
y: area.y,
|
||||
width: area.width,
|
||||
height: y - area.y,
|
||||
}))
|
||||
////buf.set_string(area.x, y, format!("{y}---BOT---"), Style::default().red());
|
||||
////buf.set_string(area.x + area.width - 1, area.y + 1, "│", Style::default().black());
|
||||
////buf.set_string(area.x + 2, y, "Patch...", Style::default().dim());
|
||||
//}
|
||||
//Ok(draw_box(buf, Rect {
|
||||
//x: area.x,
|
||||
//y: area.y,
|
||||
//width: area.width,
|
||||
//height: y - area.y,
|
||||
//}))
|
||||
}
|
||||
|
||||
impl Focus for Chain {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue