mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
style editor stats as commands
This commit is contained in:
parent
2858b01bd4
commit
9fcb5a08c6
3 changed files with 60 additions and 62 deletions
|
|
@ -39,6 +39,14 @@ impl ArrangementCommand {
|
|||
}
|
||||
}
|
||||
};
|
||||
if let Some(editor) = arranger.editor.as_mut() {
|
||||
if let Some(clip) = editor.clip() {
|
||||
let length = clip.read().unwrap().length.max(1);
|
||||
let width = arranger.inner_size.w().saturating_sub(20).max(1);
|
||||
editor.set_time_zoom(length / width);
|
||||
editor.redraw();
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
/// Set the selection
|
||||
|
|
|
|||
|
|
@ -2,21 +2,19 @@ use crate::*;
|
|||
|
||||
impl Arrangement {
|
||||
pub fn view_inputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> + 'a {
|
||||
let mut h = 0;
|
||||
let mut h = 1u16;
|
||||
for track in self.tracks().iter() {
|
||||
h = h.max(self.midi_ins.len() as u16);
|
||||
}
|
||||
let h = h + 1;
|
||||
self.view_track_row_section(
|
||||
theme,
|
||||
Bsp::s(
|
||||
Fixed::y(1, Fill::x(Align::w(button_3("i", "nput ", format!("{}", self.midi_ins.len()), false)))),
|
||||
Fixed::y(h - 1, Fill::x(Align::nw(Stack::south(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
for (index, port) in self.midi_ins.iter().enumerate() {
|
||||
add(&Fill::x(Align::w(format!("·i{index:02} {}", port.name()))));
|
||||
}
|
||||
}))))),
|
||||
button_2("I", "+", false),
|
||||
let list = Bsp::s(
|
||||
Fixed::y(1, Fill::x(Align::w(button_3("i", "nput ", format!("{}", self.midi_ins.len()), false)))),
|
||||
Fixed::y(h - 1, Fill::x(Align::nw(Stack::south(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
for (index, port) in self.midi_ins.iter().enumerate() {
|
||||
add(&Fill::x(Align::w(format!("·i{index:02} {}", port.name()))));
|
||||
}
|
||||
})))));
|
||||
self.view_track_row_section(theme, list, button_2("I", "+", false),
|
||||
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() {
|
||||
|
|
@ -41,16 +39,14 @@ impl Arrangement {
|
|||
h = h.max(track.sequencer.midi_outs.len() as u16);
|
||||
}
|
||||
let h = h + 1;
|
||||
self.view_track_row_section(
|
||||
theme,
|
||||
Bsp::s(
|
||||
Fixed::y(1, Fill::x(Align::w(button_3("o", "utput", format!("{}", self.midi_outs.len()), false)))),
|
||||
Fixed::y(h - 1, Fill::xy(Align::nw(Stack::south(|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
for (index, port) in self.midi_outs().iter().enumerate() {
|
||||
add(&Fill::x(Align::w(format!("·o{index:02} {}", port.name()))));
|
||||
}
|
||||
}))))),
|
||||
button_2("O", "+", false),
|
||||
let list = Bsp::s(
|
||||
Fixed::y(1, Fill::x(Align::w(button_3("o", "utput", format!("{}", self.midi_outs.len()), false)))),
|
||||
Fixed::y(h - 1, Fill::xy(Align::nw(Stack::south(|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
for (index, port) in self.midi_outs().iter().enumerate() {
|
||||
add(&Fill::x(Align::w(format!("·o{index:02} {}", port.name()))));
|
||||
}
|
||||
})))));
|
||||
self.view_track_row_section(theme, list, button_2("O", "+", false),
|
||||
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() {
|
||||
|
|
@ -64,11 +60,10 @@ impl Arrangement {
|
|||
add(&Fixed::y(1, Align::w(Bsp::e(
|
||||
Either(true, Tui::fg(Green, "●play "), "·play "),
|
||||
Either(false, Tui::fg(Yellow, "●solo "), "·solo "),
|
||||
|
||||
))));
|
||||
}
|
||||
})));
|
||||
}
|
||||
})))))
|
||||
})))}})))))
|
||||
}
|
||||
pub fn view_track_devices <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> + 'a {
|
||||
let mut h = 2u16;
|
||||
|
|
@ -79,14 +74,13 @@ impl Arrangement {
|
|||
theme,
|
||||
button_3("d", "evice", format!("{}", self.track().map(|t|t.devices.len()).unwrap_or(0)), false),
|
||||
button_2("D", "+", false),
|
||||
Fixed::y(h, 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::xy(self.track_width(index, track), h + 1,
|
||||
Tui::bg(track.color.dark.rgb, Align::nw(Map::south(1, move||0..h,
|
||||
|_, index|format!("·d{index:02} {}", "--------"))))));
|
||||
}
|
||||
}))))))
|
||||
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
for (index, track, x1, x2) in self.tracks_with_sizes() {
|
||||
add(&Fixed::xy(self.track_width(index, track), h + 1,
|
||||
Tui::bg(track.color.dark.rgb, Align::nw(Map::south(1, move||0..h,
|
||||
|_, index|format!("·d{index:02} {}", "--------"))))));
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -137,13 +131,8 @@ pub trait TracksView:
|
|||
button_add: impl Content<TuiOut>,
|
||||
content: impl Content<TuiOut>
|
||||
) -> impl Content<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))
|
||||
)
|
||||
)
|
||||
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
|
||||
|
|
@ -231,13 +220,7 @@ pub trait TracksView:
|
|||
}})))))
|
||||
}
|
||||
fn track_width (&self, index: usize, track: &Track) -> u16 {
|
||||
(if self.selection().track() == Some(index)
|
||||
&& let Some(editor) = self.editor()
|
||||
{
|
||||
editor.width().max(24).max(track.width)
|
||||
} else {
|
||||
track.width
|
||||
}) as u16
|
||||
track.width as u16
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -264,8 +247,6 @@ pub trait ScenesView:
|
|||
let selected_scene = self.selection().scene();
|
||||
let mut y = 0;
|
||||
self.scenes().iter().enumerate().skip(self.scene_scroll()).map_while(move|(s, scene)|{
|
||||
let active = editing && selected_track.is_some() && selected_scene == Some(s);
|
||||
let height = if active { larger } else { height };
|
||||
if y + height <= self.clips_size().h() {
|
||||
let data = (s, scene, y, y + height);
|
||||
y += height;
|
||||
|
|
@ -284,7 +265,7 @@ pub trait ScenesView:
|
|||
}
|
||||
fn view_scene_name (&self, index: usize, scene: &Scene) -> impl Content<TuiOut> {
|
||||
let h = if self.selection().scene() == Some(index) && let Some(editor) = self.editor() {
|
||||
(editor.height() as u16).max(12)
|
||||
7
|
||||
} else {
|
||||
Self::H_SCENE as u16
|
||||
};
|
||||
|
|
@ -321,13 +302,7 @@ pub trait ClipsView:
|
|||
for (track_index, track, _, _) in self.tracks_with_sizes() {
|
||||
//column(&Fixed::x(5, Fill::xy(Tui::bg(Green, "kyp"))));
|
||||
column(&Fixed::x(
|
||||
if self.selection().track() == Some(track_index)
|
||||
&& let Some(editor) = self.editor()
|
||||
{
|
||||
editor.width().max(24).max(track.width)
|
||||
} else {
|
||||
track.width
|
||||
} as u16,
|
||||
track.width as u16,
|
||||
Fill::y(self.view_track_clips(track_index, track))
|
||||
))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,15 @@ impl MidiEditor {
|
|||
(clip.color, clip.name.clone(), clip.length, clip.looped)
|
||||
} else { (ItemTheme::G[64], String::new().into(), 0, false) };
|
||||
Fixed::x(20, col!(
|
||||
Fill::x(Align::w(Bsp::e(" Clip ", format!("{name}")))),
|
||||
Fill::x(Align::w(Bsp::e(" Length ", format!("{length}")))),
|
||||
Fill::x(Align::w(Bsp::e(" Loop ", looped.to_string()))),
|
||||
Fill::x(Align::w(Bsp::e(
|
||||
button_2("f2", "name ", false),
|
||||
Fill::x(Align::e(Tui::fg(Rgb(255, 255, 255), format!("{name} "))))))),
|
||||
Fill::x(Align::w(Bsp::e(
|
||||
button_2("l", "ength ", false),
|
||||
Fill::x(Align::e(Tui::fg(Rgb(255, 255, 255), format!("{length} "))))))),
|
||||
Fill::x(Align::w(Bsp::e(
|
||||
button_2("r", "epeat ", false),
|
||||
Fill::x(Align::e(Tui::fg(Rgb(255, 255, 255), format!("{looped} "))))))),
|
||||
))
|
||||
}
|
||||
|
||||
|
|
@ -31,9 +37,18 @@ impl MidiEditor {
|
|||
let note_pos = format!("{:>3}", note_pos);
|
||||
let note_len = format!("{:>4}", self.get_note_len());
|
||||
Fixed::x(20, col!(
|
||||
Fill::x(Align::w(Bsp::e(" Time ", format!("{length}/{time_zoom}+{time_pos}")))),
|
||||
Fill::x(Align::w(Bsp::e(" Lock ", format!("{time_lock}")))),
|
||||
Fill::x(Align::w(Bsp::e(" Note ", format!("{note_name} {note_pos} {note_len}")))),
|
||||
Fill::x(Align::w(Bsp::e(
|
||||
button_2("t", "ime ", false),
|
||||
Fill::x(Align::e(Tui::fg(Rgb(255, 255, 255),
|
||||
format!("{length} /{time_zoom} +{time_pos} "))))))),
|
||||
Fill::x(Align::w(Bsp::e(
|
||||
button_2("z", "lock ", false),
|
||||
Fill::x(Align::e(Tui::fg(Rgb(255, 255, 255),
|
||||
format!("{time_lock}"))))))),
|
||||
Fill::x(Align::w(Bsp::e(
|
||||
button_2("x", "note ", false),
|
||||
Fill::x(Align::e(Tui::fg(Rgb(255, 255, 255),
|
||||
format!("{note_name} {note_pos} {note_len}"))))))),
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue