Compare commits

..

2 commits

Author SHA1 Message Date
okay stopped screaming
c72fe8ab23 wip: fix: 425e->243e
Some checks failed
/ build (push) Has been cancelled
2026-03-25 22:39:50 +02:00
okay stopped screaming
54ab1d8ba1 wip: fix: 16e->425e...? 2026-03-25 22:27:54 +02:00
8 changed files with 137 additions and 131 deletions

View file

@ -50,6 +50,7 @@ proptest-derive = { version = "^0.5.1" }
[features]
default = ["cli", "arranger", "sampler"]
arranger = ["port", "editor", "sequencer", "track", "scene", "clip", "select"]
browse = []
clap = []
@ -57,11 +58,11 @@ cli = ["dep:clap"]
clip = []
clock = []
editor = []
host = ["lv2"]
lv2 = ["port", "livi"]
lv2_gui = ["lv2", "winit"]
meter = []
mixer = []
plugin = ["lv2"]
pool = []
port = []
sampler = ["port", "meter", "mixer", "browse", "symphonia", "wavers"]

View file

@ -109,8 +109,8 @@ pub trait ClipsView: TracksView + ScenesView {
-> impl Draw<Tui> + 'a
{
self.clips_size().of(wh_full(above(
wh_full(origin_se(Tui::fg(Green, format!("{}x{}", self.clips_size().w(), self.clips_size().h())))),
Thunk::new(|to: &mut Tui|for (
wh_full(origin_se(fg(Green, format!("{}x{}", self.clips_size().w(), self.clips_size().h())))),
thunk(|to: &mut Tui|for (
track_index, track, _, _
) in self.tracks_with_sizes() {
to.place(&w_exact(track.width as u16,
@ -119,7 +119,7 @@ pub trait ClipsView: TracksView + ScenesView {
}
fn view_track_clips <'a> (&'a self, track_index: usize, track: &'a Track) -> impl Draw<Tui> + 'a {
Thunk::new(move|to: &mut Tui|for (
thunk(move|to: &mut Tui|for (
scene_index, scene, ..
) in self.scenes_with_sizes() {
let (name, theme): (Arc<str>, ItemTheme) = if let Some(Some(clip)) = &scene.clips.get(track_index) {
@ -128,20 +128,20 @@ pub trait ClipsView: TracksView + ScenesView {
} else {
(" ⏹ -- ".into(), ItemTheme::G[32])
};
let fg = theme.lightest.rgb;
let mut outline = theme.base.rgb;
let fg = theme.lightest.term;
let mut outline = theme.base.term;
let bg = if self.selection().track() == Some(track_index)
&& self.selection().scene() == Some(scene_index)
{
outline = theme.lighter.rgb;
theme.light.rgb
outline = theme.lighter.term;
theme.light.term
} else if self.selection().track() == Some(track_index)
|| self.selection().scene() == Some(scene_index)
{
outline = theme.darkest.rgb;
theme.base.rgb
outline = theme.darkest.term;
theme.base.term
} else {
theme.dark.rgb
theme.dark.term
};
let w = if self.selection().track() == Some(track_index)
&& let Some(editor) = self.editor ()
@ -162,8 +162,8 @@ pub trait ClipsView: TracksView + ScenesView {
wh_full(Outer(true, Style::default().fg(outline))),
wh_full(below(
below(
Tui::fg_bg(outline, bg, wh_full("")),
wh_full(origin_nw(Tui::fg_bg(fg, bg, Tui::bold(true, name)))),
fg_bg(outline, bg, wh_full("")),
wh_full(origin_nw(fg_bg(fg, bg, bold(true, name)))),
),
wh_full(when(self.selection().track() == Some(track_index)
&& self.selection().scene() == Some(scene_index)
@ -208,33 +208,33 @@ pub trait TracksView: ScenesView + HasMidiIns + HasMidiOuts + HasTrackScroll {
let button_2 = south(
button_2("T", "+", false),
button_2("S", "+", false));
view_track_row_section(theme, button, button_2, Tui::bg(theme.darker.rgb,
h_exact(2, Thunk::new(|to: &mut Tui|{
view_track_row_section(theme, button, button_2, bg(theme.darker.term,
h_exact(2, thunk(|to: &mut Tui|{
for (index, track, x1, _x2) in self.tracks_with_sizes() {
to.place(&x_push(x1 as u16, w_exact(track_width(index, track),
Tui::bg(if selected.track() == Some(index) {
track.color.light.rgb
bg(if selected.track() == Some(index) {
track.color.light.term
} else {
track.color.base.rgb
track.color.base.term
}, south(w_full(origin_nw(east(
format!("·t{index:02} "),
Tui::fg(Rgb(255, 255, 255), Tui::bold(true, &track.name))
fg(Rgb(255, 255, 255), bold(true, &track.name))
))), ""))) ));}}))))
}
fn view_track_outputs <'a> (&'a self, theme: ItemTheme, _h: u16) -> impl Draw<Tui> {
view_track_row_section(theme,
south(w_full(origin_w(button_2("o", "utput", false))),
Thunk::new(|to: &mut Tui|for port in self.midi_outs().iter() {
thunk(|to: &mut Tui|for port in self.midi_outs().iter() {
to.place(&w_full(origin_w(port.port_name())));
})),
button_2("O", "+", false),
Tui::bg(theme.darker.rgb, origin_w(Thunk::new(|to: &mut Tui|{
bg(theme.darker.term, origin_w(thunk(|to: &mut Tui|{
for (index, track, _x1, _x2) in self.tracks_with_sizes() {
to.place(&w_exact(track_width(index, track),
origin_nw(h_full(iter_south(1, ||track.sequencer.midi_outs.iter(),
|port, index|Tui::fg(Rgb(255, 255, 255),
h_exact(1, Tui::bg(track.color.dark.rgb, w_full(origin_w(
|port, index|fg(Rgb(255, 255, 255),
h_exact(1, bg(track.color.dark.term, w_full(origin_w(
format!("·o{index:02} {}", port.port_name())))))))))));}}))))
}
@ -243,21 +243,21 @@ pub trait TracksView: ScenesView + HasMidiIns + HasMidiOuts + HasTrackScroll {
for track in self.tracks().iter() {
h = h.max(track.sequencer.midi_ins.len() as u16);
}
let content = Thunk::new(move|to: &mut Tui|for (index, track, _x1, _x2) in self.tracks_with_sizes() {
let content = thunk(move|to: &mut Tui|for (index, track, _x1, _x2) in self.tracks_with_sizes() {
to.place(&wh_exact(track_width(index, track), h + 1,
origin_nw(south(
Tui::bg(track.color.base.rgb,
bg(track.color.base.term,
w_full(origin_w(east!(
either(track.sequencer.monitoring, Tui::fg(Green, "●mon "), "·mon "),
either(track.sequencer.recording, Tui::fg(Red, "●rec "), "·rec "),
either(track.sequencer.overdub, Tui::fg(Yellow, "●dub "), "·dub "),
either(track.sequencer.monitoring, fg(Green, "●mon "), "·mon "),
either(track.sequencer.recording, fg(Red, "●rec "), "·rec "),
either(track.sequencer.overdub, fg(Yellow, "●dub "), "·dub "),
)))),
iter_south(1, ||track.sequencer.midi_ins.iter(),
|port, index|Tui::fg_bg(Rgb(255, 255, 255), track.color.dark.rgb,
|port, index|fg_bg(Rgb(255, 255, 255), track.color.dark.term,
w_full(origin_w(format!("·i{index:02} {}", port.port_name())))))))));
});
view_track_row_section(theme, button_2("i", "nput", false), button_2("I", "+", false),
Tui::bg(theme.darker.rgb, origin_w(content)))
bg(theme.darker.term, origin_w(content)))
}
}
@ -289,7 +289,7 @@ pub trait ScenesView: HasEditor + HasSelection + HasSceneScroll + HasClipsSize +
}
fn view_scenes_names (&self) -> impl Draw<Tui> {
w_exact(20, Thunk::new(|to: &mut Tui|for (index, scene, ..) in self.scenes_with_sizes() {
w_exact(20, thunk(|to: &mut Tui|for (index, scene, ..) in self.scenes_with_sizes() {
to.place(&self.view_scene_name(index, scene));
}))
}
@ -301,17 +301,17 @@ pub trait ScenesView: HasEditor + HasSelection + HasSceneScroll + HasClipsSize +
Self::H_SCENE as u16
};
let bg = if self.selection().scene() == Some(index) {
scene.color.light.rgb
scene.color.light.term
} else {
scene.color.base.rgb
scene.color.base.term
};
let a = w_full(origin_w(east(format!("·s{index:02} "),
Tui::fg(Tui::g(255), Tui::bold(true, &scene.name)))));
fg(g(255), bold(true, &scene.name)))));
let b = when(self.selection().scene() == Some(index) && self.is_editing(),
wh_full(origin_nw(south(
self.editor().as_ref().map(|e|e.clip_status()),
self.editor().as_ref().map(|e|e.edit_status())))));
wh_exact(20, h, Tui::bg(bg, origin_nw(south(a, b))))
wh_exact(20, h, bg(bg, origin_nw(south(a, b))))
}
}
@ -447,9 +447,9 @@ pub trait HasTrack: AsRefOpt<Track> + AsMutOpt<Track> {
iter(tracks,
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|{
let width = (x2 - x1) as u16;
iter_east(x1 as u16, width, w_exact(width, Tui::fg_bg(
track.color.lightest.rgb,
track.color.base.rgb,
iter_east(x1 as u16, width, w_exact(width, fg_bg(
track.color.lightest.term,
track.color.base.term,
callback(index, track))))})
}
/// Create a new track connecting the [Sequencer] to a [Sampler].
@ -504,12 +504,12 @@ pub trait HasTrack: AsRefOpt<Track> + AsMutOpt<Track> {
tracks: impl Fn() -> U + Send + Sync + 'a,
callback: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
) -> impl Draw<Tui> + 'a {
origin_x(Tui::bg(Reset, iter(tracks,
origin_x(bg(Reset, iter(tracks,
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|{
let width = (x2 - x1) as u16;
iter_east(x1 as u16, width, w_exact(width, Tui::fg_bg(
track.color.lightest.rgb,
track.color.base.rgb,
iter_east(x1 as u16, width, w_exact(width, fg_bg(
track.color.lightest.term,
track.color.base.term,
callback(index, track))))})))
}
#[cfg(all(feature = "select"))] impl_as_ref_opt!(Scene: |self: App| self.project.as_ref_opt());
@ -653,7 +653,7 @@ impl Arrangement {
#[cfg(feature = "track")] pub fn view_inputs (&self, _theme: ItemTheme) -> impl Draw<Tui> + '_ {
south(
h_exact(1, self.view_inputs_header()),
Thunk::new(|to: &mut Tui|{
thunk(|to: &mut Tui|{
for (index, port) in self.midi_ins().iter().enumerate() {
to.place(&x_push(index as u16 * 10, h_exact(1, self.view_inputs_row(port))))
}
@ -662,23 +662,23 @@ impl Arrangement {
}
#[cfg(feature = "track")] fn view_inputs_header (&self) -> impl Draw<Tui> + '_ {
east(w_exact(20, origin_w(button_3("i", "nput ", format!("{}", self.midi_ins.len()), false))),
west(w_exact(4, button_2("I", "+", false)), Thunk::new(move|to: &mut Tui|for (_index, track, x1, _x2) in self.tracks_with_sizes() {
west(w_exact(4, button_2("I", "+", false)), thunk(move|to: &mut Tui|for (_index, track, x1, _x2) in self.tracks_with_sizes() {
#[cfg(feature = "track")]
to.place(&x_push(x1 as u16, Tui::bg(track.color.dark.rgb, origin_w(w_exact(track.width as u16, east!(
either(track.sequencer.monitoring, Tui::fg(Green, "mon "), "mon "),
either(track.sequencer.recording, Tui::fg(Red, "rec "), "rec "),
either(track.sequencer.overdub, Tui::fg(Yellow, "dub "), "dub "),
to.place(&x_push(x1 as u16, bg(track.color.dark.term, origin_w(w_exact(track.width as u16, east!(
either(track.sequencer.monitoring, fg(Green, "mon "), "mon "),
either(track.sequencer.recording, fg(Red, "rec "), "rec "),
either(track.sequencer.overdub, fg(Yellow, "dub "), "dub "),
))))))
})))
}
#[cfg(feature = "track")] fn view_inputs_row (&self, port: &MidiInput) -> impl Draw<Tui> {
east(w_exact(20, origin_w(east("", Tui::bold(true, Tui::fg(Rgb(255,255,255), port.port_name()))))),
west(w_exact(4, ()), Thunk::new(move|to: &mut Tui|for (_index, track, _x1, _x2) in self.tracks_with_sizes() {
east(w_exact(20, origin_w(east("", bold(true, fg(Rgb(255,255,255), port.port_name()))))),
west(w_exact(4, ()), thunk(move|to: &mut Tui|for (_index, track, _x1, _x2) in self.tracks_with_sizes() {
#[cfg(feature = "track")]
to.place(&Tui::bg(track.color.darker.rgb, origin_w(w_exact(track.width as u16, east!(
either(track.sequencer.monitoring, Tui::fg(Green, ""), " · "),
either(track.sequencer.recording, Tui::fg(Red, ""), " · "),
either(track.sequencer.overdub, Tui::fg(Yellow, ""), " · "),
to.place(&bg(track.color.darker.term, origin_w(w_exact(track.width as u16, east!(
either(track.sequencer.monitoring, fg(Green, ""), " · "),
either(track.sequencer.recording, fg(Red, ""), " · "),
either(track.sequencer.overdub, fg(Yellow, ""), " · "),
)))))
})))
}
@ -690,10 +690,10 @@ impl Arrangement {
let h = h as u16;
let list = south(
h_exact(1, w_full(origin_w(button_3("o", "utput", format!("{}", self.midi_outs.len()), false)))),
h_exact(h - 1, wh_full(origin_nw(Thunk::new(|to: &mut Tui|{
h_exact(h - 1, wh_full(origin_nw(thunk(|to: &mut Tui|{
for (_index, port) in self.midi_outs().iter().enumerate() {
to.place(&h_exact(1,w_full(east(
origin_w(east("", Tui::fg(Rgb(255,255,255),Tui::bold(true, port.port_name())))),
origin_w(east("", fg(Rgb(255,255,255),bold(true, port.port_name())))),
w_full(origin_e(format!("{}/{} ",
port.port().get_connections().len(),
port.connections.len())))))));
@ -703,19 +703,19 @@ impl Arrangement {
}
})))));
h_exact(h, view_track_row_section(theme, list, button_2("O", "+", false),
Tui::bg(theme.darker.rgb, origin_w(w_full(
Thunk::new(|to: &mut Tui|{
bg(theme.darker.term, origin_w(w_full(
thunk(|to: &mut Tui|{
for (index, track, _x1, _x2) in self.tracks_with_sizes() {
to.place(&w_exact(track_width(index, track),
Thunk::new(|to: &mut Tui|{
thunk(|to: &mut Tui|{
to.place(&h_exact(1, origin_w(east(
either(true, Tui::fg(Green, "play "), "play "),
either(false, Tui::fg(Yellow, "solo "), "solo "),
either(true, fg(Green, "play "), "play "),
either(false, fg(Yellow, "solo "), "solo "),
))));
for (_index, port) in self.midi_outs().iter().enumerate() {
to.place(&h_exact(1, origin_w(east(
either(true, Tui::fg(Green, ""), " · "),
either(false, Tui::fg(Yellow, ""), " · "),
either(true, fg(Green, ""), " · "),
either(false, fg(Yellow, ""), " · "),
))));
for (_index, _conn) in port.connections.iter().enumerate() {
to.place(&h_exact(1, w_full("")));
@ -730,13 +730,13 @@ impl Arrangement {
view_track_row_section(theme,
button_3("d", "evice", format!("{}", self.track().map(|t|t.devices.len()).unwrap_or(0)), false),
button_2("D", "+", false),
Thunk::new(move|to: &mut Tui|for (index, track, _x1, _x2) in self.tracks_with_sizes() {
thunk(move|to: &mut Tui|for (index, track, _x1, _x2) in self.tracks_with_sizes() {
to.place(&wh_exact(track_width(index, track), h + 1,
Tui::bg(track.color.dark.rgb, origin_nw(iter_south(2, move||0..h,
bg(track.color.dark.term, origin_nw(iter_south(2, move||0..h,
|_, _index|wh_exact(track.width as u16, 2,
Tui::fg_bg(
ItemTheme::G[32].lightest.rgb,
ItemTheme::G[32].dark.rgb,
fg_bg(
ItemTheme::G[32].lightest.term,
ItemTheme::G[32].dark.term,
origin_nw(format!(" · {}", "--")))))))));
}))
}

View file

@ -246,8 +246,8 @@ impl<'a> PoolView<'a> {
fn tui (&self) -> impl Draw<Tui> {
let Self(pool) = self;
//let color = self.1.clip().map(|c|c.read().unwrap().color).unwrap_or_else(||Tui::g(32).into());
//let on_bg = |x|x;//below(Repeat(" "), Tui::bg(color.darkest.rgb, x));
//let border = |x|x;//Outer(Style::default().fg(color.dark.rgb).bg(color.darkest.rgb)).enclose(x);
//let on_bg = |x|x;//below(Repeat(" "), Tui::bg(color.darkest.term, x));
//let border = |x|x;//Outer(Style::default().fg(color.dark.term).bg(color.darkest.term)).enclose(x);
//let height = pool.clips.read().unwrap().len() as u16;
w_exact(20, h_full(origin_n(iter(
||pool.clips().clone().into_iter(),
@ -256,8 +256,8 @@ impl<'a> PoolView<'a> {
let item_offset = i as u16 * item_height;
let selected = i == pool.clip_index();
let MidiClip { ref name, color, length, .. } = *clip.read().unwrap();
let bg = if selected { color.light.rgb } else { color.base.rgb };
let fg = color.lightest.rgb;
let bg = if selected { color.light.term } else { color.base.term };
let fg = color.lightest.term;
let name = if false { format!(" {i:>3}") } else { format!(" {i:>3} {name}") };
let length = if false { String::default() } else { format!("{length} ") };
h_exact(1, iter_south(item_offset, item_height, Tui::bg(bg, below!(

View file

@ -636,9 +636,9 @@ impl Clock {
todo!()
}
}
impl<T: HasClock> Command<T> for ClockCommand {
fn execute (&self, state: &mut T) -> Perhaps<Self> {
self.execute(state.clock_mut()) // awesome
impl<T: HasClock> Act<T> for ClockCommand {
fn act (&self, state: &mut T) -> Perhaps<Self> {
self.act(state.clock_mut()) // awesome
}
}
impl ClockView {

View file

@ -4,16 +4,18 @@ use crate::*;
Log10,
}
#[derive(Debug, Default, Clone)] pub struct Log10Meter(pub f32);
#[derive(Debug, Default, Clone)]
pub struct Log10Meter(pub f32);
#[derive(Debug, Default, Clone)] pub struct RmsMeter(pub f32);
#[derive(Debug, Default, Clone)]
pub struct RmsMeter(pub f32);
#[derive(Debug, Default)] pub enum MixingMode {
#[derive(Debug, Default)]
pub enum MixingMode {
#[default] Summing,
Average,
}
#[cfg(test)] mod test_view_meter {
use super::*;
use proptest::prelude::*;

View file

@ -1078,25 +1078,25 @@ impl PianoHorizontal {
if note == (127-note_point) || time == time_point {
cell.set_bg(Rgb(0,0,0));
} else {
cell.set_bg(clip.color.darkest.rgb);
cell.set_bg(clip.color.darkest.term);
}
if time % 384 == 0 {
cell.set_fg(clip.color.darker.rgb);
cell.set_fg(clip.color.darker.term);
cell.set_char('│');
} else if time % 96 == 0 {
cell.set_fg(clip.color.dark.rgb);
cell.set_fg(clip.color.dark.term);
cell.set_char('╎');
} else if time % note_len == 0 {
cell.set_fg(clip.color.darker.rgb);
cell.set_fg(clip.color.darker.term);
cell.set_char('┊');
} else if (127 - note) % 12 == 0 {
cell.set_fg(clip.color.darker.rgb);
cell.set_fg(clip.color.darker.term);
cell.set_char('=');
} else if (127 - note) % 6 == 0 {
cell.set_fg(clip.color.darker.rgb);
cell.set_fg(clip.color.darker.term);
cell.set_char('—');
} else {
cell.set_fg(clip.color.darker.rgb);
cell.set_fg(clip.color.darker.term);
cell.set_char('·');
}
}
@ -1106,7 +1106,7 @@ impl PianoHorizontal {
///
/// This mode uses full blocks on note on and half blocks on legato: █▄ █▄ █▄
fn draw_fg (buf: &mut BigBuffer, clip: &MidiClip, zoom: usize) {
let style = Style::default().fg(clip.color.base.rgb);//.bg(Rgb(0, 0, 0));
let style = Style::default().fg(clip.color.base.term);//.bg(Rgb(0, 0, 0));
let mut notes_on = [false;128];
for (x, time_start) in (0..clip.length).step_by(zoom).enumerate() {
for (_y, note) in (0..=127).rev().enumerate() {
@ -1178,7 +1178,7 @@ impl PianoHorizontal {
let time_pos = self.get_time_pos();
let time_start = self.get_time_start();
let time_zoom = self.get_time_zoom();
let style = Some(Style::default().fg(self.color.lightest.rgb));
let style = Some(Style::default().fg(self.color.lightest.term));
Thunk::new(move|to: &mut Tui|{
let XYWH(x0, y0, w, _) = to.area();
for (_area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {
@ -1209,7 +1209,7 @@ impl PianoHorizontal {
let note_pos = state.get_note_pos();
let key_style = Some(Style::default().fg(Rgb(192, 192, 192)).bg(Rgb(0, 0, 0)));
let off_style = Some(Style::default().fg(Tui::g(255)));
let on_style = Some(Style::default().fg(Rgb(255,0,0)).bg(color.base.rgb).bold());
let on_style = Some(Style::default().fg(Rgb(255,0,0)).bg(color.base.term).bold());
h_full(w_exact(self.keys_width, Thunk::new(move|to: &mut Tui|{
let XYWH(x, y0, _w, _h) = to.area();
for (_area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {
@ -1266,8 +1266,10 @@ impl MidiViewer for PianoHorizontal {
fn clip (&self) -> &Option<Arc<RwLock<MidiClip>>> { &self.clip }
fn clip_mut (&mut self) -> &mut Option<Arc<RwLock<MidiClip>>> { &mut self.clip }
/// Determine the required space to render the clip.
fn buffer_size (&self, clip: &MidiClip) -> (usize, usize) { (clip.length / self.range.time_zoom().get(), 128) }
fn redraw(self) {
fn buffer_size (&self, clip: &MidiClip) -> (usize, usize) {
(clip.length / self.range.time_zoom().get(), 128)
}
fn redraw (&self) {
*self.buffer.write().unwrap() = if let Some(clip) = self.clip.as_ref() {
let clip = clip.read().unwrap();
let buf_size = self.buffer_size(&clip);

View file

@ -49,12 +49,13 @@ pub mod dialog;
pub mod menu;
pub mod mix;
pub mod mode;
pub mod plugin;
pub mod sample;
pub mod sequence;
pub mod select;
pub mod view;
#[cfg(feature = "plugin")] pub mod plugin;
use clap::{self, Parser, Subcommand};
use builder_pattern::Builder;
use self::{
@ -182,7 +183,7 @@ fn tek_inc (state: &mut App, axis: &ControlAxis) -> Perhaps<AppCommand> {
Ok(match (&state.dialog, axis) {
(Dialog::None, _) => todo!(),
(Dialog::Menu(_, _), ControlAxis::Y) => AppCommand::SetDialog { dialog: state.dialog.menu_next() }
.execute(state)?,
.act(state)?,
_ => todo!()
})
}
@ -191,7 +192,7 @@ fn tek_dec (state: &mut App, axis: &ControlAxis) -> Perhaps<AppCommand> {
Ok(match (&state.dialog, axis) {
(Dialog::None, _) => None,
(Dialog::Menu(_, _), ControlAxis::Y) => AppCommand::SetDialog { dialog: state.dialog.menu_prev() }
.execute(state)?,
.act(state)?,
_ => todo!()
})
}
@ -218,7 +219,7 @@ fn execute_commands (
) -> Usually<Vec<(AppCommand, Option<AppCommand>)>> {
let mut history = vec![];
for command in commands.into_iter() {
let result = command.execute(app);
let result = command.act(app);
match result { Err(err) => { history.push((command, None)); return Err(err) }
Ok(undo) => { history.push((command, undo)); } };
}
@ -357,11 +358,11 @@ def_sizes_iter!(TracksSizes => Track);
/// let _ = tek::view_logo();
/// ```
pub fn view_logo () -> impl Draw<Tui> {
wh_exact(32, 7, Tui::bold(true, Tui::fg(Rgb(240,200,180), south!{
wh_exact(32, 7, bold(true, fg(Rgb(240,200,180), south!{
h_exact(1, ""),
h_exact(1, ""),
h_exact(1, "~~ ╓─╥─╖ ╓──╖ ╥ ╖ ~~~~~~~~~~~~"),
h_exact(1, east("~~~~ ║ ~ ╟─╌ ~╟─< ~~ ", east(Tui::fg(Rgb(230,100,40), "v0.3.0"), " ~~"))),
h_exact(1, east("~~~~ ║ ~ ╟─╌ ~╟─< ~~ ", east(fg(Rgb(230,100,40), "v0.3.0"), " ~~"))),
h_exact(1, "~~~~ ╨ ~ ╙──╜ ╨ ╜ ~~~~~~~~~~~~"),
})))
}
@ -378,7 +379,7 @@ pub fn view_transport (
time: Arc<RwLock<String>>,
) -> impl Draw<Tui> {
let theme = ItemTheme::G[96];
Tui::bg(Black, east!(above(
bg(Black, east!(above(
wh_full(origin_w(button_play_pause(play))),
wh_full(origin_e(east!(
field_h(theme, "BPM", bpm),
@ -400,7 +401,7 @@ pub fn view_status (
lat: Arc<RwLock<String>>,
) -> impl Draw<Tui> {
let theme = ItemTheme::G[96];
Tui::bg(Black, east!(above(
bg(Black, east!(above(
wh_full(origin_w(sel.map(|sel|field_h(theme, "Selected", sel)))),
wh_full(origin_e(east!(
field_h(theme, "SR", sr),
@ -415,15 +416,15 @@ pub fn view_status (
/// ```
pub fn button_play_pause (playing: bool) -> impl Draw<Tui> {
let compact = true;//self.is_editing();
Tui::bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) },
bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) },
either(compact,
Thunk::new(move|to: &mut Tui|to.place(&w_exact(9, either(playing,
Tui::fg(Rgb(0, 255, 0), " PLAYING "),
Tui::fg(Rgb(255, 128, 0), " STOPPED ")))
fg(Rgb(0, 255, 0), " PLAYING "),
fg(Rgb(255, 128, 0), " STOPPED ")))
)),
Thunk::new(move|to: &mut Tui|to.place(&w_exact(5, either(playing,
Tui::fg(Rgb(0, 255, 0), south(" 🭍🭑🬽 ", " 🭞🭜🭘 ",)),
Tui::fg(Rgb(255, 128, 0), south(" ▗▄▖ ", " ▝▀▘ ",))))
fg(Rgb(0, 255, 0), south(" 🭍🭑🬽 ", " 🭞🭜🭘 ",)),
fg(Rgb(255, 128, 0), south(" ▗▄▖ ", " ▝▀▘ ",))))
))
)
)
@ -445,9 +446,9 @@ pub fn button_play_pause (playing: bool) -> impl Draw<Tui> {
/// let _ = tek::view_wrap(bg, fg, "and then blue, too!");
/// ```
pub fn view_wrap (bg: Color, fg: Color, content: impl Draw<Tui>) -> impl Draw<Tui> {
let left = Tui::fg_bg(bg, Reset, w_exact(1, y_repeat("")));
let right = Tui::fg_bg(bg, Reset, w_exact(1, y_repeat("")));
east(left, west(right, Tui::fg_bg(fg, bg, content)))
let left = fg_bg(bg, Reset, w_exact(1, y_repeat("")));
let right = fg_bg(bg, Reset, w_exact(1, y_repeat("")));
east(left, west(right, fg_bg(fg, bg, content)))
}
/// ```
@ -470,7 +471,7 @@ pub fn view_meter <'a> (label: &'a str, value: f32) -> impl Draw<Tui> + 'a {
else if value >= -25.0 { 3 }
else if value >= -30.0 { 2 }
else if value >= -40.0 { 1 }
else { 0 }, 1, Tui::bg(if value >= 0.0 { Red }
else { 0 }, 1, bg(if value >= 0.0 { Red }
else if value >= -3.0 { Yellow }
else { Green }, ())))
}
@ -508,15 +509,15 @@ pub fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> + us
w_full(origin_w(field_h(theme, "Trans ", "0"))),
w_full(origin_w(field_h(theme, "Gain ", format!("{}", sample.gain)))),
)))
}), Thunk::new(|to: &mut Tui|to.place(&Tui::fg(Red, south!(
Tui::bold(true, "× No sample."),
}), Thunk::new(|to: &mut Tui|to.place(&fg(Red, south!(
bold(true, "× No sample."),
"[r] record",
"[Shift-F9] import",
)))))
}
pub fn draw_status (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> {
Tui::bold(true, Tui::fg(Tui::g(224), sample
bold(true, fg(g(224), sample
.map(|sample|{
let sample = sample.read().unwrap();
format!("Sample {}-{}", sample.start, sample.end)
@ -525,14 +526,14 @@ pub fn draw_status (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> {
}
pub fn view_track_header (theme: ItemTheme, content: impl Draw<Tui>) -> impl Draw<Tui> {
w_exact(12, Tui::bg(theme.darker.rgb, w_full(origin_e(content))))
w_exact(12, bg(theme.darker.term, w_full(origin_e(content))))
}
pub fn view_ports_status <'a, T: JackPort> (theme: ItemTheme, title: &'a str, ports: &'a [T])
-> impl Draw<Tui> + use<'a, T>
{
let ins = ports.len() as u16;
let frame = Outer(true, Style::default().fg(Tui::g(96)));
let frame = Outer(true, Style::default().fg(g(96)));
let iter = move||ports.iter();
let names = iter_south(1, iter, move|port, index|h_full(origin_w(format!(" {index} {}", port.port_name()))));
let field = field_v(theme, title, names);
@ -546,9 +547,9 @@ pub fn io_ports <'a, T: PortsSizes<'a>> (
_index, name, connections, y, y2
): (usize, &'a Arc<str>, &'a [Connect], usize, usize), _|
iter_south(y as u16, (y2-y) as u16, south(
h_full(Tui::bold(true, Tui::fg_bg(fg, bg, origin_w(east(&" 󰣲 ", name))))),
h_full(bold(true, fg_bg(fg, bg, origin_w(east(&" 󰣲 ", name))))),
iter(||connections.iter(), move|connect: &'a Connect, index|iter_south(index as u16, 1,
h_full(origin_w(Tui::bold(false, Tui::fg_bg(fg, bg,
h_full(origin_w(bold(false, fg_bg(fg, bg,
&connect.info)))))))))
}
@ -734,16 +735,16 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
Some(":logo") => to.place(&view_logo()),
Some(":status") => to.place(&h_exact(1, "TODO: Status Bar")),
Some(":meters") => match frags.next() {
Some("input") => to.place(&Tui::bg(Rgb(30, 30, 30), h_full(origin_s("Input Meters")))),
Some("output") => to.place(&Tui::bg(Rgb(30, 30, 30), h_full(origin_s("Output Meters")))),
Some("input") => to.place(&bg(Rgb(30, 30, 30), h_full(origin_s("Input Meters")))),
Some("output") => to.place(&bg(Rgb(30, 30, 30), h_full(origin_s("Output Meters")))),
_ => panic!()
},
Some(":tracks") => match frags.next() {
None => to.place(&"TODO tracks"),
Some("names") => to.place(&state.project.view_track_names(state.color.clone())),//Tui::bg(Rgb(40, 40, 40), w_full(origin_w("Track Names")))),
Some("inputs") => to.place(&Tui::bg(Rgb(40, 40, 40), w_full(origin_w("Track Inputs")))),
Some("devices") => to.place(&Tui::bg(Rgb(40, 40, 40), w_full(origin_w("Track Devices")))),
Some("outputs") => to.place(&Tui::bg(Rgb(40, 40, 40), w_full(origin_w("Track Outputs")))),
Some("names") => to.place(&state.project.view_track_names(state.color.clone())),//bg(Rgb(40, 40, 40), w_full(origin_w("Track Names")))),
Some("inputs") => to.place(&bg(Rgb(40, 40, 40), w_full(origin_w("Track Inputs")))),
Some("devices") => to.place(&bg(Rgb(40, 40, 40), w_full(origin_w("Track Devices")))),
Some("outputs") => to.place(&bg(Rgb(40, 40, 40), w_full(origin_w("Track Outputs")))),
_ => panic!()
},
Some(":scenes") => match frags.next() {
@ -759,7 +760,7 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
Some(wh_full(Thunk::new(move|to: &mut Tui|{
for (index, MenuItem(item, _)) in items.0.iter().enumerate() {
to.place(&y_push((2 * index) as u16,
Tui::fg_bg(
fg_bg(
if *selected == index { Rgb(240,200,180) } else { Rgb(200, 200, 200) },
if *selected == index { Rgb(80, 80, 50) } else { Rgb(30, 30, 30) },
h_exact(2, origin_n(w_full(item)))
@ -781,11 +782,11 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
let info = profile.info.get(0).map(|x|x.as_ref()).unwrap_or("<no info>");
let fg1 = Rgb(224, 192, 128);
let fg2 = Rgb(224, 128, 32);
let field_name = w_full(origin_w(Tui::fg(fg1, name)));
let field_id = w_full(origin_e(Tui::fg(fg2, id)));
let field_name = w_full(origin_w(fg(fg1, name)));
let field_id = w_full(origin_e(fg(fg2, id)));
let field_info = w_full(origin_w(info));
to.place(&y_push((2 * index) as u16,
h_exact(2, w_full(Tui::bg(bg, south(
h_exact(2, w_full(bg(bg, south(
above(field_name, field_id), field_info))))));
}
})))
@ -795,7 +796,7 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
for (index, name) in ["session1", "session2", "session3"].iter().enumerate() {
let bg = if index == 0 { Rgb(50,50,50) } else { Rgb(40,40,40) };
to.place(&y_push((2 * index) as u16,
&h_exact(2, w_full(Tui::bg(bg, origin_w(Tui::fg(fg, name)))))));
&h_exact(2, w_full(bg(bg, origin_w(fg(fg, name)))))));
}
})))),
Some(":browse/title") => to.place(&w_full(origin_w(field_v(ItemColor::default(),
@ -806,16 +807,16 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
BrowseTarget::ExportSample(_) => "Export sample:",
BrowseTarget::ImportClip(_) => "Import clip:",
BrowseTarget::ExportClip(_) => "Export clip:",
}, w_shrink(3, h_exact(1, Tui::fg(Tui::g(96), x_repeat("🭻")))))))),
}, w_shrink(3, h_exact(1, fg(g(96), x_repeat("🭻")))))))),
Some(":device") => {
let selected = state.dialog.device_kind().unwrap();
to.place(&south(Tui::bold(true, "Add device"), iter_south(1,
to.place(&south(bold(true, "Add device"), iter_south(1,
move||device_kinds().iter(),
move|_label: &&'static str, i|{
let bg = if i == selected { Rgb(64,128,32) } else { Rgb(0,0,0) };
let lb = if i == selected { "[ " } else { " " };
let rb = if i == selected { " ]" } else { " " };
w_full(Tui::bg(bg, east(lb, west(rb, "FIXME device name")))) })))
w_full(bg(bg, east(lb, west(rb, "FIXME device name")))) })))
},
Some(":debug") => to.place(&h_exact(1, format!("[{:?}]", to.area()))),
Some(_) => {
@ -955,7 +956,7 @@ impl App {
impl Draw<Tui> for App {
fn draw (self, to: &mut Tui) -> Usually<XYWH<u16>> {
if let Some(e) = self.error.read().unwrap().as_ref() {
to.show(to.area(), e);
to.place_at(to.area(), e);
}
for (index, dsl) in self.mode.view.iter().enumerate() {
if let Err(e) = self.understand(to, dsl) {

2
tengri

@ -1 +1 @@
Subproject commit cf57f44933c45507e8de072e32c284f20f12ac7a
Subproject commit 30d378a6ee8a998b3c4437a4c2e83f56b370ac1d