mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
layout lib is borked, testing with edn examples yields such wonders
This commit is contained in:
parent
eee10cc3eb
commit
07d90228d3
4 changed files with 46 additions and 41 deletions
|
|
@ -6,6 +6,8 @@ use crossterm::event::{*, KeyCode::*};
|
||||||
const EDN: &'static [&'static str] = &[
|
const EDN: &'static [&'static str] = &[
|
||||||
include_str!("edn01.edn"),
|
include_str!("edn01.edn"),
|
||||||
include_str!("edn02.edn"),
|
include_str!("edn02.edn"),
|
||||||
|
include_str!("edn03.edn"),
|
||||||
|
include_str!("edn04.edn"),
|
||||||
];
|
];
|
||||||
|
|
||||||
fn main () -> Usually<()> {
|
fn main () -> Usually<()> {
|
||||||
|
|
@ -29,9 +31,10 @@ impl EdnViewData<TuiOut> for &Example {
|
||||||
|
|
||||||
impl Content<TuiOut> for Example {
|
impl Content<TuiOut> for Example {
|
||||||
fn content (&self) -> impl Render<TuiOut> {
|
fn content (&self) -> impl Render<TuiOut> {
|
||||||
Bsp::a(
|
Bsp::a(Push::y(1, Align::n(format!("Example {}/{}:", self.0 + 1, EDN.len()))),
|
||||||
Push::xy(1, 1, Align::n(format!("Example {}/{}:", self.0 + 1, EDN.len()))),
|
Bsp::a(Push::y(2, Align::n(format!("{}", EDN[self.0]))),
|
||||||
EdnView::from_source(self, EDN[self.0])
|
Tui::bg(Color::Rgb(10,20,30), EdnView::from_source(self, EDN[self.0]))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
(fill/xy :hello-world)
|
||||||
1
tek/examples/edn04.edn
Normal file
1
tek/examples/edn04.edn
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
(fixed/xy 20 20 :hello-world)
|
||||||
|
|
@ -31,6 +31,43 @@ impl Arranger {
|
||||||
pub const LEFT_SEP: char = '▎';
|
pub const LEFT_SEP: char = '▎';
|
||||||
pub const TRACK_MIN_WIDTH: usize = 4;
|
pub const TRACK_MIN_WIDTH: usize = 4;
|
||||||
|
|
||||||
|
pub fn scenes_with_heights (&self, h: usize) -> impl Iterator<Item = (usize, &ArrangerScene, usize, usize)> {
|
||||||
|
let mut y = 0;
|
||||||
|
let editing = self.editing;
|
||||||
|
let (selected_track, selected_scene) = match self.selected {
|
||||||
|
ArrangerSelection::Clip(t, s) => (Some(t), Some(s)),
|
||||||
|
_ => (None, None)
|
||||||
|
};
|
||||||
|
self.scenes.iter().enumerate().map(move|(s, scene)|{
|
||||||
|
let active = editing && selected_track.is_some() && selected_scene == Some(s);
|
||||||
|
let height = if active { 15 } else { h };
|
||||||
|
let data = (s, scene, y, y + height);
|
||||||
|
y += height;
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
pub fn tracks_with_widths (&self)
|
||||||
|
-> impl Iterator<Item = (usize, &ArrangerTrack, usize, usize)>
|
||||||
|
{
|
||||||
|
let active = match self.selected {
|
||||||
|
ArrangerSelection::Track(t) => Some(t),
|
||||||
|
ArrangerSelection::Clip(t, _) => Some(t),
|
||||||
|
_ => None
|
||||||
|
};
|
||||||
|
Self::tracks_with_widths_static(self.tracks.as_slice(), active)
|
||||||
|
}
|
||||||
|
fn tracks_with_widths_static (tracks: &[ArrangerTrack], active: Option<usize>)
|
||||||
|
-> impl Iterator<Item = (usize, &ArrangerTrack, usize, usize)>
|
||||||
|
{
|
||||||
|
let mut x = 0;
|
||||||
|
tracks.iter().enumerate().map(move |(index, track)|{
|
||||||
|
let width = if Some(index) == active { 40 } else { track.width };
|
||||||
|
let data = (index, track, x, x + width);
|
||||||
|
x += width;
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn output_row_header <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
|
fn output_row_header <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
|
||||||
let fg = TuiTheme::g(192);
|
let fg = TuiTheme::g(192);
|
||||||
let bg = TuiTheme::g(48);
|
let bg = TuiTheme::g(48);
|
||||||
|
|
@ -108,22 +145,6 @@ impl Arranger {
|
||||||
})).boxed()).into()
|
})).boxed()).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scenes_with_heights (&self, h: usize) -> impl Iterator<Item = (usize, &ArrangerScene, usize, usize)> {
|
|
||||||
let mut y = 0;
|
|
||||||
let editing = self.editing;
|
|
||||||
let (selected_track, selected_scene) = match self.selected {
|
|
||||||
ArrangerSelection::Clip(t, s) => (Some(t), Some(s)),
|
|
||||||
_ => (None, None)
|
|
||||||
};
|
|
||||||
self.scenes.iter().enumerate().map(move|(s, scene)|{
|
|
||||||
let active = editing && selected_track.is_some() && selected_scene == Some(s);
|
|
||||||
let height = if active { 15 } else { h };
|
|
||||||
let data = (s, scene, y, y + height);
|
|
||||||
y += height;
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn scene_row_headers <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
|
fn scene_row_headers <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
|
||||||
(||{
|
(||{
|
||||||
let scenes_w = 16;//.max(SCENES_W_OFFSET + ArrangerScene::longest_name(&self.scenes) as u16);
|
let scenes_w = 16;//.max(SCENES_W_OFFSET + ArrangerScene::longest_name(&self.scenes) as u16);
|
||||||
|
|
@ -160,27 +181,6 @@ impl Arranger {
|
||||||
))).boxed()
|
))).boxed()
|
||||||
}).into()
|
}).into()
|
||||||
}
|
}
|
||||||
pub fn tracks_with_widths (&self)
|
|
||||||
-> impl Iterator<Item = (usize, &ArrangerTrack, usize, usize)>
|
|
||||||
{
|
|
||||||
let active = match self.selected {
|
|
||||||
ArrangerSelection::Track(t) => Some(t),
|
|
||||||
ArrangerSelection::Clip(t, _) => Some(t),
|
|
||||||
_ => None
|
|
||||||
};
|
|
||||||
Self::tracks_with_widths_static(self.tracks.as_slice(), active)
|
|
||||||
}
|
|
||||||
fn tracks_with_widths_static (tracks: &[ArrangerTrack], active: Option<usize>)
|
|
||||||
-> impl Iterator<Item = (usize, &ArrangerTrack, usize, usize)>
|
|
||||||
{
|
|
||||||
let mut x = 0;
|
|
||||||
tracks.iter().enumerate().map(move |(index, track)|{
|
|
||||||
let width = if Some(index) == active { 40 } else { track.width };
|
|
||||||
let data = (index, track, x, x + width);
|
|
||||||
x += width;
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
fn scene_row_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
|
fn scene_row_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
|
||||||
let editing = self.editing;
|
let editing = self.editing;
|
||||||
let (selected_track, selected_scene) = match self.selected {
|
let (selected_track, selected_scene) = match self.selected {
|
||||||
|
|
@ -459,7 +459,7 @@ fn phat_cell_3 <T: Content<TuiOut>> (
|
||||||
) -> impl Content<TuiOut> {
|
) -> impl Content<TuiOut> {
|
||||||
Bsp::s(phat_lo(middle, top),
|
Bsp::s(phat_lo(middle, top),
|
||||||
Bsp::n(phat_hi(middle, bottom),
|
Bsp::n(phat_hi(middle, bottom),
|
||||||
Fixed::y(1, Fill::x(Tui::bg(middle, field))),
|
Fill::y(Fill::x(Tui::bg(middle, field))),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue