mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
polite outline
This commit is contained in:
parent
701ea3fc27
commit
62bfb0120b
3 changed files with 109 additions and 121 deletions
|
|
@ -115,28 +115,16 @@ impl App {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
pub fn view_arranger_inputs <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
pub fn view_arranger_inputs <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
||||||
Fixed::y(3, Bsp::e(
|
Fixed::y(3, self.project.view_track_inputs(self.color))
|
||||||
Fixed::x(20, Tui::bg(self.color.darker.rgb, Fill::xy(""))),
|
|
||||||
self.project.view_track_inputs(self.color)
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
pub fn view_arranger_outputs <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
pub fn view_arranger_outputs <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
||||||
Fixed::y(3, Bsp::e(
|
Fixed::y(3, self.project.view_track_outputs(self.color))
|
||||||
Fixed::x(20, Tui::bg(self.color.darker.rgb, Fill::xy(""))),
|
|
||||||
self.project.view_track_outputs(self.color)
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
pub fn view_arranger_devices <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
pub fn view_arranger_devices <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
||||||
Fixed::y(3, Bsp::e(
|
Fixed::y(3, self.project.view_track_devices(self.color))
|
||||||
Fixed::x(20, Tui::bg(self.color.darker.rgb, Fill::xy(""))),
|
|
||||||
self.project.view_track_devices(self.color)
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
pub fn view_arranger_tracks <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
pub fn view_arranger_tracks <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
||||||
Fixed::y(2, Bsp::e(
|
Fixed::y(3, self.project.view_track_names(self.color))
|
||||||
Fixed::x(20, Tui::bg(self.color.darker.rgb, Fill::xy(""))),
|
|
||||||
self.project.view_track_names(self.color)
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
pub fn view_arranger_track_names (&self) -> impl Content<TuiOut> + use<'_> {
|
pub fn view_arranger_track_names (&self) -> impl Content<TuiOut> + use<'_> {
|
||||||
self.project.view_track_names(self.color)
|
self.project.view_track_names(self.color)
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ impl Arrangement {
|
||||||
mouts: &[PortConnect],
|
mouts: &[PortConnect],
|
||||||
) -> Usually<(usize, &mut Track)> {
|
) -> Usually<(usize, &mut Track)> {
|
||||||
let name: Arc<str> = name.map_or_else(
|
let name: Arc<str> = name.map_or_else(
|
||||||
||format!("t{:02}", self.track_last).into(),
|
||format!("trk{:02}", self.track_last).into(),
|
||||||
|x|x.to_string().into()
|
|x|x.to_string().into()
|
||||||
);
|
);
|
||||||
self.track_last += 1;
|
self.track_last += 1;
|
||||||
|
|
|
||||||
|
|
@ -12,16 +12,10 @@ pub trait TracksView:
|
||||||
/// Iterate over tracks with their corresponding sizes.
|
/// Iterate over tracks with their corresponding sizes.
|
||||||
fn tracks_with_sizes (&self) -> impl TracksSizes<'_> {
|
fn tracks_with_sizes (&self) -> impl TracksSizes<'_> {
|
||||||
let editor_width = self.editor().map(|e|e.width());
|
let editor_width = self.editor().map(|e|e.width());
|
||||||
let active_track = if let Some(width) = editor_width {
|
let active_track = self.selection().track();
|
||||||
self.selection().track()
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
let mut x = 0;
|
let mut x = 0;
|
||||||
self.tracks().iter().enumerate().map(move |(index, track)|{
|
self.tracks().iter().enumerate().map(move |(index, track)|{
|
||||||
let width = active_track
|
let width = active_track.and_then(|_|editor_width).unwrap_or(track.width.max(8));
|
||||||
.and_then(|_|editor_width)
|
|
||||||
.unwrap_or(track.width.max(8));
|
|
||||||
let data = (index, track, x, x + width);
|
let data = (index, track, x, x + width);
|
||||||
x += width + Self::TRACK_SPACING;
|
x += width + Self::TRACK_SPACING;
|
||||||
data
|
data
|
||||||
|
|
@ -34,78 +28,87 @@ pub trait TracksView:
|
||||||
((x2 as u16) < self.tracks_width_available())
|
((x2 as u16) < self.tracks_width_available())
|
||||||
.then_some((t, track, x1, x2)))
|
.then_some((t, track, x1, x2)))
|
||||||
}
|
}
|
||||||
|
fn view_track_row_section <'a> (
|
||||||
|
&'a self,
|
||||||
|
theme: ItemTheme,
|
||||||
|
button: impl Content<TuiOut>,
|
||||||
|
button_add: impl Content<TuiOut>,
|
||||||
|
content: impl Content<TuiOut>
|
||||||
|
) -> impl Content<TuiOut> {
|
||||||
|
Bsp::w(
|
||||||
|
Fixed::x(4, button_add),
|
||||||
|
Bsp::e(
|
||||||
|
Fixed::x(20, Align::w(button)),
|
||||||
|
content
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
fn view_track_header <'a, T: Content<TuiOut>> (
|
fn view_track_header <'a, T: Content<TuiOut>> (
|
||||||
&'a self, theme: ItemTheme, content: T
|
&'a self, theme: ItemTheme, content: T
|
||||||
) -> impl Content<TuiOut> {
|
) -> impl Content<TuiOut> {
|
||||||
Fixed::x(12, Tui::bg(theme.darker.rgb, Fill::x(Align::e(content))))
|
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 Content<TuiOut> {
|
||||||
let content = Fixed::y(1, Align::w(Tui::bg(theme.darker.rgb, Align::w(Fill::x(
|
self.view_track_row_section(
|
||||||
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
theme,
|
||||||
for (index, track, x1, x2) in self.tracks_with_sizes() {
|
button_2("t", "rack", false),
|
||||||
add(&Fixed::x(track.width as u16,
|
button_2("T", "+", false),
|
||||||
Tui::bg(if self.selection().track() == Some(index) {
|
Fixed::y(1, Align::w(Tui::bg(theme.darker.rgb, Align::w(Fill::x(
|
||||||
track.color.light.rgb
|
|
||||||
} else {
|
|
||||||
track.color.base.rgb
|
|
||||||
}, Align::nw(Tui::fg(
|
|
||||||
Rgb(255, 255, 255), Tui::bold(true,
|
|
||||||
format!("{}", track.name)))))));
|
|
||||||
}
|
|
||||||
}))))));
|
|
||||||
Bsp::w(
|
|
||||||
self.view_track_header(theme, row!(
|
|
||||||
Tui::bold(true, button_2("t", "rack ", false)),
|
|
||||||
button_2("T", "+", false)
|
|
||||||
)),
|
|
||||||
content
|
|
||||||
)
|
|
||||||
}
|
|
||||||
fn view_track_outputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> {
|
|
||||||
let mut max_outputs = 0u16;
|
|
||||||
for track in self.tracks().iter() {
|
|
||||||
max_outputs = max_outputs.max(track.sequencer.midi_outs.len() as u16);
|
|
||||||
}
|
|
||||||
let content = Align::w(Fixed::y(1 + max_outputs*2,
|
|
||||||
Tui::bg(theme.darker.rgb, Align::w(Fill::x(
|
|
||||||
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||||
for (index, track, x1, x2) in self.tracks_with_sizes() {
|
for (index, track, x1, x2) in self.tracks_with_sizes() {
|
||||||
add(&Fixed::x(track.width as u16, Align::nw(Bsp::n(
|
add(&Fixed::x(track.width as u16,
|
||||||
Tui::bg(if self.selection().track() == Some(index) {
|
Tui::bg(if self.selection().track() == Some(index) {
|
||||||
track.color.light.rgb
|
track.color.light.rgb
|
||||||
} else {
|
} else {
|
||||||
track.color.base.rgb
|
track.color.base.rgb
|
||||||
}, Fill::x(Align::w(format!("·mute ·solo")))),
|
}, Align::nw(Bsp::e(
|
||||||
Map::south(2, ||track.sequencer.midi_outs.iter(),
|
format!("·t{index:02} "),
|
||||||
|port, index|Tui::fg(Rgb(255, 255, 255),
|
Tui::fg(Rgb(255, 255, 255), Tui::bold(true, &track.name))
|
||||||
Fixed::y(2, Tui::bg(track.color.dark.rgb, Fill::x(Align::w(
|
)))));
|
||||||
format!("·o{index}: {}", port.name())))))))))));
|
|
||||||
}
|
}
|
||||||
}))))));
|
})))))))
|
||||||
Bsp::w(
|
}
|
||||||
self.view_track_header(theme, row!(
|
fn view_track_outputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||||
Tui::bold(true, button_2("o", "utput", false)),
|
let mut h = 0u16;
|
||||||
button_2("O", "+", false)
|
for track in self.tracks().iter() {
|
||||||
)),
|
h = h.max(track.sequencer.midi_outs.len() as u16);
|
||||||
content
|
}
|
||||||
)
|
self.view_track_row_section(
|
||||||
|
theme,
|
||||||
|
button_2("o", "utput", false),
|
||||||
|
button_2("O", "+", false),
|
||||||
|
Align::w(Fixed::y(1 + h*2,
|
||||||
|
Tui::bg(theme.darker.rgb, Align::w(Fill::x(
|
||||||
|
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||||
|
for (index, track, x1, x2) in self.tracks_with_sizes() {
|
||||||
|
add(&Fixed::x(track.width as u16, Align::nw(Bsp::n(
|
||||||
|
Tui::bg(if self.selection().track() == Some(index) {
|
||||||
|
track.color.light.rgb
|
||||||
|
} else {
|
||||||
|
track.color.base.rgb
|
||||||
|
}, Fill::x(Align::w(format!("·mute ·solo")))),
|
||||||
|
Map::south(2, ||track.sequencer.midi_outs.iter(),
|
||||||
|
|port, index|Tui::fg(Rgb(255, 255, 255),
|
||||||
|
Fixed::y(2, Tui::bg(track.color.dark.rgb, Fill::x(Align::w(
|
||||||
|
format!("·o{index:02} {}", port.name())))))))))));
|
||||||
|
}
|
||||||
|
})))))))
|
||||||
}
|
}
|
||||||
fn view_track_devices <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> {
|
fn view_track_devices <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||||
let mut h = 2u16;
|
let mut h = 2u16;
|
||||||
for track in self.tracks().iter() {
|
for track in self.tracks().iter() {
|
||||||
h = h.max(track.devices.len() as u16);
|
h = h.max(track.devices.len() as u16);
|
||||||
}
|
}
|
||||||
Bsp::w(
|
self.view_track_row_section(
|
||||||
self.view_track_header(theme, row!(
|
theme,
|
||||||
Tui::bold(true, button_2("d", "evice", false)),
|
button_2("d", "evice", false),
|
||||||
button_2("D", "+", false)
|
button_2("D", "+", false),
|
||||||
)),
|
|
||||||
Fixed::y(h, Tui::bg(theme.darker.rgb, Align::w(Fill::x(Stack::east(
|
Fixed::y(h, Tui::bg(theme.darker.rgb, Align::w(Fill::x(Stack::east(
|
||||||
move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||||
for (index, track, x1, x2) in self.tracks_with_sizes() {
|
for (index, track, x1, x2) in self.tracks_with_sizes() {
|
||||||
add(&Fixed::xy(track.width as u16, h + 1,
|
add(&Fixed::xy(track.width as u16, h + 1,
|
||||||
Tui::bg(track.color.dark.rgb, Align::nw(Map::south(1, move||0..h,
|
Tui::bg(track.color.dark.rgb, Align::nw(Map::south(1, move||0..h,
|
||||||
|_, index|format!("·d{index}: {}", "--------"))))));
|
|_, index|format!("·d{index:02} {}", "--------"))))));
|
||||||
}
|
}
|
||||||
}))))))
|
}))))))
|
||||||
}
|
}
|
||||||
|
|
@ -114,26 +117,21 @@ pub trait TracksView:
|
||||||
for track in self.tracks().iter() {
|
for track in self.tracks().iter() {
|
||||||
h = h.max(track.sequencer.midi_ins.len() as u16);
|
h = h.max(track.sequencer.midi_ins.len() as u16);
|
||||||
}
|
}
|
||||||
let content = Tui::bg(theme.darker.rgb, Align::w(Fill::x(
|
self.view_track_row_section(
|
||||||
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
theme,
|
||||||
for (index, track, x1, x2) in self.tracks_with_sizes() {
|
button_2("i", "nput", false),
|
||||||
add(&Fixed::xy(track.width as u16, h + 1,
|
button_2("I", "+", false),
|
||||||
Align::nw(Bsp::s(
|
Tui::bg(theme.darker.rgb, Align::w(Fill::x(
|
||||||
Tui::bg(track.color.base.rgb,
|
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||||
Fill::x(Align::w(format!("·mon ·rec ·dub")))),
|
for (index, track, x1, x2) in self.tracks_with_sizes() {
|
||||||
Map::south(1, ||track.sequencer.midi_ins.iter(),
|
add(&Fixed::xy(track.width as u16, h + 1,
|
||||||
|port, index|Tui::fg_bg(Rgb(255, 255, 255), track.color.dark.rgb,
|
Align::nw(Bsp::s(
|
||||||
Fill::x(Align::w(format!("·i{index}: {}", port.name())))))))));
|
Tui::bg(track.color.base.rgb,
|
||||||
}
|
Fill::x(Align::w(format!("·mon ·rec ·dub")))),
|
||||||
|
Map::south(1, ||track.sequencer.midi_ins.iter(),
|
||||||
}))));
|
|port, index|Tui::fg_bg(Rgb(255, 255, 255), track.color.dark.rgb,
|
||||||
Bsp::w(
|
Fill::x(Align::w(format!("·i{index:02} {}", port.name())))))))));
|
||||||
self.view_track_header(theme, row!(
|
}})))))
|
||||||
Tui::bold(true, button_2("i", "nputs", false)),
|
|
||||||
button_2("I", "+", false)
|
|
||||||
)),
|
|
||||||
Fixed::y(h, Fill::x(Align::w(Fixed::y(h + 1, content)))),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,8 +163,8 @@ pub trait ScenesView: HasEditor + HasSelection + HasSceneScroll + Send + Sync {
|
||||||
};
|
};
|
||||||
Fixed::xy(20, h, Tui::bg(bg, Align::nw(Bsp::s(
|
Fixed::xy(20, h, Tui::bg(bg, Align::nw(Bsp::s(
|
||||||
Fill::x(Align::w(Bsp::e(
|
Fill::x(Align::w(Bsp::e(
|
||||||
format!(" {index:2} "),
|
format!("·s{index:02} "),
|
||||||
Tui::fg(Rgb(255, 255, 255), Tui::bold(true, format!("{}", scene.name)))
|
Tui::fg(Rgb(255, 255, 255), Tui::bold(true, &scene.name))
|
||||||
))),
|
))),
|
||||||
When(self.selection().scene() == Some(index) && self.is_editing(),
|
When(self.selection().scene() == Some(index) && self.is_editing(),
|
||||||
Fill::xy(Align::nw(Bsp::s(
|
Fill::xy(Align::nw(Bsp::s(
|
||||||
|
|
@ -202,18 +200,18 @@ pub trait ClipsView: TracksView + ScenesView + Send + Sync {
|
||||||
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 Content<TuiOut> + 'a {
|
||||||
Stack::south(move|cell: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
Stack::south(move|cell: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||||
for (scene_index, scene) in self.scenes().iter().enumerate().skip(self.scene_scroll()) {
|
for (scene_index, scene) in self.scenes().iter().enumerate().skip(self.scene_scroll()) {
|
||||||
let (name, theme) = if let Some(Some(clip)) = &scene.clips.get(track_index) {
|
let (name, theme): (Arc<str>, ItemTheme) = if let Some(Some(clip)) = &scene.clips.get(track_index) {
|
||||||
let clip = clip.read().unwrap();
|
let clip = clip.read().unwrap();
|
||||||
(Some(clip.name.clone()), clip.color)
|
(clip.name.clone(), clip.color)
|
||||||
} else {
|
} else {
|
||||||
(None, ItemTheme::G[32])
|
(" ---- ".into(), ItemTheme::G[32])
|
||||||
};
|
};
|
||||||
let fg = theme.lightest.rgb;
|
let fg = theme.lightest.rgb;
|
||||||
let mut outline = theme.base.rgb;
|
let mut outline = theme.base.rgb;
|
||||||
let bg = if self.selection().track() == Some(track_index)
|
let bg = if self.selection().track() == Some(track_index)
|
||||||
&& self.selection().scene() == Some(scene_index)
|
&& self.selection().scene() == Some(scene_index)
|
||||||
{
|
{
|
||||||
outline = theme.lightest.rgb;
|
outline = theme.lighter.rgb;
|
||||||
theme.light.rgb
|
theme.light.rgb
|
||||||
} else if self.selection().track() == Some(track_index)
|
} else if self.selection().track() == Some(track_index)
|
||||||
|| self.selection().scene() == Some(scene_index)
|
|| self.selection().scene() == Some(scene_index)
|
||||||
|
|
@ -223,28 +221,30 @@ pub trait ClipsView: TracksView + ScenesView + Send + Sync {
|
||||||
} else {
|
} else {
|
||||||
theme.dark.rgb
|
theme.dark.rgb
|
||||||
};
|
};
|
||||||
cell(&Fixed::xy(
|
let w = if self.selection().track() == Some(track_index)
|
||||||
if self.selection().track() == Some(track_index)
|
&& let Some(editor) = self.editor ()
|
||||||
&& let Some(editor) = self.editor ()
|
{
|
||||||
{
|
editor.width().max(24).max(track.width)
|
||||||
editor.width().max(24).max(track.width)
|
} else {
|
||||||
} else {
|
track.width
|
||||||
track.width
|
} as u16;
|
||||||
} as u16,
|
let y = if self.selection().scene() == Some(scene_index)
|
||||||
if self.selection().scene() == Some(scene_index)
|
&& let Some(editor) = self.editor ()
|
||||||
&& let Some(editor) = self.editor ()
|
{
|
||||||
{
|
editor.height().max(12)
|
||||||
editor.height().max(12)
|
} else {
|
||||||
} else {
|
Self::H_SCENE
|
||||||
Self::H_SCENE
|
} as u16;
|
||||||
} as u16,
|
cell(&Fixed::xy(w, y, Bsp::b(
|
||||||
Bsp::b(
|
Fill::xy(Outer(true, Style::default().fg(outline))),
|
||||||
Fill::xy(Outer(true, Style::default().fg(outline))),
|
Fill::xy(Bsp::b(
|
||||||
Fill::xy(Bsp::b(
|
Bsp::b(
|
||||||
Fill::xy(Align::nw(Tui::fg_bg(fg, bg, Align::nw(name.unwrap_or(" ---- ".into()))))),
|
Tui::fg_bg(outline, bg, Fill::xy("")),
|
||||||
Fill::xy(When(self.selection().track() == Some(track_index)
|
Fill::xy(Align::nw(Tui::fg_bg(fg, bg, Tui::bold(true, name)))),
|
||||||
&& self.selection().scene() == Some(scene_index)
|
),
|
||||||
&& self.is_editing(), self.editor())))))));
|
Fill::xy(When(self.selection().track() == Some(track_index)
|
||||||
|
&& self.selection().scene() == Some(scene_index)
|
||||||
|
&& self.is_editing(), self.editor())))))));
|
||||||
//let (name, theme) = if let Some(clip) = &scene.clips.get(track_index).flatten() {
|
//let (name, theme) = if let Some(clip) = &scene.clips.get(track_index).flatten() {
|
||||||
//let clip = clip.read().unwrap();
|
//let clip = clip.read().unwrap();
|
||||||
//(Some(clip.name.clone()), clip.color)
|
//(Some(clip.name.clone()), clip.color)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue