diff --git a/crates/tek_sequencer/src/arranger_tui.rs b/crates/tek_sequencer/src/arranger_tui.rs index dfd685a3..23227827 100644 --- a/crates/tek_sequencer/src/arranger_tui.rs +++ b/crates/tek_sequencer/src/arranger_tui.rs @@ -102,14 +102,11 @@ impl Content for ArrangerStatusBar { row!(mode, commands) } } -fn command ( - commands: &[[impl Widget;3]] -) -> impl Widget + '_ { +fn command (commands: &[[impl Widget;3]]) -> impl Widget + '_ { Stack::right(|add|{ - for [a, b, c] in commands.iter() { + Ok(for [a, b, c] in commands.iter() { add(&row!(" ", widget(a), widget(b).bold(true).fg(Color::Rgb(255,255,0)), widget(c)))?; - } - Ok(()) + }) }) } impl Content for Arrangement { @@ -263,10 +260,7 @@ impl<'a> Content for VerticalArranger<'a, Tui> { let mut scene_area: Option<[u16;4]> = None; let mut clip_area: Option<[u16;4]> = None; let area = match selected { - ArrangementFocus::Mix => { - //if focused { to.fill_bg(area, Color::Rgb(40, 50, 30)); } - area - }, + ArrangementFocus::Mix => area, ArrangementFocus::Track(t) => { track_area = Some(get_track_area(t)); area }, ArrangementFocus::Scene(s) => { scene_area = Some(get_scene_area(s)); area }, ArrangementFocus::Clip(t, s) => { @@ -284,21 +278,12 @@ impl<'a> Content for VerticalArranger<'a, Tui> { to.fill_ul([area.x(), y - 1, area.w(), 1], Color::Rgb(70, 80, 50)); to.fill_ul([area.x(), y + height - 1, area.w(), 1], Color::Rgb(70, 80, 50)); } - if focused { - if let Some(clip_area) = clip_area { - to.render_in(clip_area, &CORNERS)?; - //to.fill_bg(clip_area, Color::Rgb(40, 50, 30)); - } else if let Some(track_area) = track_area { - to.render_in(track_area.clip_h(track_title_h), &CORNERS)?; - //to.fill_bg(track_area, Color::Rgb(40, 50, 30)); - } else if let Some(scene_area) = scene_area { - to.render_in(scene_area.clip_w(scene_title_w), &CORNERS)?; - //to.fill_bg(scene_area, Color::Rgb(40, 50, 30)); - } else { - to.render_in(area.clip_w(scene_title_w).clip_h(track_title_h), &CORNERS)?; - } - } - Ok(()) + Ok(if focused { + to.render_in(if let Some(clip_area) = clip_area { clip_area } + else if let Some(track_area) = track_area { track_area.clip_h(track_title_h) } + else if let Some(scene_area) = scene_area { scene_area.clip_w(scene_title_w) } + else { area.clip_w(scene_title_w).clip_h(track_title_h) }, &CORNERS)? + }) })) }).bg(bg).grow_y(1).border(border); let title_color = if self.0.focused { @@ -488,7 +473,7 @@ impl<'a> Content for HorizontalArranger<'a, Tui> { let area = to.area(); let mut x2 = 0; let [x, y, _, height] = area; - for (scene_index, scene) in scenes.iter().enumerate() { + Ok(for (scene_index, scene) in scenes.iter().enumerate() { let active_scene = selected.scene() == Some(scene_index); let sep = Some(if active_scene { Style::default().yellow().not_dim() @@ -515,9 +500,7 @@ impl<'a> Content for HorizontalArranger<'a, Tui> { } } x2 = x2 + x3 + 1; - } - //Ok(Some([x, y, x2, height])) - Ok(()) + }) }), ) ) diff --git a/crates/tek_sequencer/src/sequencer_tui.rs b/crates/tek_sequencer/src/sequencer_tui.rs index cc4f03c2..64be6726 100644 --- a/crates/tek_sequencer/src/sequencer_tui.rs +++ b/crates/tek_sequencer/src/sequencer_tui.rs @@ -34,8 +34,7 @@ impl Content for PhrasePool { let row2 = TuiStyle::bold(row2, true); let bg = if i == self.phrase { color } else { color }; add(&col!(row1, row2).fill_x().bg(bg))?; - if *focused && i == self.phrase { add(&CORNERS)?; } - Ok(()) + Ok(if *focused && i == self.phrase { add(&CORNERS)?; }) }) ); let border_color = if *focused {Color::Rgb(100, 110, 40)} else {Color::Rgb(70, 80, 50)}; @@ -44,7 +43,7 @@ impl Content for PhrasePool { let title_color = if *focused {Color::Rgb(150, 160, 90)} else {Color::Rgb(120, 130, 100)}; let title = format!("Phrases ({})", phrases.len()); let title = TuiStyle::fg(title, title_color).push_x(1); - Layers::new(move|add|{ add(&content)?; add(&title)?; Ok(()) }) + Layers::new(move|add|{ add(&content)?; Ok(add(&title)?) }) } } impl Content for PhraseEditor { @@ -60,15 +59,14 @@ impl Content for PhraseEditor { let color = Color::Rgb(0,255,0); let color = phrase.as_ref().map(|p|p.read().unwrap().color).unwrap_or(color); let keys = CustomWidget::new(|to:[u16;2]|Ok(Some(to.clip_w(5))), move|to: &mut TuiOutput|{ - if to.area().h() >= 2 { + Ok(if to.area().h() >= 2 { to.buffer_update(to.area().set_w(5), &|cell, x, y|{ let y = y + (note_start / 2) as u16; if x < keys.area.width && y < keys.area.height { *cell = keys.get(x, y).clone() } }); - } - Ok(()) + }) }).fill_y(); let notes_bg_null = Color::Rgb(28, 35, 25); let notes = CustomWidget::new(|to|Ok(Some(to)), move|to: &mut TuiOutput|{ @@ -82,7 +80,7 @@ impl Content for PhraseEditor { axis.start += 2; } } - if to.area().h() >= 2 { + Ok(if to.area().h() >= 2 { let area = to.area(); to.buffer_update(area, &move |cell, x, y|{ cell.set_bg(notes_bg_null); @@ -96,11 +94,10 @@ impl Content for PhraseEditor { }); } }); - } - Ok(()) + }) }).fill_x(); let cursor = CustomWidget::new(|to|Ok(Some(to)), move|to: &mut TuiOutput|{ - if *entered { + Ok(if *entered { let area = to.area(); if let (Some(time), Some(note)) = (time_point, note_point) { let x1 = area.x() + (time / time_scale) as u16; @@ -111,8 +108,7 @@ impl Content for PhraseEditor { to.blit(&c, x, y, Some(Style::default().fg(color))); } } - } - Ok(()) + }) }); let playhead_inactive = Style::default().fg(Color::Rgb(255,255,255)).bg(Color::Rgb(0,0,0)); let playhead_active = playhead_inactive.clone().yellow().bold().not_dim();