mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
wip: big flat pt.12, down to 1 error
This commit is contained in:
parent
b718e54d33
commit
e21ef1af94
9 changed files with 53 additions and 30 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use std::sync::{Arc, atomic::AtomicUsize};
|
use std::sync::{Arc, atomic::{AtomicUsize, Ordering::Relaxed}};
|
||||||
|
|
||||||
impl Direction {
|
impl Direction {
|
||||||
pub fn is_north (&self) -> bool { matches!(self, Self::North) }
|
pub fn is_north (&self) -> bool { matches!(self, Self::North) }
|
||||||
|
|
@ -46,6 +46,14 @@ pub struct Measure<E: Engine> {
|
||||||
pub y: Arc<AtomicUsize>,
|
pub y: Arc<AtomicUsize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render!(Measure<E>
|
||||||
|
|self, layout|Ok(Some(layout)),
|
||||||
|
|self, render|{
|
||||||
|
self.x.store(render.area().w().into(), Relaxed);
|
||||||
|
self.y.store(render.area().h().into(), Relaxed);
|
||||||
|
Ok(())
|
||||||
|
});
|
||||||
|
|
||||||
impl<E: Engine> Clone for Measure<E> {
|
impl<E: Engine> Clone for Measure<E> {
|
||||||
fn clone (&self) -> Self {
|
fn clone (&self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ from!(|args:(&ArrangerTui, usize)|ArrangerVCursor = Self {
|
||||||
});
|
});
|
||||||
|
|
||||||
render!(<Tui>(self: ArrangerVCursor)
|
render!(<Tui>(self: ArrangerVCursor)
|
||||||
|layout|Ok([0, 0]),
|
|layout|Ok(Some([0, 0])),
|
||||||
|render|{
|
|render|{
|
||||||
let area = render.area();
|
let area = render.area();
|
||||||
let focused = true;
|
let focused = true;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub(crate) use ::tek_layout::{
|
||||||
},
|
},
|
||||||
ratatui::{
|
ratatui::{
|
||||||
self,
|
self,
|
||||||
prelude::{Color, Style, Buffer, Modifier},
|
prelude::{Color, Style, Stylize, Buffer, Modifier},
|
||||||
buffer::Cell,
|
buffer::Cell,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,14 @@ impl Content<Tui> for Box<dyn PhraseViewMode> {
|
||||||
Some(&(*self))
|
Some(&(*self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl Render<Tui> for Box<dyn PhraseViewMode> {
|
||||||
|
fn min_size (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||||
|
self.content().unwrap().min_size(to)
|
||||||
|
}
|
||||||
|
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||||
|
self.content().unwrap().render(to)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl MidiView<Tui> for MidiEditor {}
|
impl MidiView<Tui> for MidiEditor {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ render!(<Tui>|self: PianoHorizontal|{
|
||||||
Padding::xy(0, 1, Fill::xy(Bsp::s(
|
Padding::xy(0, 1, Fill::xy(Bsp::s(
|
||||||
Fixed::y(1, Bsp::e(
|
Fixed::y(1, Bsp::e(
|
||||||
Fixed::x(self.keys_width, ""),
|
Fixed::x(self.keys_width, ""),
|
||||||
Fill::w(timeline()),
|
Fill::x(timeline()),
|
||||||
)),
|
)),
|
||||||
Bsp::e(
|
Bsp::e(
|
||||||
Fixed::x(self.keys_width, keys()),
|
Fixed::x(self.keys_width, keys()),
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ use super::note_y_iter;
|
||||||
|
|
||||||
pub struct PianoHorizontalCursor<'a>(pub(crate) &'a PianoHorizontal);
|
pub struct PianoHorizontalCursor<'a>(pub(crate) &'a PianoHorizontal);
|
||||||
render!(<Tui>(self: PianoHorizontalCursor<'a>)
|
render!(<Tui>(self: PianoHorizontalCursor<'a>)
|
||||||
|layout|Ok([0, 0]),
|
|layout|Ok(Some([0, 0])),
|
||||||
|render|{
|
|render|Ok({
|
||||||
let style = Some(Style::default().fg(self.0.color.lightest.rgb));
|
let style = Some(Style::default().fg(self.0.color.lightest.rgb));
|
||||||
let note_hi = self.0.note_hi();
|
let note_hi = self.0.note_hi();
|
||||||
let note_len = self.0.note_len();
|
let note_len = self.0.note_len();
|
||||||
|
|
@ -32,4 +32,4 @@ render!(<Tui>(self: PianoHorizontalCursor<'a>)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub struct AddSampleModal {
|
||||||
_search: Option<String>,
|
_search: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Exit for AddSampleModal {
|
impl AddSampleModal {
|
||||||
fn exited (&self) -> bool {
|
fn exited (&self) -> bool {
|
||||||
self.exited
|
self.exited
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,16 +49,10 @@ render!(<Tui>(self: SampleViewer)
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let draw = |ctx| {
|
|
||||||
for line in lines.iter() {
|
|
||||||
ctx.draw(line)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Canvas::default()
|
Canvas::default()
|
||||||
.x_bounds(x_bounds)
|
.x_bounds(x_bounds)
|
||||||
.y_bounds(y_bounds)
|
.y_bounds(y_bounds)
|
||||||
.paint(draw)
|
.paint(|ctx| { for line in lines.iter() { ctx.draw(line) } })
|
||||||
.render(area, &mut render.buffer);
|
.render(area, &mut render.buffer);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -56,24 +56,37 @@ render!(<Tui>|self: SamplerTui|{
|
||||||
Tui::fg(self.color.light.rgb, Tui::bold(true, &"Sampler")),
|
Tui::fg(self.color.light.rgb, Tui::bold(true, &"Sampler")),
|
||||||
with_size(Shrink::y(1, Bsp::e(
|
with_size(Shrink::y(1, Bsp::e(
|
||||||
Fixed::x(keys_width, keys()),
|
Fixed::x(keys_width, keys()),
|
||||||
Fill::xy(render(|to: &mut TuiOutput|Ok({
|
Fill::xy(SamplesTui {
|
||||||
let x = to.area.x();
|
color: self.color,
|
||||||
|
note_hi: self.note_hi(),
|
||||||
|
note_pt: self.note_point(),
|
||||||
|
height: self.size.h(),
|
||||||
|
}),
|
||||||
|
))),
|
||||||
|
))))
|
||||||
|
});
|
||||||
|
|
||||||
|
struct SamplesTui {
|
||||||
|
color: ItemPalette,
|
||||||
|
note_hi: usize,
|
||||||
|
note_pt: usize,
|
||||||
|
height: usize,
|
||||||
|
}
|
||||||
|
render!(<Tui>(self: SamplesTui)
|
||||||
|
|area|Ok(Some([15, 1])),
|
||||||
|
|render|Ok({
|
||||||
|
let x = render.area.x();
|
||||||
let bg_base = self.color.darkest.rgb;
|
let bg_base = self.color.darkest.rgb;
|
||||||
let bg_selected = self.color.darker.rgb;
|
let bg_selected = self.color.darker.rgb;
|
||||||
let style_empty = Style::default().fg(self.color.base.rgb);
|
let style_empty = Style::default().fg(self.color.base.rgb);
|
||||||
let style_full = Style::default().fg(self.color.lighter.rgb);
|
let style_full = Style::default().fg(self.color.lighter.rgb);
|
||||||
let note_hi = self.note_hi();
|
for y in 0..self.height {
|
||||||
let note_pt = self.note_point();
|
let note = self.note_hi - y as usize;
|
||||||
for y in 0..self.size.h() {
|
let bg = if note == self.note_pt { bg_selected } else { bg_base };
|
||||||
let note = note_hi - y as usize;
|
|
||||||
let bg = if note == note_pt { bg_selected } else { bg_base };
|
|
||||||
let style = Some(style_empty.bg(bg));
|
let style = Some(style_empty.bg(bg));
|
||||||
to.blit(&" (no sample) ", x, to.area.y() + y as u16, style)
|
render.blit(&" (no sample) ", x, render.area.y() + y as u16, style)
|
||||||
}
|
}
|
||||||
})))
|
}));
|
||||||
))),
|
|
||||||
))))
|
|
||||||
});
|
|
||||||
|
|
||||||
impl NoteRange for SamplerTui {
|
impl NoteRange for SamplerTui {
|
||||||
fn note_lo (&self) -> &AtomicUsize { &self.note_lo }
|
fn note_lo (&self) -> &AtomicUsize { &self.note_lo }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue