mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-01-12 02:56:42 +01:00
This commit is contained in:
parent
34070de5f7
commit
fd26b12955
18 changed files with 243 additions and 194 deletions
|
|
@ -13,7 +13,7 @@ def_sizes_iter!(InputsSizes => MidiInput);
|
|||
def_sizes_iter!(OutputsSizes => MidiOutput);
|
||||
def_sizes_iter!(PortsSizes => Arc<str>, [Connect]);
|
||||
|
||||
pub(crate) fn wrap (bg: Color, fg: Color, content: impl Content<TuiOut>) -> impl Content<TuiOut> {
|
||||
pub(crate) fn wrap (bg: Color, fg: Color, content: impl Render<TuiOut>) -> impl Render<TuiOut> {
|
||||
let left = Tui::fg_bg(bg, Reset, Fixed::x(1, RepeatV("▐")));
|
||||
let right = Tui::fg_bg(bg, Reset, Fixed::x(1, RepeatV("▌")));
|
||||
Bsp::e(left, Bsp::w(right, Tui::fg_bg(fg, bg, content)))
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ impl Track {
|
|||
pub trait HasTrack {
|
||||
fn track (&self) -> Option<&Track>;
|
||||
fn track_mut (&mut self) -> Option<&mut Track>;
|
||||
fn view_midi_ins_status (&self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
fn view_midi_ins_status (&self, theme: ItemTheme) -> impl Render<TuiOut> {
|
||||
self.track().map(|track|{
|
||||
let ins = track.sequencer.midi_ins.len() as u16;
|
||||
Fixed::xy(20, 1 + ins, Outer(true, Style::default().fg(Tui::g(96))).enclose(
|
||||
|
|
@ -249,7 +249,7 @@ pub trait HasTrack {
|
|||
Map::south(1, ||track.sequencer.midi_ins.iter(),
|
||||
|port, index|Fill::x(Align::w(format!(" {index} {}", port.port_name()))))))))})
|
||||
}
|
||||
fn view_midi_outs_status (&self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
fn view_midi_outs_status (&self, theme: ItemTheme) -> impl Render<TuiOut> {
|
||||
self.track().map(|track|{
|
||||
let outs = track.sequencer.midi_outs.len() as u16;
|
||||
Fixed::xy(20, 1 + outs, Outer(true, Style::default().fg(Tui::g(96))).enclose(
|
||||
|
|
@ -257,7 +257,7 @@ pub trait HasTrack {
|
|||
Map::south(1, ||track.sequencer.midi_outs.iter(),
|
||||
|port, index|Fill::x(Align::w(format!(" {index} {}", port.port_name()))))))))})
|
||||
}
|
||||
fn view_audio_ins_status (&self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
fn view_audio_ins_status (&self, theme: ItemTheme) -> impl Render<TuiOut> {
|
||||
self.track().and_then(|track|track.devices.get(0)).map(|device|{
|
||||
let ins = device.audio_ins().len() as u16;
|
||||
Fixed::xy(20, 1 + ins, Outer(true, Style::default().fg(Tui::g(96))).enclose(
|
||||
|
|
@ -265,7 +265,7 @@ pub trait HasTrack {
|
|||
Map::south(1, ||device.audio_ins().iter(),
|
||||
|port, index|Fill::x(Align::w(format!(" {index} {}", port.port_name()))))))))})
|
||||
}
|
||||
fn view_audio_outs_status (&self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
fn view_audio_outs_status (&self, theme: ItemTheme) -> impl Render<TuiOut> {
|
||||
self.track().and_then(|track|track.devices.last()).map(|device|{
|
||||
let outs = device.audio_outs().len() as u16;
|
||||
Fixed::xy(20, 1 + outs, Outer(true, Style::default().fg(Tui::g(96))).enclose(
|
||||
|
|
@ -279,7 +279,7 @@ impl Track {
|
|||
pub fn per <'a, T: Content<TuiOut> + 'a, U: TracksSizes<'a>> (
|
||||
tracks: impl Fn() -> U + Send + Sync + 'a,
|
||||
callback: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
) -> impl Render<TuiOut> + 'a {
|
||||
Map::new(tracks,
|
||||
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|{
|
||||
let width = (x2 - x1) as u16;
|
||||
|
|
@ -293,7 +293,7 @@ impl Track {
|
|||
pub(crate) fn per_track_top <'a, T: Content<TuiOut> + 'a, U: TracksSizes<'a>> (
|
||||
tracks: impl Fn() -> U + Send + Sync + 'a,
|
||||
callback: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
) -> impl Render<TuiOut> + 'a {
|
||||
Align::x(Tui::bg(Reset, Map::new(tracks,
|
||||
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|{
|
||||
let width = (x2 - x1) as u16;
|
||||
|
|
@ -306,13 +306,13 @@ pub(crate) fn per_track_top <'a, T: Content<TuiOut> + 'a, U: TracksSizes<'a>> (
|
|||
pub(crate) fn per_track <'a, T: Content<TuiOut> + 'a, U: TracksSizes<'a>> (
|
||||
tracks: impl Fn() -> U + Send + Sync + 'a,
|
||||
callback: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
) -> impl Render<TuiOut> + 'a {
|
||||
per_track_top(tracks, move|index, track|Fill::y(Align::y(callback(index, track))))
|
||||
}
|
||||
|
||||
pub(crate) fn io_ports <'a, T: PortsSizes<'a>> (
|
||||
fg: Color, bg: Color, iter: impl Fn()->T + Send + Sync + 'a
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
) -> impl Render<TuiOut> + 'a {
|
||||
Map::new(iter, move|(
|
||||
_index, name, connections, y, y2
|
||||
): (usize, &'a Arc<str>, &'a [Connect], usize, usize), _|
|
||||
|
|
@ -325,7 +325,7 @@ pub(crate) fn io_ports <'a, T: PortsSizes<'a>> (
|
|||
|
||||
pub(crate) fn io_conns <'a, T: PortsSizes<'a>> (
|
||||
fg: Color, bg: Color, iter: impl Fn()->T + Send + Sync + 'a
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
) -> impl Render<TuiOut> + 'a {
|
||||
Map::new(iter, move|(
|
||||
_index, _name, connections, y, y2
|
||||
): (usize, &'a Arc<str>, &'a [Connect], usize, usize), _|
|
||||
|
|
|
|||
|
|
@ -1,38 +1,36 @@
|
|||
use crate::*;
|
||||
|
||||
type Add<'a> = &'a dyn FnMut(&dyn Render<TuiOut>);
|
||||
|
||||
impl Arrangement {
|
||||
pub fn view_inputs <'a> (&'a self, _theme: ItemTheme) -> impl Content<TuiOut> + 'a {
|
||||
pub fn view_inputs (&self, _theme: ItemTheme) -> impl Render<TuiOut> + '_ {
|
||||
Stack::south(move|add|{
|
||||
add(&Fixed::y(1,
|
||||
Bsp::e(Fixed::x(20, Align::w(button_3("i", "nput ", format!("{}", self.midi_ins.len()), false))),
|
||||
Bsp::w(Fixed::x(4, button_2("I", "+", false)),
|
||||
Stack::east(move|add|{
|
||||
for (_index, track, _x1, _x2) in self.tracks_with_sizes() {
|
||||
add(&Tui::bg(track.color.dark.rgb, Align::w(Fixed::x(track.width as u16, row!(
|
||||
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 "),
|
||||
)))))
|
||||
}
|
||||
Stack::east(move|add|for (_index, track, _x1, _x2) in self.tracks_with_sizes() {
|
||||
add(&Tui::bg(track.color.dark.rgb, Align::w(Fixed::x(track.width as u16, row!(
|
||||
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 "),
|
||||
)))))
|
||||
})))));
|
||||
for (_index, port) in self.midi_ins().iter().enumerate() {
|
||||
add(&Fixed::y(1, Bsp::e(
|
||||
Fixed::x(20, Align::w(Bsp::e(" ● ",
|
||||
Tui::bold(true, Tui::fg(Rgb(255,255,255), port.port_name()))))),
|
||||
Bsp::w(Fixed::x(4, ()),
|
||||
Stack::east(move|add|{
|
||||
for (_index, track, _x1, _x2) in self.tracks_with_sizes() {
|
||||
add(&Tui::bg(track.color.darker.rgb, Align::w(Fixed::x(track.width as u16, row!(
|
||||
Either(track.sequencer.monitoring, Tui::fg(Green, " ● "), " · "),
|
||||
Either(track.sequencer.recording, Tui::fg(Red, " ● "), " · "),
|
||||
Either(track.sequencer.overdub, Tui::fg(Yellow, " ● "), " · "),
|
||||
)))))
|
||||
}
|
||||
Stack::east(move|add|for (_index, track, _x1, _x2) in self.tracks_with_sizes() {
|
||||
add(&Tui::bg(track.color.darker.rgb, Align::w(Fixed::x(track.width as u16, row!(
|
||||
Either(track.sequencer.monitoring, Tui::fg(Green, " ● "), " · "),
|
||||
Either(track.sequencer.recording, Tui::fg(Red, " ● "), " · "),
|
||||
Either(track.sequencer.overdub, Tui::fg(Yellow, " ● "), " · "),
|
||||
)))))
|
||||
})))));
|
||||
}
|
||||
})
|
||||
}
|
||||
pub fn view_outputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> + 'a {
|
||||
pub fn view_outputs <'a> (&'a self, theme: ItemTheme) -> impl Render<TuiOut> + 'a {
|
||||
let mut h = 1;
|
||||
for output in self.midi_outs().iter() {
|
||||
h += 1 + output.connections.len();
|
||||
|
|
@ -72,7 +70,7 @@ impl Arrangement {
|
|||
}
|
||||
}})))}}))))))
|
||||
}
|
||||
pub fn view_track_devices <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> + 'a {
|
||||
pub fn view_track_devices <'a> (&'a self, theme: ItemTheme) -> impl Render<TuiOut> + 'a {
|
||||
let mut h = 2u16;
|
||||
for track in self.tracks().iter() {
|
||||
h = h.max(track.devices.len() as u16 * 2);
|
||||
|
|
@ -137,19 +135,19 @@ pub trait TracksView:
|
|||
}
|
||||
fn view_track_row_section (
|
||||
_theme: ItemTheme,
|
||||
button: impl Content<TuiOut>,
|
||||
button_add: impl Content<TuiOut>,
|
||||
content: impl Content<TuiOut>
|
||||
) -> impl Content<TuiOut> {
|
||||
button: impl Render<TuiOut>,
|
||||
button_add: impl Render<TuiOut>,
|
||||
content: impl Render<TuiOut>
|
||||
) -> impl Render<TuiOut> {
|
||||
Bsp::w(Fill::y(Fixed::x(4, Align::nw(button_add))),
|
||||
Bsp::e(Fixed::x(20, Fill::y(Align::nw(button))), Fill::xy(Align::c(content))))
|
||||
}
|
||||
fn view_track_header <'a, T: Content<TuiOut>> (
|
||||
&'a self, theme: ItemTheme, content: T
|
||||
) -> impl Content<TuiOut> {
|
||||
) -> impl Render<TuiOut> {
|
||||
Fixed::x(12, Tui::bg(theme.darker.rgb, Fill::x(Align::e(content))))
|
||||
}
|
||||
fn view_track_names (&self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
fn view_track_names (&self, theme: ItemTheme) -> impl Render<TuiOut> {
|
||||
let track_count = self.tracks().len();
|
||||
let scene_count = self.scenes().len();
|
||||
let selected = self.selection();
|
||||
|
|
@ -176,7 +174,7 @@ pub trait TracksView:
|
|||
}
|
||||
})))))
|
||||
}
|
||||
fn view_track_outputs <'a> (&'a self, theme: ItemTheme, _h: u16) -> impl Content<TuiOut> {
|
||||
fn view_track_outputs <'a> (&'a self, theme: ItemTheme, _h: u16) -> impl Render<TuiOut> {
|
||||
Self::view_track_row_section(theme,
|
||||
Bsp::s(
|
||||
Fill::x(Align::w(button_2("o", "utput", false))),
|
||||
|
|
@ -197,7 +195,7 @@ pub trait TracksView:
|
|||
}
|
||||
})))))
|
||||
}
|
||||
fn view_track_inputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
fn view_track_inputs <'a> (&'a self, theme: ItemTheme) -> impl Render<TuiOut> {
|
||||
let mut h = 0u16;
|
||||
for track in self.tracks().iter() {
|
||||
h = h.max(track.sequencer.midi_ins.len() as u16);
|
||||
|
|
@ -259,14 +257,14 @@ pub trait ScenesView:
|
|||
}
|
||||
})
|
||||
}
|
||||
fn view_scenes_names (&self) -> impl Content<TuiOut> {
|
||||
fn view_scenes_names (&self) -> impl Render<TuiOut> {
|
||||
Fixed::x(20, Stack::south(move|add|{
|
||||
for (index, scene, ..) in self.scenes_with_sizes() {
|
||||
add(&self.view_scene_name(index, scene));
|
||||
}
|
||||
}))
|
||||
}
|
||||
fn view_scene_name (&self, index: usize, scene: &Scene) -> impl Content<TuiOut> {
|
||||
fn view_scene_name (&self, index: usize, scene: &Scene) -> impl Render<TuiOut> {
|
||||
let h = if self.selection().scene() == Some(index) && let Some(_editor) = self.editor() {
|
||||
7
|
||||
} else {
|
||||
|
|
@ -297,7 +295,7 @@ pub trait ClipsView:
|
|||
Sync
|
||||
{
|
||||
fn view_scenes_clips <'a> (&'a self)
|
||||
-> impl Content<TuiOut> + 'a
|
||||
-> impl Render<TuiOut> + 'a
|
||||
{
|
||||
self.clips_size().of(Fill::xy(Bsp::a(
|
||||
Fill::xy(Align::se(Tui::fg(Green, format!("{}x{}", self.clips_size().w(), self.clips_size().h())))),
|
||||
|
|
@ -312,7 +310,7 @@ pub trait ClipsView:
|
|||
}))))
|
||||
}
|
||||
|
||||
fn view_track_clips <'a> (&'a self, track_index: usize, track: &'a Track) -> impl Content<TuiOut> + 'a {
|
||||
fn view_track_clips <'a> (&'a self, track_index: usize, track: &'a Track) -> impl Render<TuiOut> + 'a {
|
||||
Stack::south(move|cell|{
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ pub fn view_transport (
|
|||
bpm: Arc<RwLock<String>>,
|
||||
beat: Arc<RwLock<String>>,
|
||||
time: Arc<RwLock<String>>,
|
||||
) -> impl Content<TuiOut> {
|
||||
) -> impl Render<TuiOut> {
|
||||
let theme = ItemTheme::G[96];
|
||||
Tui::bg(Black, row!(Bsp::a(
|
||||
Fill::xy(Align::w(button_play_pause(play))),
|
||||
|
|
@ -23,7 +23,7 @@ pub fn view_status (
|
|||
sr: Arc<RwLock<String>>,
|
||||
buf: Arc<RwLock<String>>,
|
||||
lat: Arc<RwLock<String>>,
|
||||
) -> impl Content<TuiOut> {
|
||||
) -> impl Render<TuiOut> {
|
||||
let theme = ItemTheme::G[96];
|
||||
Tui::bg(Black, row!(Bsp::a(
|
||||
Fill::xy(Align::w(sel.map(|sel|FieldH(theme, "Selected", sel)))),
|
||||
|
|
@ -35,7 +35,7 @@ pub fn view_status (
|
|||
)))
|
||||
}
|
||||
|
||||
pub(crate) fn button_play_pause (playing: bool) -> impl Content<TuiOut> {
|
||||
pub(crate) fn button_play_pause (playing: bool) -> impl Render<TuiOut> {
|
||||
let compact = true;//self.is_editing();
|
||||
Tui::bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) },
|
||||
Either::new(compact,
|
||||
|
|
@ -93,7 +93,7 @@ impl ViewCache {
|
|||
//}
|
||||
|
||||
//pub fn scene_add (cache: &Arc<RwLock<Self>>, scene: usize, scenes: usize, is_editing: bool)
|
||||
//-> impl Content<TuiOut>
|
||||
//-> impl Render<TuiOut>
|
||||
//{
|
||||
//let data = (scene, scenes);
|
||||
//cache.write().unwrap().scns.update(Some(data), rewrite!(buf, "({}/{})", data.0, data.1));
|
||||
|
|
@ -133,7 +133,7 @@ impl ViewCache {
|
|||
}
|
||||
}
|
||||
|
||||
//pub fn view_h2 (&self) -> impl Content<TuiOut> {
|
||||
//pub fn view_h2 (&self) -> impl Render<TuiOut> {
|
||||
//let cache = self.project.clock.view_cache.clone();
|
||||
//let cache = cache.read().unwrap();
|
||||
//add(&Fixed::x(15, Align::w(Bsp::s(
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ content!(TuiOut: |self: MidiEditor| {
|
|||
|
||||
impl MidiEditor {
|
||||
|
||||
pub fn clip_status (&self) -> impl Content<TuiOut> + '_ {
|
||||
pub fn clip_status (&self) -> impl Render<TuiOut> + '_ {
|
||||
let (_color, name, length, looped) = if let Some(clip) = self.clip().as_ref().map(|p|p.read().unwrap()) {
|
||||
(clip.color, clip.name.clone(), clip.length, clip.looped)
|
||||
} else { (ItemTheme::G[64], String::new().into(), 0, false) };
|
||||
|
|
@ -25,7 +25,7 @@ impl MidiEditor {
|
|||
))
|
||||
}
|
||||
|
||||
pub fn edit_status (&self) -> impl Content<TuiOut> + '_ {
|
||||
pub fn edit_status (&self) -> impl Render<TuiOut> + '_ {
|
||||
let (_color, length) = if let Some(clip) = self.clip().as_ref().map(|p|p.read().unwrap()) {
|
||||
(clip.color, clip.length)
|
||||
} else { (ItemTheme::G[64], 0) };
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ impl PianoHorizontal {
|
|||
|
||||
}
|
||||
}
|
||||
fn notes (&self) -> impl Content<TuiOut> {
|
||||
fn notes (&self) -> impl Render<TuiOut> {
|
||||
let time_start = self.get_time_start();
|
||||
let note_lo = self.get_note_lo();
|
||||
let note_hi = self.get_note_hi();
|
||||
|
|
@ -170,7 +170,7 @@ impl PianoHorizontal {
|
|||
}
|
||||
})
|
||||
}
|
||||
fn cursor (&self) -> impl Content<TuiOut> {
|
||||
fn cursor (&self) -> impl Render<TuiOut> {
|
||||
let note_hi = self.get_note_hi();
|
||||
let note_lo = self.get_note_lo();
|
||||
let note_pos = self.get_note_pos();
|
||||
|
|
@ -201,7 +201,7 @@ impl PianoHorizontal {
|
|||
}
|
||||
})
|
||||
}
|
||||
fn keys (&self) -> impl Content<TuiOut> {
|
||||
fn keys (&self) -> impl Render<TuiOut> {
|
||||
let state = self;
|
||||
let color = state.color;
|
||||
let note_lo = state.get_note_lo();
|
||||
|
|
@ -225,7 +225,7 @@ impl PianoHorizontal {
|
|||
}
|
||||
})))
|
||||
}
|
||||
fn timeline (&self) -> impl Content<TuiOut> + '_ {
|
||||
fn timeline (&self) -> impl Render<TuiOut> + '_ {
|
||||
Fill::x(Fixed::y(1, ThunkRender::new(move|to: &mut TuiOut|{
|
||||
let [x, y, w, _h] = to.area();
|
||||
let style = Some(Style::default().dim());
|
||||
|
|
|
|||
|
|
@ -48,8 +48,10 @@ macro_rules! def_sizes_iter {
|
|||
#[cfg(feature = "vst3")] mod vst3; #[cfg(feature = "vst3")] pub use self::vst3::*;
|
||||
|
||||
pub fn button_2 <'a> (
|
||||
key: impl Content<TuiOut> + 'a, label: impl Content<TuiOut> + 'a, editing: bool,
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
key: impl Render<TuiOut> + 'a,
|
||||
label: impl Render<TuiOut> + 'a,
|
||||
editing: bool,
|
||||
) -> impl Render<TuiOut> + 'a {
|
||||
let key = Tui::fg_bg(Tui::orange(), Tui::g(0), Bsp::e(
|
||||
Tui::fg(Tui::g(0), "▐"),
|
||||
Bsp::e(key, Tui::fg(Tui::g(96), "▐"))
|
||||
|
|
@ -58,16 +60,12 @@ pub fn button_2 <'a> (
|
|||
Tui::bold(true, Bsp::e(key, label))
|
||||
}
|
||||
|
||||
pub fn button_3 <'a, K, L, V> (
|
||||
key: K,
|
||||
label: L,
|
||||
value: V,
|
||||
pub fn button_3 <'a> (
|
||||
key: impl Render<TuiOut> + 'a,
|
||||
label: impl Render<TuiOut> + 'a,
|
||||
value: impl Render<TuiOut> + 'a,
|
||||
editing: bool,
|
||||
) -> impl Content<TuiOut> + 'a where
|
||||
K: Content<TuiOut> + 'a,
|
||||
L: Content<TuiOut> + 'a,
|
||||
V: Content<TuiOut> + 'a,
|
||||
{
|
||||
) -> impl Render<TuiOut> + 'a {
|
||||
let key = Tui::fg_bg(Tui::orange(), Tui::g(0),
|
||||
Bsp::e(Tui::fg(Tui::g(0), "▐"), Bsp::e(key, Tui::fg(if editing {
|
||||
Tui::g(128)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::*;
|
||||
use super::*;
|
||||
|
||||
impl Content<TuiOut> for Lv2 {
|
||||
impl Render<TuiOut> for Lv2 {
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
let area = to.area();
|
||||
let [x, y, _, height] = area;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ pub fn to_rms (samples: &[f32]) -> f32 {
|
|||
(sum / samples.len() as f32).sqrt()
|
||||
}
|
||||
|
||||
pub fn view_meter <'a> (label: &'a str, value: f32) -> impl Content<TuiOut> + 'a {
|
||||
pub fn view_meter <'a> (label: &'a str, value: f32) -> impl Render<TuiOut> + 'a {
|
||||
col!(
|
||||
FieldH(ItemTheme::G[128], label, format!("{:>+9.3}", value)),
|
||||
Fixed::xy(if value >= 0.0 { 13 }
|
||||
|
|
@ -74,7 +74,7 @@ pub fn view_meter <'a> (label: &'a str, value: f32) -> impl Content<TuiOut> + 'a
|
|||
else { Green }, ())))
|
||||
}
|
||||
|
||||
pub fn view_meters (values: &[f32;2]) -> impl Content<TuiOut> + use<'_> {
|
||||
pub fn view_meters (values: &[f32;2]) -> impl Render<TuiOut> + use<'_> {
|
||||
let left = format!("L/{:>+9.3}", values[0]);
|
||||
let right = format!("R/{:>+9.3}", values[1]);
|
||||
Bsp::s(left, right)
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ fn scan (dir: &PathBuf) -> Usually<(Vec<OsString>, Vec<OsString>)> {
|
|||
Ok((subdirs, files))
|
||||
}
|
||||
|
||||
impl Content<TuiOut> for AddSampleModal {
|
||||
impl Render<TuiOut> for AddSampleModal {
|
||||
fn render (&self, _to: &mut TuiOut) {
|
||||
todo!()
|
||||
//let area = to.area();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::*;
|
|||
|
||||
impl Sampler {
|
||||
|
||||
pub fn view_grid (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
pub fn view_grid (&self) -> impl Render<TuiOut> + use<'_> {
|
||||
let cells_x = 8u16;
|
||||
let cells_y = 8u16;
|
||||
let cell_width = 10u16;
|
||||
|
|
@ -23,7 +23,7 @@ impl Sampler {
|
|||
|
||||
pub fn view_grid_cell <'a> (
|
||||
&'a self, name: &'a str, x: u16, y: u16, w: u16, h: u16
|
||||
) -> impl Content<TuiOut> + use<'a> {
|
||||
) -> impl Render<TuiOut> + use<'a> {
|
||||
let cursor = self.cursor();
|
||||
let hi_fg = Color::Rgb(64, 64, 64);
|
||||
let hi_bg = if y == 0 { Color::Reset } else { Color::Rgb(64, 64, 64) /*prev*/ };
|
||||
|
|
@ -55,7 +55,7 @@ impl Sampler {
|
|||
|
||||
pub fn view_list <'a, T: NotePoint + NoteRange> (
|
||||
&'a self, compact: bool, editor: &T
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
) -> impl Render<TuiOut> + 'a {
|
||||
let note_lo = editor.get_note_lo();
|
||||
let note_pt = editor.get_note_pos();
|
||||
let note_hi = editor.get_note_hi();
|
||||
|
|
@ -97,7 +97,7 @@ impl Sampler {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn view_sample (&self, note_pt: usize) -> impl Content<TuiOut> + use<'_> {
|
||||
pub fn view_sample (&self, note_pt: usize) -> impl Render<TuiOut> + use<'_> {
|
||||
Outer(true, Style::default().fg(Tui::g(96)))
|
||||
.enclose(Fill::xy(draw_viewer(if let Some((_, Some(sample))) = &self.recording {
|
||||
Some(sample)
|
||||
|
|
@ -108,7 +108,7 @@ impl Sampler {
|
|||
})))
|
||||
}
|
||||
|
||||
pub fn view_sample_info (&self, note_pt: usize) -> impl Content<TuiOut> + use<'_> {
|
||||
pub fn view_sample_info (&self, note_pt: usize) -> impl Render<TuiOut> + use<'_> {
|
||||
Fill::x(Fixed::y(1, draw_info(if let Some((_, Some(sample))) = &self.recording {
|
||||
Some(sample)
|
||||
} else if let Some(sample) = &self.mapped[note_pt] {
|
||||
|
|
@ -118,7 +118,7 @@ impl Sampler {
|
|||
})))
|
||||
}
|
||||
|
||||
pub fn view_sample_status (&self, note_pt: usize) -> impl Content<TuiOut> + use<'_> {
|
||||
pub fn view_sample_status (&self, note_pt: usize) -> impl Render<TuiOut> + use<'_> {
|
||||
Fixed::x(20, draw_info_v(if let Some((_, Some(sample))) = &self.recording {
|
||||
Some(sample)
|
||||
} else if let Some(sample) = &self.mapped[note_pt] {
|
||||
|
|
@ -128,20 +128,20 @@ impl Sampler {
|
|||
}))
|
||||
}
|
||||
|
||||
pub fn view_status (&self, index: usize) -> impl Content<TuiOut> {
|
||||
pub fn view_status (&self, index: usize) -> impl Render<TuiOut> {
|
||||
draw_status(self.mapped[index].as_ref())
|
||||
}
|
||||
|
||||
pub fn view_meters_input (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
pub fn view_meters_input (&self) -> impl Render<TuiOut> + use<'_> {
|
||||
draw_meters(&self.input_meters)
|
||||
}
|
||||
|
||||
pub fn view_meters_output (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
pub fn view_meters_output (&self) -> impl Render<TuiOut> + use<'_> {
|
||||
draw_meters(&self.output_meters)
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_meters (meters: &[f32]) -> impl Content<TuiOut> + use<'_> {
|
||||
fn draw_meters (meters: &[f32]) -> impl Render<TuiOut> + use<'_> {
|
||||
Tui::bg(Black, Fixed::x(2, Map::east(1, ||meters.iter(), |value, _index|{
|
||||
Fill::y(RmsMeter(*value))
|
||||
})))
|
||||
|
|
@ -163,7 +163,7 @@ fn draw_list_item (sample: &Option<Arc<RwLock<Sample>>>) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
fn draw_viewer (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> + use<'_> {
|
||||
fn draw_viewer (sample: Option<&Arc<RwLock<Sample>>>) -> impl Render<TuiOut> + use<'_> {
|
||||
let min_db = -64.0;
|
||||
ThunkRender::new(move|to: &mut TuiOut|{
|
||||
let [x, y, width, height] = to.area();
|
||||
|
|
@ -218,7 +218,7 @@ fn draw_viewer (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> +
|
|||
})
|
||||
}
|
||||
|
||||
fn draw_info (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> + use<'_> {
|
||||
fn draw_info (sample: Option<&Arc<RwLock<Sample>>>) -> impl Render<TuiOut> + use<'_> {
|
||||
When(sample.is_some(), Thunk::new(move||{
|
||||
let sample = sample.unwrap().read().unwrap();
|
||||
let theme = sample.color;
|
||||
|
|
@ -233,7 +233,7 @@ fn draw_info (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> + us
|
|||
}))
|
||||
}
|
||||
|
||||
fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> + use<'_> {
|
||||
fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Render<TuiOut> + use<'_> {
|
||||
Either(sample.is_some(), Thunk::new(move||{
|
||||
let sample = sample.unwrap().read().unwrap();
|
||||
let theme = sample.color;
|
||||
|
|
@ -252,7 +252,7 @@ fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> +
|
|||
))))
|
||||
}
|
||||
|
||||
fn draw_status (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> {
|
||||
fn draw_status (sample: Option<&Arc<RwLock<Sample>>>) -> impl Render<TuiOut> {
|
||||
Tui::bold(true, Tui::fg(Tui::g(224), sample
|
||||
.map(|sample|{
|
||||
let sample = sample.read().unwrap();
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ pub trait HasPlayClip: HasClock {
|
|||
*self.reset_mut() = true;
|
||||
}
|
||||
|
||||
fn play_status (&self) -> impl Content<TuiOut> {
|
||||
fn play_status (&self) -> impl Render<TuiOut> {
|
||||
let (name, color): (Arc<str>, ItemTheme) = if let Some((_, Some(clip))) = self.play_clip() {
|
||||
let MidiClip { ref name, color, .. } = *clip.read().unwrap();
|
||||
(name.clone(), color)
|
||||
|
|
@ -51,7 +51,7 @@ pub trait HasPlayClip: HasClock {
|
|||
FieldV(color, "Now:", format!("{} {}", time, name))
|
||||
}
|
||||
|
||||
fn next_status (&self) -> impl Content<TuiOut> {
|
||||
fn next_status (&self) -> impl Render<TuiOut> {
|
||||
let mut time: Arc<str> = String::from("--.-.--").into();
|
||||
let mut name: Arc<str> = String::from("").into();
|
||||
let mut color = ItemTheme::G[64];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue