mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: fixing some assumptions
This commit is contained in:
parent
5ae99b4ada
commit
2a60808239
11 changed files with 73 additions and 125 deletions
|
|
@ -2,39 +2,26 @@ use crate::*;
|
|||
use tek_core::Direction;
|
||||
|
||||
pub struct ChainView<'a> {
|
||||
pub track: Option<&'a Chain>,
|
||||
pub chain: Option<&'a Chain>,
|
||||
pub direction: Direction,
|
||||
pub focused: bool,
|
||||
pub entered: bool,
|
||||
}
|
||||
|
||||
impl<'a> ChainView<'a> {
|
||||
pub fn horizontal (app: &'a App) -> Self {
|
||||
Self::new(app, Direction::Right)
|
||||
}
|
||||
pub fn vertical (app: &'a App) -> Self {
|
||||
Self::new(app, Direction::Down)
|
||||
}
|
||||
pub fn new (app: &'a App, direction: Direction) -> Self {
|
||||
Self {
|
||||
direction,
|
||||
entered: app.entered,
|
||||
focused: app.section == AppFocus::Chain,
|
||||
track: app.arranger.track()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render for ChainView<'a> {
|
||||
fn render (&self, buf: &mut Buffer, mut area: Rect) -> Usually<Rect> {
|
||||
if let Some(track) = self.track {
|
||||
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),
|
||||
}
|
||||
fill_bg(buf, area, Nord::bg_lo(self.focused, self.entered));
|
||||
let devices: Vec<&(dyn Render + Send + Sync)> = chain.devices.as_slice()
|
||||
.iter()
|
||||
.map(|d|d as &(dyn Render + Send + Sync))
|
||||
.collect();
|
||||
let (area, areas) = self.direction
|
||||
.split_focus(0, track.devices.as_slice(), if self.focused {
|
||||
.split_focus(0, devices.as_slice(), if self.focused {
|
||||
Style::default().green().dim()
|
||||
} else {
|
||||
Style::default().dim()
|
||||
|
|
@ -46,7 +33,7 @@ impl<'a> Render for ChainView<'a> {
|
|||
Ok(area)
|
||||
} else {
|
||||
let Rect { x, y, width, height } = area;
|
||||
let label = "No track selected";
|
||||
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()))?;
|
||||
|
|
@ -55,4 +42,19 @@ impl<'a> Render for ChainView<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//impl<'a> ChainView<'a> {
|
||||
//pub fn horizontal (app: &'a App) -> Self {
|
||||
//Self::new(app, Direction::Right)
|
||||
//}
|
||||
//pub fn vertical (app: &'a App) -> Self {
|
||||
//Self::new(app, Direction::Down)
|
||||
//}
|
||||
//pub fn new (app: &'a App, direction: Direction) -> Self {
|
||||
//Self {
|
||||
//direction,
|
||||
//entered: app.entered,
|
||||
//focused: app.section == AppFocus::Chain,
|
||||
//chain: app.arranger.chain()
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue