mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
canonize custom_render; duh flipped again
This commit is contained in:
parent
8bdd088f70
commit
43154c486d
4 changed files with 27 additions and 30 deletions
|
|
@ -37,6 +37,10 @@ mod phrase_select; pub(crate) use phrase_select::*;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn render <F: Fn(&mut TuiOutput)->Usually<()>+Send+Sync> (render: F) -> impl Render<Tui> {
|
||||||
|
Widget::new(|_|Ok(Some([0u16,0u16].into())), render)
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
|
|
||||||
pub struct Tui {
|
pub struct Tui {
|
||||||
|
|
|
||||||
|
|
@ -391,10 +391,6 @@ fn any_size <E: Engine> (_: E::Size) -> Perhaps<E::Size>{
|
||||||
Ok(Some([0.into(),0.into()].into()))
|
Ok(Some([0.into(),0.into()].into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn custom_render <F: Fn(&mut TuiOutput)->Usually<()>+Send+Sync> (render: F) -> impl Render<Tui> {
|
|
||||||
Widget::new(|_|Ok(Some([0u16,0u16].into())), render)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn arranger_content_vertical (
|
pub fn arranger_content_vertical (
|
||||||
view: &ArrangerTui,
|
view: &ArrangerTui,
|
||||||
factor: usize
|
factor: usize
|
||||||
|
|
@ -429,7 +425,7 @@ impl From<&ArrangerTui> for ArrangerVerticalColumnSeparator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
render!(|self: ArrangerVerticalColumnSeparator|custom_render(move|to: &mut TuiOutput|{
|
render!(|self: ArrangerVerticalColumnSeparator|render(move|to: &mut TuiOutput|{
|
||||||
let style = Some(Style::default().fg(self.sep_fg));
|
let style = Some(Style::default().fg(self.sep_fg));
|
||||||
Ok(for x in self.cols.iter().map(|col|col.1) {
|
Ok(for x in self.cols.iter().map(|col|col.1) {
|
||||||
let x = self.scenes_w + to.area().x() + x as u16;
|
let x = self.scenes_w + to.area().x() + x as u16;
|
||||||
|
|
@ -452,7 +448,7 @@ impl From<(&ArrangerTui, usize)> for ArrangerVerticalRowSeparator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render!(|self: ArrangerVerticalRowSeparator|custom_render(move|to: &mut TuiOutput|{
|
render!(|self: ArrangerVerticalRowSeparator|render(move|to: &mut TuiOutput|{
|
||||||
Ok(for y in self.rows.iter().map(|row|row.1) {
|
Ok(for y in self.rows.iter().map(|row|row.1) {
|
||||||
let y = to.area().y() + (y / PPQ) as u16 + 1;
|
let y = to.area().y() + (y / PPQ) as u16 + 1;
|
||||||
if y >= to.buffer.area.height { break }
|
if y >= to.buffer.area.height { break }
|
||||||
|
|
@ -486,7 +482,7 @@ impl From<(&ArrangerTui, usize)> for ArrangerVerticalCursor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
render!(|self: ArrangerVerticalCursor|custom_render(move|to: &mut TuiOutput|{
|
render!(|self: ArrangerVerticalCursor|render(move|to: &mut TuiOutput|{
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let focused = self.focused;
|
let focused = self.focused;
|
||||||
let selected = self.selected;
|
let selected = self.selected;
|
||||||
|
|
|
||||||
|
|
@ -196,23 +196,6 @@ render!(|self: PhraseView<'a>|{
|
||||||
//now: _,
|
//now: _,
|
||||||
..
|
..
|
||||||
} = self;
|
} = self;
|
||||||
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,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
};
|
|
||||||
lay!([
|
lay!([
|
||||||
lay!(move|add|{
|
lay!(move|add|{
|
||||||
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)};
|
||||||
|
|
@ -239,10 +222,24 @@ render!(|self: PhraseView<'a>|{
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Tui::bg(Color::Rgb(40, 50, 30), Tui::fill_x(row!([
|
Tui::bg(Color::Rgb(40, 50, 30), Tui::fill_x(row!([
|
||||||
Tui::push_y(1, Tui::fill_y(Widget::new(|to:[u16;2]|Ok(Some(to.clip_w(2))), keys))),
|
Tui::push_y(1, Tui::fill_y(Widget::new(|to:[u16;2]|Ok(Some(to.clip_w(2))), move|to: &mut TuiOutput|{
|
||||||
|
Ok(if to.area().h() >= 2 { view_mode.render_keys(to, *note_hi, *note_lo) })
|
||||||
|
}))),
|
||||||
Tui::fill_x(lay!([
|
Tui::fill_x(lay!([
|
||||||
Tui::push_y(1, Tui::fill_x(Widget::new(|to|Ok(Some(to)), notes))),
|
Tui::push_y(1, Tui::fill_x(render(|to: &mut TuiOutput|{
|
||||||
Tui::push_y(1, Widget::new(|to|Ok(Some(to)), cursor))
|
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) })
|
||||||
|
}))),
|
||||||
|
Tui::push_y(1, render(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,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}))
|
||||||
])),
|
])),
|
||||||
])))
|
])))
|
||||||
])
|
])
|
||||||
|
|
@ -444,7 +441,7 @@ impl PhraseViewMode {
|
||||||
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 (y, note) in (0..127).rev().enumerate() {
|
for (y, note) in (0..127).rev().enumerate() {
|
||||||
let cell = target.get_mut(x, 127 - note).unwrap();
|
let cell = target.get_mut(x, note).unwrap();
|
||||||
if notes_on[note] {
|
if notes_on[note] {
|
||||||
cell.set_fg(Color::Rgb(255, 255, 255));
|
cell.set_fg(Color::Rgb(255, 255, 255));
|
||||||
cell.set_bg(Color::Rgb(0, 0, 0));
|
cell.set_bg(Color::Rgb(0, 0, 0));
|
||||||
|
|
@ -457,7 +454,7 @@ impl PhraseViewMode {
|
||||||
match event {
|
match event {
|
||||||
MidiMessage::NoteOn { key, .. } => {
|
MidiMessage::NoteOn { key, .. } => {
|
||||||
let note = key.as_int() as usize;
|
let note = key.as_int() as usize;
|
||||||
let cell = target.get_mut(x, 127 - note).unwrap();
|
let cell = target.get_mut(x, note).unwrap();
|
||||||
cell.set_char('█');
|
cell.set_char('█');
|
||||||
cell.set_style(style);
|
cell.set_style(style);
|
||||||
notes_on[note] = true
|
notes_on[note] = true
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ render!(|self: PhraseSelector<'a>|{
|
||||||
let row1 = Tui::fill_x(lay!([Tui::fill_x(Tui::at_w(format!(" "))), length]));
|
let row1 = Tui::fill_x(lay!([Tui::fill_x(Tui::at_w(format!(" "))), length]));
|
||||||
let row2 = format!(" {name}");
|
let row2 = format!(" {name}");
|
||||||
let row2 = Tui::bold(true, row2);
|
let row2 = Tui::bold(true, row2);
|
||||||
add(&Tui::bg(color.base.rgb, Tui::fill_x(Tui::to_south(row1, row2))))?;
|
add(&Tui::bg(color.base.rgb, Tui::fill_x(col!([row1, row2]))))?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})))),
|
})))),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue