mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
merge SceneRows and TracksHeader into ArrangerViewVertical
This commit is contained in:
parent
647cd06060
commit
6660416fd2
2 changed files with 46 additions and 72 deletions
|
|
@ -357,17 +357,59 @@ impl<'a, 'b> Content for ArrangerViewVertical<'a, 'b, Tui> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
let Self(state, cols, rows) = self;
|
let Self(state, cols, rows) = self;
|
||||||
let tracks = state.tracks.as_ref();
|
let tracks: &[Sequencer<Tui>] = state.tracks.as_ref();
|
||||||
let scenes = state.scenes.as_ref();
|
let scenes = state.scenes.as_ref();
|
||||||
let offset = 4 + scene_name_max_len(scenes) as u16;
|
let offset = 4 + scene_name_max_len(scenes) as u16;
|
||||||
Layers::new(move |add|{
|
Layers::new(move |add|{
|
||||||
//.add_ref(&Background(Color::Rgb(30, 33, 36)))//COLOR_BG1))//bg_lo(state.focused, state.entered)))
|
|
||||||
add(&ColumnSeparators(offset, cols))?;
|
add(&ColumnSeparators(offset, cols))?;
|
||||||
add(&RowSeparators(rows))?;
|
add(&RowSeparators(rows))?;
|
||||||
add(&CursorFocus(state.focused, state.selected, offset, cols, rows))?;
|
add(&CursorFocus(state.focused, state.selected, offset, cols, rows))?;
|
||||||
add(&Split::down(|add|{
|
add(&Split::down(|add|{
|
||||||
add(&TracksHeader(offset, cols, tracks))?;
|
add(&Plus::X(offset, Split::right(move |add|{
|
||||||
add(&SceneRows(offset, cols, rows, tracks, scenes))
|
for (track, (w, _)) in tracks.iter().zip(*cols) {
|
||||||
|
add(&Min::XY(*w as u16, 2, Layers::new(|add|{
|
||||||
|
add(&Background(COLOR_BG1))?;
|
||||||
|
add(&track.name.read().unwrap().as_str())
|
||||||
|
})))?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
})))?;
|
||||||
|
add(&Split::down(move |add| {
|
||||||
|
for (scene, (pulses, _)) in scenes.iter().zip(*rows) {
|
||||||
|
let height = 1.max((pulses / 96) as u16);
|
||||||
|
let playing = scene.is_playing(tracks);
|
||||||
|
add(&Fixed::Y(height, Split::right(move |add| {
|
||||||
|
add(&Fixed::XY(offset.saturating_sub(1), height, Split::right(|add|{
|
||||||
|
add(&if playing { "▶ " } else { " " })?;
|
||||||
|
add(&scene.name.read().unwrap().as_str())
|
||||||
|
})))?;
|
||||||
|
for (track, (w, _x)) in cols.iter().enumerate() {
|
||||||
|
add(&Fixed::XY(*w as u16, height, Layers::new(move |add|{
|
||||||
|
let mut color = COLOR_BG0;
|
||||||
|
if let (Some(track), Some(Some(clip))) = (
|
||||||
|
tracks.get(track),
|
||||||
|
scene.clips.get(track),
|
||||||
|
) {
|
||||||
|
if let Some(phrase) = track.phrases.get(*clip) {
|
||||||
|
add(&Plus::X(1, format!(
|
||||||
|
"{clip:02} {}",
|
||||||
|
phrase.read().unwrap().name.read().unwrap()
|
||||||
|
).as_str()))?;
|
||||||
|
color = if track.sequence == Some(*clip) {
|
||||||
|
Nord::PLAYING
|
||||||
|
} else {
|
||||||
|
COLOR_BG1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add(&Background(color))
|
||||||
|
})))?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
})))?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}))
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -489,73 +531,6 @@ impl<'a> Widget for CursorFocus<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TracksHeader<'a>(
|
|
||||||
u16, &'a[(usize, usize)], &'a [Sequencer<Tui>]
|
|
||||||
);
|
|
||||||
|
|
||||||
impl<'a> Content for TracksHeader<'a> {
|
|
||||||
type Engine = Tui;
|
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
|
||||||
let Self(offset, columns, tracks) = *self;
|
|
||||||
Plus::X(offset, Split::right(move |add|{
|
|
||||||
for (track, (w, _)) in tracks.iter().zip(columns) {
|
|
||||||
add(&Min::XY(*w as u16, 2, Layers::new(|add|{
|
|
||||||
add(&Background(COLOR_BG1))?;
|
|
||||||
add(&track.name.read().unwrap().as_str())
|
|
||||||
})))?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SceneRows<'a>(
|
|
||||||
u16, &'a[(usize, usize)], &'a[(usize, usize)], &'a[Sequencer<Tui>], &'a[Scene]
|
|
||||||
);
|
|
||||||
|
|
||||||
impl<'a> Content for SceneRows<'a> {
|
|
||||||
type Engine = Tui;
|
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
|
||||||
let Self(offset, columns, rows, tracks, scenes) = *self;
|
|
||||||
Split::down(move |add| {
|
|
||||||
for (scene, (pulses, _)) in scenes.iter().zip(rows) {
|
|
||||||
let height = 1.max((pulses / 96) as u16);
|
|
||||||
let playing = scene.is_playing(tracks);
|
|
||||||
add(&Fixed::Y(height, Split::right(move |add| {
|
|
||||||
add(&Fixed::XY(offset.saturating_sub(1), height, Split::right(|add|{
|
|
||||||
add(&if playing { "▶ " } else { " " })?;
|
|
||||||
add(&scene.name.read().unwrap().as_str())
|
|
||||||
})))?;
|
|
||||||
for (track, (w, _x)) in columns.iter().enumerate() {
|
|
||||||
add(&Fixed::XY(*w as u16, height, Layers::new(move |add|{
|
|
||||||
let mut color = COLOR_BG0;
|
|
||||||
if let (Some(track), Some(Some(clip))) = (
|
|
||||||
tracks.get(track),
|
|
||||||
scene.clips.get(track),
|
|
||||||
) {
|
|
||||||
if let Some(phrase) = track.phrases.get(*clip) {
|
|
||||||
add(&Plus::X(1, format!(
|
|
||||||
"{clip:02} {}",
|
|
||||||
phrase.read().unwrap().name.read().unwrap()
|
|
||||||
).as_str()))?;
|
|
||||||
color = if track.sequence == Some(*clip) {
|
|
||||||
Nord::PLAYING
|
|
||||||
} else {
|
|
||||||
COLOR_BG1
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
add(&Background(color))
|
|
||||||
})))?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
})))?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ArrangerViewHorizontal<'a, E: Engine>(
|
struct ArrangerViewHorizontal<'a, E: Engine>(
|
||||||
&'a Arranger<E>
|
&'a Arranger<E>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use tek_core::Direction;
|
|
||||||
|
|
||||||
/// Phrase editor.
|
/// Phrase editor.
|
||||||
pub struct Sequencer<E: Engine> {
|
pub struct Sequencer<E: Engine> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue