generalize Fixed and bring back some more of the arranger

This commit is contained in:
🪞👃🪞 2024-09-17 00:38:22 +03:00
parent d577449b72
commit 2352b72377
4 changed files with 51 additions and 52 deletions

View file

@ -359,12 +359,12 @@ impl<'a, 'b> Content for ArrangerViewVertical<'a, 'b, Tui> {
let Self(state, cols, rows) = self;
let tracks = state.tracks.as_ref();
let scenes = state.scenes.as_ref();
let offset = 3 + scene_name_max_len(scenes) as u16;
let offset = 4 + scene_name_max_len(scenes) as u16;
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(&RowSeparators(rows))?;
add(&CursorFocus(state.selected, offset, cols, rows))?;
add(&CursorFocus(state.focused, state.selected, offset, cols, rows))?;
add(&Split::down(|add|{
add(&TracksHeader(offset, cols, tracks))?;
add(&SceneRows(offset, cols, rows, tracks, scenes))
@ -416,14 +416,14 @@ impl<'a> Widget for RowSeparators<'a> {
}
struct CursorFocus<'a>(
ArrangerFocus, u16, &'a [(usize, usize)], &'a [(usize, usize)]
bool, ArrangerFocus, u16, &'a [(usize, usize)], &'a [(usize, usize)]
);
impl<'a> Widget for CursorFocus<'a> {
type Engine = Tui;
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
let area = to.area();
let Self(selected, offset, cols, rows) = *self;
let Self(focused, selected, offset, cols, rows) = *self;
let get_track_area = |t: usize| [
offset + area.x() + cols[t].1 as u16 - 1,
area.y(),
@ -447,7 +447,9 @@ impl<'a> Widget for CursorFocus<'a> {
let mut clip_area: Option<[u16;4]> = None;
let area = match selected {
ArrangerFocus::Mix => {
to.fill_bg(area, COLOR_BG0);
if focused {
to.fill_bg(area, COLOR_BG0);
}
area
},
ArrangerFocus::Track(t) => {
@ -473,12 +475,14 @@ impl<'a> Widget for CursorFocus<'a> {
to.fill_ul([area.x(), y - 1, area.w(), 1], COLOR_BG5);
to.fill_ul([area.x(), y + height - 1, area.w(), 1], COLOR_BG5);
}
if let Some(clip_area) = clip_area {
to.fill_bg(clip_area, COLOR_BG0);
} else if let Some(track_area) = track_area {
to.fill_bg(track_area, COLOR_BG0);
} else if let Some(scene_area) = scene_area {
to.fill_bg(scene_area, COLOR_BG0);
if focused {
if let Some(clip_area) = clip_area {
to.fill_bg(clip_area, COLOR_BG0);
} else if let Some(track_area) = track_area {
to.fill_bg(track_area, COLOR_BG0);
} else if let Some(scene_area) = scene_area {
to.fill_bg(scene_area, COLOR_BG0);
}
}
//Ok(Some(area))
Ok(())
@ -515,9 +519,7 @@ impl<'a> Content for SceneRows<'a> {
let Self(offset, columns, rows, tracks, scenes) = *self;
Split::down(move |add| {
for (scene, (pulses, _)) in scenes.iter().zip(rows) {
add(&Fixed::X(1.max((pulses / 96) as u16), SceneRow(
tracks, scene, columns, offset
)))?;
add(&SceneRow(tracks, scene, columns, offset, 1.max((pulses / 96) as u16)))?;
}
Ok(())
})
@ -525,28 +527,24 @@ impl<'a> Content for SceneRows<'a> {
}
struct SceneRow<'a>(
&'a[Sequencer<Tui>], &'a Scene, &'a[(usize, usize)], u16
&'a[Sequencer<Tui>], &'a Scene, &'a[(usize, usize)], u16, u16
);
impl<'a> Content for SceneRow<'a> {
type Engine = Tui;
fn content (&self) -> impl Widget<Engine = Tui> {
let Self(tracks, scene, columns, _offset) = self;
let Self(tracks, scene, columns, offset, height) = self;
let playing = scene.is_playing(tracks);
Split::right(move |add| {
add(&Layers::new(|add|{
//add(&Split::right(|add|{
//add(&if playing { "▶" } else { " " })?;
add(&scene.name.read().unwrap().as_str())?;
//}))?;
//add(&Background(COLOR_BG1))
Ok(())
}))?;
//for (track, (_w, _x)) in columns.iter().enumerate() {
//add(&SceneClip(tracks.get(track), scene.clips.get(track)))?;
//}
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(&SceneClip(tracks.get(track), scene.clips.get(track)))?;
}
Ok(())
})
}))
}
}

View file

@ -262,7 +262,7 @@ impl Content for TransportPlayPauseButton<Tui> {
type Engine = Tui;
fn content (&self) -> impl Widget<Engine = Tui> {
Layers::new(|add|{
add(&Plus::X(1, Min::Y(2, Styled(match self.value {
add(&Plus::X(1, Min::XY(11, 2, Styled(match self.value {
Some(TransportState::Stopped) => Some(GRAY_DIM.bold()),
Some(TransportState::Starting) => Some(GRAY_NOT_DIM_BOLD),
Some(TransportState::Rolling) => Some(WHITE_NOT_DIM_BOLD),