mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
refactor sequencer layout
This commit is contained in:
parent
ed7f96baca
commit
265d4a3953
1 changed files with 46 additions and 52 deletions
|
|
@ -56,31 +56,22 @@ impl<'a> Content for PhraseView<'a> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn content (&self) -> impl Render<Engine = Tui> {
|
fn content (&self) -> impl Render<Engine = Tui> {
|
||||||
let Self {
|
let Self {
|
||||||
focused,
|
focused, entered, size,
|
||||||
entered,
|
phrase, view_mode, buffer,
|
||||||
phrase,
|
note_point, note_len,
|
||||||
size,
|
|
||||||
buffer,
|
|
||||||
view_mode,
|
|
||||||
note_len,
|
|
||||||
note_range: (note_lo, note_hi),
|
note_range: (note_lo, note_hi),
|
||||||
note_names: (note_lo_name, note_hi_name),
|
note_names: (note_lo_name, note_hi_name),
|
||||||
note_point,
|
time_start, time_point,
|
||||||
time_start,
|
//now: _,
|
||||||
time_point,
|
|
||||||
now,
|
|
||||||
..
|
..
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
let upper_left = format!(
|
let upper_left = format!(
|
||||||
"╭{note_hi} {note_hi_name} {}",
|
"╭{note_hi} {note_hi_name} {}",
|
||||||
phrase.as_ref().map(|p|p.read().unwrap().name.clone()).unwrap_or(String::new())
|
phrase.as_ref().map(|p|p.read().unwrap().name.clone()).unwrap_or(String::new())
|
||||||
);
|
);
|
||||||
|
|
||||||
let lower_left = format!(
|
let lower_left = format!(
|
||||||
"╰{note_lo} {note_lo_name}"
|
"╰{note_lo} {note_lo_name}"
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut lower_right = format!(
|
let mut lower_right = format!(
|
||||||
" {} ", size.format()
|
" {} ", size.format()
|
||||||
);
|
);
|
||||||
|
|
@ -89,7 +80,6 @@ impl<'a> Content for PhraseView<'a> {
|
||||||
note_point, to_note_name(*note_point), pulses_to_name(*note_len)
|
note_point, to_note_name(*note_point), pulses_to_name(*note_len)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut upper_right = format!(
|
let mut upper_right = format!(
|
||||||
"[{}]",
|
"[{}]",
|
||||||
if *entered {"■"} else {" "}
|
if *entered {"■"} else {" "}
|
||||||
|
|
@ -99,51 +89,55 @@ impl<'a> Content for PhraseView<'a> {
|
||||||
time_point, phrase.read().unwrap().length, pulses_to_name(view_mode.time_zoom()),
|
time_point, phrase.read().unwrap().length, pulses_to_name(view_mode.time_zoom()),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let title_color = if *focused{Color::Rgb(150, 160, 90)}else{Color::Rgb(120, 130, 100)};
|
let title_color = if *focused{Color::Rgb(150, 160, 90)}else{Color::Rgb(120, 130, 100)};
|
||||||
|
// is it r6d that `to` is the receiver?
|
||||||
|
let keys = move|to: &mut TuiOutput|{
|
||||||
|
Ok(if to.area().h() >= 2 { view_mode.render_keys(to, *note_hi, *note_lo) })
|
||||||
|
};
|
||||||
|
let notes = |to: &mut TuiOutput|{
|
||||||
|
size.set_wh(to.area.w(), to.area.h() as usize - 1);
|
||||||
|
let draw = to.area().h() >= 2;
|
||||||
|
Ok(if draw { view_mode.render_notes(to, buffer, *time_start, *note_hi) })
|
||||||
|
};
|
||||||
|
let cursor = move|to: &mut TuiOutput|{
|
||||||
|
Ok(if *focused && *entered {
|
||||||
|
view_mode.render_cursor(
|
||||||
|
to,
|
||||||
|
*time_point, *time_start, view_mode.time_zoom(),
|
||||||
|
*note_point, *note_len, *note_hi, *note_lo,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
};
|
||||||
|
//let playhead = move|_: &mut TuiOutput|{ // will this live or die?
|
||||||
|
////let playhead_inactive = Style::default().fg(Color::Rgb(255,255,255)).bg(Color::Rgb(40,50,30));
|
||||||
|
////let playhead_active = playhead_inactive.clone().yellow().bold().not_dim();
|
||||||
|
////if let Some(_) = phrase {
|
||||||
|
////let now = now.get() as usize; // TODO FIXME: self.now % phrase.read().unwrap().length;
|
||||||
|
////let time_clamp = time_clamp;
|
||||||
|
////for x in 0..(time_clamp/time_zoom).saturating_sub(*time_start) {
|
||||||
|
////let this_step = time_start + (x + 0) * time_zoom;
|
||||||
|
////let next_step = time_start + (x + 1) * time_zoom;
|
||||||
|
////let x = to.area().x() + x as u16;
|
||||||
|
////let active = this_step <= now && now < next_step;
|
||||||
|
////let character = if active { "|" } else { "·" };
|
||||||
|
////let style = if active { playhead_active } else { playhead_inactive };
|
||||||
|
////to.blit(&character, x, to.area.y(), Some(style));
|
||||||
|
////}
|
||||||
|
////}
|
||||||
|
//Ok(())
|
||||||
|
//};
|
||||||
|
|
||||||
lay!(
|
lay!(
|
||||||
row!(
|
row!(
|
||||||
Widget::new(|to:[u16;2]|Ok(Some(to.clip_w(2))), move|to: &mut TuiOutput|{
|
Widget::new(|to:[u16;2]|Ok(Some(to.clip_w(2))), keys).fill_y().push_y(1),
|
||||||
Ok(if to.area().h() >= 2 { view_mode.render_keys(to, *note_hi, *note_lo) })
|
|
||||||
}).fill_y().push_y(1),
|
|
||||||
lay!(
|
lay!(
|
||||||
Widget::new(|to|Ok(Some(to)), |to: &mut TuiOutput|{
|
Widget::new(|to|Ok(Some(to)), notes).fill_x().push_y(1),
|
||||||
size.set_wh(to.area.w(), to.area.h() as usize - 1);
|
Widget::new(|to|Ok(Some(to)), cursor).push_y(1)
|
||||||
let draw = to.area().h() >= 2;
|
|
||||||
Ok(if draw { view_mode.render_notes(to, buffer, *time_start, *note_hi) })
|
|
||||||
}).fill_x().push_y(1),
|
|
||||||
Widget::new(|to|Ok(Some(to)), move|to: &mut TuiOutput|{
|
|
||||||
Ok(if *focused && *entered {
|
|
||||||
view_mode.render_cursor(
|
|
||||||
to,
|
|
||||||
*time_point, *time_start, view_mode.time_zoom(),
|
|
||||||
*note_point, *note_len, *note_hi, *note_lo,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}).push_y(1)
|
|
||||||
).fill_x()
|
).fill_x()
|
||||||
)
|
)
|
||||||
.fill_x()
|
.fill_x()
|
||||||
.bg(Color::Rgb(40, 50, 30)),
|
.bg(Color::Rgb(40, 50, 30)),
|
||||||
Widget::new(|to:[u16;2]|Ok(Some(to.clip_h(1))), move|to: &mut TuiOutput|{
|
//Widget::new(|to:[u16;2]|Ok(Some(to.clip_h(1))), playhead).push_x(6).align_sw(),
|
||||||
//let playhead_inactive = Style::default().fg(Color::Rgb(255,255,255)).bg(Color::Rgb(40,50,30));
|
|
||||||
//let playhead_active = playhead_inactive.clone().yellow().bold().not_dim();
|
|
||||||
//if let Some(_) = phrase {
|
|
||||||
//let now = now.get() as usize; // TODO FIXME: self.now % phrase.read().unwrap().length;
|
|
||||||
//let time_clamp = time_clamp;
|
|
||||||
//for x in 0..(time_clamp/time_zoom).saturating_sub(*time_start) {
|
|
||||||
//let this_step = time_start + (x + 0) * time_zoom;
|
|
||||||
//let next_step = time_start + (x + 1) * time_zoom;
|
|
||||||
//let x = to.area().x() + x as u16;
|
|
||||||
//let active = this_step <= now && now < next_step;
|
|
||||||
//let character = if active { "|" } else { "·" };
|
|
||||||
//let style = if active { playhead_active } else { playhead_inactive };
|
|
||||||
//to.blit(&character, x, to.area.y(), Some(style));
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
Ok(())
|
|
||||||
}).push_x(6).align_sw(),
|
|
||||||
TuiStyle::fg(upper_left.to_string(), title_color).align_nw(),
|
TuiStyle::fg(upper_left.to_string(), title_color).align_nw(),
|
||||||
TuiStyle::fg(lower_left.to_string(), title_color).align_sw(),
|
TuiStyle::fg(lower_left.to_string(), title_color).align_sw(),
|
||||||
TuiStyle::fg(upper_right.to_string(), title_color).pull_x(1).align_ne().fill_xy(),
|
TuiStyle::fg(upper_right.to_string(), title_color).pull_x(1).align_ne().fill_xy(),
|
||||||
|
|
@ -329,7 +323,6 @@ impl PhraseViewMode {
|
||||||
target: &mut BigBuffer, phrase: &Phrase, time_zoom: usize, _: usize
|
target: &mut BigBuffer, phrase: &Phrase, time_zoom: usize, _: usize
|
||||||
) {
|
) {
|
||||||
let style = Style::default().fg(Color::Rgb(255, 255, 255));
|
let style = Style::default().fg(Color::Rgb(255, 255, 255));
|
||||||
let mut notes_on = [false;128];
|
|
||||||
for (y, note) in (0..127).rev().enumerate() {
|
for (y, note) in (0..127).rev().enumerate() {
|
||||||
for (x, time) in (0..target.width).map(|x|(x, x*time_zoom)) {
|
for (x, time) in (0..target.width).map(|x|(x, x*time_zoom)) {
|
||||||
let cell = target.get_mut(x, y).unwrap();
|
let cell = target.get_mut(x, y).unwrap();
|
||||||
|
|
@ -345,6 +338,7 @@ impl PhraseViewMode {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let mut notes_on = [false;128];
|
||||||
for (x, time_start) in (0..phrase.length).step_by(time_zoom).enumerate() {
|
for (x, time_start) in (0..phrase.length).step_by(time_zoom).enumerate() {
|
||||||
let time_end = time_start + time_zoom;
|
let time_end = time_start + time_zoom;
|
||||||
for time in time_start..time_end {
|
for time in time_start..time_end {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue