wip: component refactor

This commit is contained in:
🪞👃🪞 2024-06-21 12:13:11 +03:00
parent 5082bf9fdf
commit c18aa2cbbd
14 changed files with 374 additions and 272 deletions

View file

@ -6,7 +6,7 @@ pub struct Launcher {
impl Launcher {
pub fn new (name: &str) -> Result<DynamicDevice<Self>, Box<dyn Error>> {
Ok(DynamicDevice::new(render, handle, Self {
Ok(DynamicDevice::new(render, handle, process, Self {
name: name.into(),
}))
}
@ -16,10 +16,23 @@ pub fn process (_: &mut Launcher, _: &Client, _: &ProcessScope) -> Control {
Control::Continue
}
pub fn render (_: &Launcher, _: &mut Buffer, _: Rect) -> Usually<Rect> {
Ok(Rect::default())
pub fn render (_: &Launcher, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
for i in 1..=8 {
buf.set_string(area.x + 2 + (i-1) * 10, area.y, format!("Track#{i} | "), Style::default())
}
for i in 0..=7 {
for j in 0..=7 {
buf.set_string(area.x + 2 + i * 10, area.y + 2 + j, format!("······· | "), Style::default().dim())
}
}
Ok(draw_box(buf, Rect {
x: area.x,
y: area.y - 1,
width: area.width,
height: 12
}))
}
pub fn handle (_: &mut Launcher, _: &AppEvent) -> Result<(), Box<dyn Error>> {
Ok(())
pub fn handle (_: &mut Launcher, _: &AppEvent) -> Usually<bool> {
Ok(false)
}