mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
wip: tui cleanup
This commit is contained in:
parent
df3dac183e
commit
14d619a10a
17 changed files with 345 additions and 306 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use crate::*;
|
||||
use tek_core::Direction;
|
||||
|
||||
impl<'a> Render<TuiOutput<'a>, Rect> for Track<TuiOutput<'a>, Rect> {
|
||||
impl<'a> Render<Tui> for Track<Tui> {
|
||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
||||
TrackView {
|
||||
chain: Some(&self),
|
||||
|
|
@ -30,15 +30,16 @@ pub struct TrackView<'a, T, U> {
|
|||
pub focused: bool,
|
||||
pub entered: bool,
|
||||
}
|
||||
impl<'a> Render<TuiOutput<'a>, Rect> for TrackView<'a, TuiOutput<'a>, Rect> {
|
||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
||||
impl<'a> Render<Tui> for TrackView<'a, Tui> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||
let mut area = to.area();
|
||||
if let Some(chain) = self.chain {
|
||||
match self.direction {
|
||||
Direction::Down => to.area.width = to.area.width.min(40),
|
||||
Direction::Right => to.area.width = to.area.width.min(10),
|
||||
Direction::Down => area.width = area.width.min(40),
|
||||
Direction::Right => area.width = area.width.min(10),
|
||||
_ => { unimplemented!() },
|
||||
}
|
||||
fill_bg(to.buffer, to.area, Nord::bg_lo(self.focused, self.entered));
|
||||
to.fill_bg(to.area(), Nord::bg_lo(self.focused, self.entered));
|
||||
let mut split = Split::new(self.direction);
|
||||
for device in chain.devices.as_slice().iter() {
|
||||
split = split.add_ref(device);
|
||||
|
|
@ -49,12 +50,12 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TrackView<'a, TuiOutput<'a>, Rect> {
|
|||
}
|
||||
Ok(Some(area))
|
||||
} else {
|
||||
let Rect { x, y, width, height } = to.area;
|
||||
let Rect { x, y, width, height } = area;
|
||||
let label = "No chain selected";
|
||||
let x = x + (width - label.len() as u16) / 2;
|
||||
let y = y + height / 2;
|
||||
label.blit(to.buffer, x, y, Some(Style::default().dim().bold()))?;
|
||||
Ok(Some(to.area))
|
||||
label.blit(to.buffer(), x, y, Some(Style::default().dim().bold()))?;
|
||||
Ok(Some(area))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue