mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: layout
This commit is contained in:
parent
ac865824cc
commit
d627d257ad
13 changed files with 220 additions and 131 deletions
|
|
@ -15,7 +15,7 @@ impl Chain {
|
|||
}
|
||||
|
||||
pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
||||
-> Usually<(u16, u16)>
|
||||
-> Usually<Rect>
|
||||
{
|
||||
let Rect { x, y, width, height } = area;
|
||||
let area = Rect { x, y, width: 40, height: 30 };
|
||||
|
|
@ -26,25 +26,25 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
|||
let mut x = 0u16;
|
||||
y = y + 1;
|
||||
for device in state.devices.iter() {
|
||||
let (w, h) = device.render(buf, Rect {
|
||||
let result = device.render(buf, Rect {
|
||||
x: area.x,
|
||||
y: area.y + y,
|
||||
width: area.width,
|
||||
height: area.height - y
|
||||
height: area.height.saturating_sub(y)
|
||||
})?;
|
||||
//buf.set_string(area.x, y, format!("{y}---TOP---+{h}"), Style::default().red());
|
||||
x = x.max(w);
|
||||
y = y + h;
|
||||
x = x.max(result.width);
|
||||
y = y + result.height;
|
||||
y = y + 1;
|
||||
buf.set_string(area.x, y, "│", Style::default().black());
|
||||
buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
|
||||
buf.set_string(area.x + 2, y, "Patch in... │ Patch out...", Style::default().dim());
|
||||
buf.set_string(area.x + 2, y, " Patch in ┐ │ └ Patch out", Style::default().dim());
|
||||
y = y + 1;
|
||||
//buf.set_string(area.x, y, format!("{y}---BOT---"), Style::default().red());
|
||||
//buf.set_string(area.x + area.width - 1, area.y + 1, "│", Style::default().black());
|
||||
//buf.set_string(area.x + 2, y, "Patch...", Style::default().dim());
|
||||
}
|
||||
Ok((x, y))
|
||||
Ok(Rect { x: area.x, y: area.y, width: x, height: y })
|
||||
}
|
||||
|
||||
pub fn handle (state: &mut Chain, event: &EngineEvent) -> Result<(), Box<dyn Error>> {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@ impl Launcher {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn render (state: &Launcher, buf: &mut Buffer, area: Rect) {}
|
||||
pub fn render (state: &Launcher, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
Ok(Rect::default())
|
||||
}
|
||||
|
||||
pub fn handle (state: &mut Launcher, event: &Event) -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ impl Looper {
|
|||
}
|
||||
|
||||
pub fn render (state: &Looper, buf: &mut Buffer, area: Rect)
|
||||
-> Usually<(u16, u16)>
|
||||
-> Usually<Rect>
|
||||
{
|
||||
//let move_to = |col, row| MoveTo(offset.0 + col, offset.1 + row);
|
||||
//stdout
|
||||
|
|
@ -22,7 +22,7 @@ pub fn render (state: &Looper, buf: &mut Buffer, area: Rect)
|
|||
//.queue(move_to(0, 2))?.queue(PrintStyledContent(" Loop 1 [ ] ████ Track 1".bold()))?
|
||||
//.queue(move_to(0, 3))?.queue(PrintStyledContent(" Loop 2 [ ] ████████ Track 2".bold()))?
|
||||
//.queue(move_to(0, 4))?.queue(PrintStyledContent(" Loop 3 [ ] ████████ Track 3".bold()))?;
|
||||
Ok((20, 10))
|
||||
Ok(Rect::default())
|
||||
}
|
||||
|
||||
pub fn handle (state: &mut Looper, event: &EngineEvent) -> Result<(), Box<dyn Error>> {
|
||||
|
|
|
|||
|
|
@ -42,10 +42,10 @@ impl Mixer {
|
|||
}
|
||||
|
||||
pub fn render (state: &Mixer, buf: &mut Buffer, mut area: Rect)
|
||||
-> Usually<(u16, u16)>
|
||||
-> Usually<Rect>
|
||||
{
|
||||
if area.height < 2 {
|
||||
return Ok((0, 0))
|
||||
return Ok(area)
|
||||
}
|
||||
area.x = area.width.saturating_sub(80) / 2;
|
||||
area.width = area.width.min(80);
|
||||
|
|
@ -87,7 +87,7 @@ pub fn render (state: &Mixer, buf: &mut Buffer, mut area: Rect)
|
|||
//fn render_meters (
|
||||
//state: &mut Mixer,
|
||||
//stdout: &mut Stdout,
|
||||
//offset: (u16, u16)
|
||||
//offset: Rect
|
||||
//) -> Result<(), Box<dyn Error>> {
|
||||
//let move_to = |col, row| crossterm::cursor::MoveTo(offset.0 + col, offset.1 + row);
|
||||
//for (i, track) in state.tracks.iter().enumerate() {
|
||||
|
|
@ -102,7 +102,7 @@ pub fn render (state: &Mixer, buf: &mut Buffer, mut area: Rect)
|
|||
//}
|
||||
}
|
||||
}
|
||||
Ok((20,10))
|
||||
Ok(area)
|
||||
}
|
||||
|
||||
pub fn handle (state: &mut Mixer, event: &EngineEvent) -> Result<(), Box<dyn Error>> {
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ impl Plugin {
|
|||
}
|
||||
|
||||
pub fn render (state: &Plugin, buf: &mut Buffer, Rect { x, y, width, height }: Rect)
|
||||
-> Usually<(u16, u16)>
|
||||
-> Usually<Rect>
|
||||
{
|
||||
let style = Style::default().gray();
|
||||
draw_box(buf, Rect { x, y: y, width: 40, height: 8 });
|
||||
draw_box(buf, Rect { x, y, width: 40, height: 8 });
|
||||
buf.set_string(x + 1, y + 1, &format!(" {}", state.name), style.white().bold());
|
||||
buf.set_string(x + 13, y + 1, &format!("│ Plugin Name"), style.not_dim());
|
||||
buf.set_string(x + 0, y + 2, &format!("├--------------------------------------┤"), style.dim());
|
||||
|
|
@ -24,7 +24,7 @@ pub fn render (state: &Plugin, buf: &mut Buffer, Rect { x, y, width, height }: R
|
|||
buf.set_string(x + 1, y + 4, &format!(" Parameter 2 0.0"), style);
|
||||
buf.set_string(x + 1, y + 5, &format!(" Parameter 3 0.0"), style);
|
||||
buf.set_string(x + 1, y + 6, &format!(" Parameter 4 0.0"), style);
|
||||
Ok((40, 7))
|
||||
Ok(Rect { x, y, width: 40, height: 7 })
|
||||
}
|
||||
|
||||
pub fn handle (state: &mut Plugin, event: &EngineEvent) -> Result<(), Box<dyn Error>> {
|
||||
|
|
|
|||
|
|
@ -107,28 +107,28 @@ impl Sample {
|
|||
}
|
||||
|
||||
pub fn render (state: &Sampler, buf: &mut Buffer, Rect { x, y, width, height }: Rect)
|
||||
-> Usually<(u16, u16)>
|
||||
-> Usually<Rect>
|
||||
{
|
||||
let style = Style::default().gray();
|
||||
draw_box(buf, Rect { x, y: y, width: 40, height: 12 });
|
||||
buf.set_string(x + 1, y + 1, &format!(" {} │", state.name), style.white().bold());
|
||||
buf.set_string(x + 0, y + 2, &format!("├--------------------------------------┤"), style.dim());
|
||||
buf.set_string(x + 2, y + 3, &format!("C0 Sample#000"), style.bold());
|
||||
buf.set_string(x + 2, y + 3, &format!("C4 Sample#000"), style.bold());
|
||||
buf.set_string(x + 2, y + 4, &format!(" {:.03}s",
|
||||
100000.0/44100.0), style);
|
||||
buf.set_string(x + 2, y + 5, &format!("C#0 Sample#001"), style.bold());
|
||||
buf.set_string(x + 2, y + 5, &format!("C#4 Sample#001"), style.bold());
|
||||
buf.set_string(x + 2, y + 6, &format!(" {:.03}-{:.03}s",
|
||||
50000.0/44100.0, 100000.0/44100.0), style);
|
||||
buf.set_string(x + 2, y + 7, &format!("D0 Sample#002"), style.bold());
|
||||
buf.set_string(x + 2, y + 7, &format!("D4 Sample#002"), style.bold());
|
||||
buf.set_string(x + 2, y + 8, &format!(" {:.03}-{:.03}/{:.03}s",
|
||||
0.0, 50000.0/44100.0, 100000.0/44100.0), style);
|
||||
buf.set_string(x + 2, y + 9, &format!("D#0 Sample#003"), style.bold());
|
||||
buf.set_string(x + 2, y + 9, &format!("D#4 Sample#003"), style.bold());
|
||||
buf.set_string(x + 2, y + 10, &format!(" {:.03}-[{:.03}-{:.03}]/{:.03}s ",
|
||||
10000.0/44100.0, 25000.0/44100.0, 50000.0/44100.0, 100000.0/44100.0), style);
|
||||
//buf.set_string(x + 1, y + 7 + 6, &format!(" Inputs... │ Outputs... "), style.dim());
|
||||
//render_table(state, stdout, offset)?;
|
||||
//render_meters(state, stdout, offset)?;
|
||||
Ok((40, 11))
|
||||
Ok(Rect { x, y, width: 40, height: 11 })
|
||||
}
|
||||
|
||||
//fn render_table (
|
||||
|
|
|
|||
|
|
@ -206,52 +206,65 @@ const KEYS_VERTICAL: [&'static str; 6] = [
|
|||
];
|
||||
|
||||
fn render (sequencer: &Sequencer, buf: &mut Buffer, mut area: Rect)
|
||||
-> Usually<(u16, u16)>
|
||||
-> Usually<Rect>
|
||||
{
|
||||
let style = Style::default().gray();
|
||||
area.height = 18;
|
||||
let header = draw_sequencer_header(sequencer, buf, area)?;
|
||||
let piano = draw_sequencer_vertical(sequencer, buf, Rect {
|
||||
x: area.x,
|
||||
y: area.y + header.height,
|
||||
width: area.width,
|
||||
height: area.height - header.height
|
||||
})?;
|
||||
let area = Rect {
|
||||
x: area.x,
|
||||
y: area.y,
|
||||
width: header.width.max(piano.width),
|
||||
height: header.height + piano.height
|
||||
};
|
||||
//draw_box_styled(buf, area, Some(Style::default().red()));
|
||||
Ok(area)
|
||||
}
|
||||
|
||||
fn draw_sequencer_header (sequencer: &Sequencer, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let Rect { x, y, width, height } = area;
|
||||
let style = Style::default().gray();
|
||||
buf.set_string(x + 1, y + 1, &format!(" │ 00:00.00 / 00:00.00"), style);
|
||||
buf.set_string(x + 2, y + 1, &format!("{}", &sequencer.name), style.white().bold());
|
||||
buf.set_string(x + 1, y + 2, &format!(" ▶ PLAY │ ⏹ STOP │ ⏺ REC │ ⏺ DUB "), style);
|
||||
//buf.set_string(x + 1, y + 6, &format!(" │ Outputs... "), style.dim());
|
||||
Ok(Rect { x, y, width, height: 4 })
|
||||
}
|
||||
|
||||
let mut h = 9;
|
||||
let toggle = true;
|
||||
if toggle {
|
||||
for i in 0..16 {
|
||||
buf.set_string(x + 2, y + 4 + i, &format!(" "), Style::default().on_black());
|
||||
h = h + 1;
|
||||
}
|
||||
fn draw_sequencer_vertical (sequencer: &Sequencer, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let Rect { x, y, .. } = area;
|
||||
let white = Style::default().gray();
|
||||
let black = Style::default().black();
|
||||
for i in 0..area.width-4 {
|
||||
let color = match i % 12 {
|
||||
0 => white,
|
||||
1 => black,
|
||||
2 => white,
|
||||
3 => black,
|
||||
4 => white,
|
||||
5 => white,
|
||||
6 => black,
|
||||
7 => white,
|
||||
8 => black,
|
||||
9 => white,
|
||||
10 => black,
|
||||
11 => white,
|
||||
_ => unreachable!()
|
||||
};
|
||||
buf.set_string(x + 2 + i, y - 1, &format!("▄"), color);
|
||||
buf.set_string(x + 2 + i, y, &format!("▀"), color);
|
||||
}
|
||||
for i in 0..3 {
|
||||
buf.set_string(1 + i * 12 + x + 1, y + h - 5, &format!("▄"), Style::default().white());
|
||||
buf.set_string(1 + i * 12 + x + 2, y + h - 5, &format!("▄"), Style::default().black());
|
||||
buf.set_string(1 + i * 12 + x + 3, y + h - 5, &format!("▄"), Style::default().white());
|
||||
buf.set_string(1 + i * 12 + x + 4, y + h - 5, &format!("▄"), Style::default().black());
|
||||
buf.set_string(1 + i * 12 + x + 5, y + h - 5, &format!("▄"), Style::default().white());
|
||||
buf.set_string(1 + i * 12 + x + 6, y + h - 5, &format!("▄"), Style::default().white());
|
||||
buf.set_string(1 + i * 12 + x + 7, y + h - 5, &format!("▄"), Style::default().black());
|
||||
buf.set_string(1 + i * 12 + x + 8, y + h - 5, &format!("▄"), Style::default().white());
|
||||
buf.set_string(1 + i * 12 + x + 9, y + h - 5, &format!("▄"), Style::default().black());
|
||||
buf.set_string(1 + i * 12 + x + 10, y + h - 5, &format!("▄"), Style::default().white());
|
||||
buf.set_string(1 + i * 12 + x + 11, y + h - 5, &format!("▄"), Style::default().black());
|
||||
buf.set_string(1 + i * 12 + x + 12, y + h - 5, &format!("▄"), Style::default().white());
|
||||
buf.set_string(1 + i * 12 + x + 1, y + h - 4, &format!("▀"), Style::default().white());
|
||||
buf.set_string(1 + i * 12 + x + 2, y + h -4, &format!("▀"), Style::default().black());
|
||||
buf.set_string(1 + i * 12 + x + 3, y + h -4, &format!("▀"), Style::default().white());
|
||||
buf.set_string(1 + i * 12 + x + 4, y + h -4, &format!("▀"), Style::default().black());
|
||||
buf.set_string(1 + i * 12 + x + 5, y + h -4, &format!("▀"), Style::default().white());
|
||||
buf.set_string(1 + i * 12 + x + 6, y + h -4, &format!("▀"), Style::default().white());
|
||||
buf.set_string(1 + i * 12 + x + 7, y + h -4, &format!("▀"), Style::default().black());
|
||||
buf.set_string(1 + i * 12 + x + 8, y + h -4, &format!("▀"), Style::default().white());
|
||||
buf.set_string(1 + i * 12 + x + 9, y + h -4, &format!("▀"), Style::default().black());
|
||||
buf.set_string(1 + i * 12 + x + 10, y + h -4, &format!("▀"), Style::default().white());
|
||||
buf.set_string(1 + i * 12 + x + 11, y + h -4, &format!("▀"), Style::default().black());
|
||||
buf.set_string(1 + i * 12 + x + 12, y + h -4, &format!("▀"), Style::default().white());
|
||||
let bg = Style::default().on_black();
|
||||
for i in 0..area.height - 8 {
|
||||
buf.set_string(x + 2, y + 1 + i, &" ".repeat((area.width-4)as usize), bg);
|
||||
}
|
||||
draw_box(buf, Rect { x, y, width: 40, height: h - 2 });
|
||||
Ok((40,h-3))
|
||||
Ok(Rect { x, y, width: area.width, height: area.height - 6 })
|
||||
}
|
||||
|
||||
//{
|
||||
//let mut area = area.clone();
|
||||
//area.y = area.y + 3;
|
||||
|
|
@ -329,7 +342,6 @@ fn render (sequencer: &Sequencer, buf: &mut Buffer, mut area: Rect)
|
|||
//}
|
||||
//}
|
||||
//
|
||||
}
|
||||
|
||||
fn draw_sequence_button (
|
||||
buf: &mut Buffer,
|
||||
|
|
|
|||
|
|
@ -41,12 +41,12 @@ impl Transport {
|
|||
}
|
||||
|
||||
pub fn render (state: &Transport, buf: &mut Buffer, mut area: Rect)
|
||||
-> Usually<(u16, u16)>
|
||||
-> Usually<Rect>
|
||||
{
|
||||
area.x = area.width.saturating_sub(80) / 2;
|
||||
area.width = area.width.min(80);
|
||||
area.height = 5;
|
||||
draw_box(buf, area);
|
||||
//draw_box(buf, area);
|
||||
draw_leaf(buf, area, 1, 0, "REC");
|
||||
draw_leaf(buf, area, 1, 5, "DUB");
|
||||
draw_leaf(buf, area, 1, 10, "STOP");
|
||||
|
|
@ -91,7 +91,6 @@ pub fn render (state: &Transport, buf: &mut Buffer, mut area: Rect)
|
|||
draw_leaf(buf, area, 3, 48, &format!("Rate {:>6}Hz", rate));
|
||||
draw_leaf(buf, area, 3, 63, &format!("Frame {:>10}", frame));
|
||||
}
|
||||
Ok((area.width, area.height))
|
||||
//let bbt = position.pos.bbt().map(|mut bbt|*bbt
|
||||
//.with_bpm(state.bpm)
|
||||
//.with_timesig(state.timesig.0, state.timesig.1));
|
||||
|
|
@ -131,6 +130,7 @@ pub fn render (state: &Transport, buf: &mut Buffer, mut area: Rect)
|
|||
//None => String::from("(none)")
|
||||
//}).render(area.clone().offset(Offset { x: 50, y: 2 }), buf);
|
||||
//}
|
||||
Ok(area)
|
||||
}
|
||||
|
||||
//pub fn render (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue