mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 12:46:42 +01:00
wip: borrow checker battles
This commit is contained in:
parent
1d4db3c629
commit
7fbb40fad6
38 changed files with 778 additions and 708 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use crate::*;
|
||||
use tek_core::Direction;
|
||||
|
||||
impl<'a> Render<TuiOutput<'a>, Rect> for Track {
|
||||
impl<'a> Render<TuiOutput<'a>, Rect> for Track<TuiOutput<'a>, Rect> {
|
||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
||||
TrackView {
|
||||
chain: Some(&self),
|
||||
|
|
@ -24,37 +24,37 @@ impl<'a> Render<TuiOutput<'a>, Rect> for Track {
|
|||
}.render(to)
|
||||
}
|
||||
}
|
||||
pub struct TrackView<'a> {
|
||||
pub chain: Option<&'a Track>,
|
||||
pub struct TrackView<'a, T, U> {
|
||||
pub chain: Option<&'a Track<T, U>>,
|
||||
pub direction: Direction,
|
||||
pub focused: bool,
|
||||
pub entered: bool,
|
||||
}
|
||||
impl<'a> Render<TuiOutput<'a>, Rect> for TrackView<'a> {
|
||||
impl<'a> Render<TuiOutput<'a>, Rect> for TrackView<'a, TuiOutput<'a>, Rect> {
|
||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
||||
if let Some(chain) = self.chain {
|
||||
match self.direction {
|
||||
Direction::Down => area.width = area.width.min(40),
|
||||
Direction::Right => area.width = area.width.min(10),
|
||||
Direction::Down => to.area.width = to.area.width.min(40),
|
||||
Direction::Right => to.area.width = to.area.width.min(10),
|
||||
_ => { unimplemented!() },
|
||||
}
|
||||
fill_bg(buf, area, Nord::bg_lo(self.focused, self.entered));
|
||||
fill_bg(to.buffer, 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);
|
||||
}
|
||||
let (area, areas) = split.render_areas(buf, area)?;
|
||||
let (area, areas) = split.render_areas(to)?;
|
||||
if self.focused && self.entered && areas.len() > 0 {
|
||||
Corners(Style::default().green().not_dim()).draw(buf, areas[0])?;
|
||||
Corners(Style::default().green().not_dim()).draw(to.buffer, areas[0])?;
|
||||
}
|
||||
Ok(area)
|
||||
Ok(Some(area))
|
||||
} else {
|
||||
let Rect { x, y, width, height } = area;
|
||||
let Rect { x, y, width, height } = to.area;
|
||||
let label = "No chain selected";
|
||||
let x = x + (width - label.len() as u16) / 2;
|
||||
let y = y + height / 2;
|
||||
label.blit(buf, x, y, Some(Style::default().dim().bold()))?;
|
||||
Ok(area)
|
||||
label.blit(to.buffer, x, y, Some(Style::default().dim().bold()))?;
|
||||
Ok(Some(to.area))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue