wip: tek_test again

This commit is contained in:
🪞👃🪞 2024-09-09 22:57:00 +03:00
parent fa8282a9d5
commit 4c23aed40a
16 changed files with 190 additions and 172 deletions

View file

@ -9,13 +9,13 @@ pub fn main () -> Usually<()> {
struct ArrangerStandalone<E: Engine> {
/// Contains all the sequencers.
arranger: Arranger<E>,
arranger: Arranger<E>,
/// Controls the JACK transport.
transport: Option<TransportToolbar>,
transport: Option<TransportToolbar<E>>,
/// This allows the sequencer view to be moved or hidden.
show_sequencer: Option<tek_core::Direction>,
show_sequencer: Option<tek_core::Direction>,
///
focus: usize,
focus: usize,
}
#[derive(Debug, Parser)]
@ -38,7 +38,7 @@ pub struct ArrangerCli {
scenes: usize,
}
impl<E: Engine> ArrangerStandalone<E> {
impl ArrangerStandalone<Tui> {
pub fn from_args () -> Usually<Self> {
let args = ArrangerCli::parse();
let mut arranger = Arranger::new("");
@ -73,10 +73,15 @@ impl<E: Engine> ArrangerStandalone<E> {
}
}
impl Render<Tui> for ArrangerStandalone<Tui> {
impl Widget for ArrangerStandalone<Tui> {
type Engine = Tui;
fn layout (&self, to: [u16;4]) -> Perhaps<[u16;4]> {
Ok(Some(to))
}
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
let area = to.area();
let sequencer = self.arranger.sequencer();
let sequencer = self.arranger.sequencer()
.map(|t|t as &dyn Widget<Engine = Tui>);
let result = Split::down()
.add_ref(&self.transport)
.add_ref(&self.arranger)

View file

@ -4,7 +4,7 @@ pub fn draw (state: &Arranger<Tui>, to: &mut Tui) -> Perhaps<[u16;4]> {
let area = to.area();
let area = [area.x(), area.y(), area.w(), area.h().min((2 + state.tracks.len() * 2) as u16)];
let tracks = state.tracks.as_slice();
Layers(&[
Layers([
&state.focused.then_some(FillBg(COLOR_BG0)),
&Split::right()
.add(TrackNameColumn(tracks, state.selected))

View file

@ -38,15 +38,15 @@ pub fn draw <'a, 'b> (
let offset = 3 + scene_name_max_len(state.scenes.as_ref()) as u16;
let tracks = state.tracks.as_ref();
let scenes = state.scenes.as_ref();
Layered::new()
Layers([
//.add_ref(&FillBg(Color::Rgb(30, 33, 36)))//COLOR_BG1))//bg_lo(state.focused, state.entered)))
.add_ref(&ColumnSeparators(offset, cols))
.add_ref(&RowSeparators(rows))
.add_ref(&CursorFocus(state.selected, offset, cols, rows))
.add_ref(&Split::down()
&ColumnSeparators(offset, cols),
&RowSeparators(rows),
&CursorFocus(state.selected, offset, cols, rows),
&Split::down()
.add_ref(&TracksHeader(offset, cols, tracks))
.add_ref(&SceneRows(offset, cols, rows, tracks, scenes)))
.render(to)
.add_ref(&SceneRows(offset, cols, rows, tracks, scenes))
]).render(to.with_rect(area))
}
struct ColumnSeparators<'a>(u16, &'a [(usize, usize)]);

View file

@ -15,13 +15,13 @@ impl Sequencer<Tui> {
let area = [area.x() + 10, area.y(), area.w().saturating_sub(10), area.h().min(66)];
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(area))?;
let area = [area.x() + 1, area.y(), area.w().saturating_sub(1), area.h()];
Layered::new()
.add_ref(&SequenceKeys(&self))
.add_ref(&self.phrase.as_ref().map(|phrase|SequenceTimer(&self, phrase.clone())))
.add_ref(&SequenceNotes(&self))
.add_ref(&SequenceCursor(&self))
.add_ref(&SequenceZoom(&self))
.render(to.with_rect(area))?;
Layers([
&SequenceKeys(&self),
&self.phrase.as_ref().map(|phrase|SequenceTimer(&self, phrase.clone())),
&SequenceNotes(&self),
&SequenceCursor(&self),
&SequenceZoom(&self),
]).render(to.with_rect(area))?;
Ok(())
}

View file

@ -23,7 +23,7 @@ pub struct TransportToolbar<E: Engine> {
pub clock: TransportClock<E>,
}
impl<E: Engine> TransportToolbar<E> {
pub fn standalone () -> Usually<Arc<RwLock<Self>>> {
pub fn standalone () -> Usually<Arc<RwLock<Self>>> where Self: 'static {
let mut transport = Self::new(None);
transport.focused = true;
let jack = JackClient::Inactive(

View file

@ -22,7 +22,7 @@ impl Widget for TransportPlayPauseButton<Tui> {
}
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
let Self { value, focused, .. } = &self;
Layers(&[
Layers([
&focused.then_some(CORNERS),
&Inset::W(1, Styled(match value {
Some(TransportState::Stopped) => Some(GRAY_DIM.bold()),