mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 20:26:42 +01:00
rename Widget::layout to Widget::min_size
This commit is contained in:
parent
d652feb705
commit
f018988567
10 changed files with 100 additions and 98 deletions
|
|
@ -97,7 +97,7 @@ pub struct TrackView<'a, E: Engine> {
|
|||
|
||||
impl<'a> Widget for TrackView<'a, Tui> {
|
||||
type Engine = Tui;
|
||||
fn layout (&self, area: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
fn min_size (&self, area: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
todo!()
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ impl<E> Plugin<E> {
|
|||
}
|
||||
impl Widget for Plugin<Tui> {
|
||||
type Engine = Tui;
|
||||
fn layout (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
fn min_size (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
Ok(Some(to))
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ impl Sample {
|
|||
|
||||
impl Widget for SamplerView<Tui> {
|
||||
type Engine = Tui;
|
||||
fn layout (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
fn min_size (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
todo!()
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
|
|
@ -373,7 +373,7 @@ fn draw_sample (
|
|||
|
||||
impl Widget for AddSampleModal {
|
||||
type Engine = Tui;
|
||||
fn layout (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
fn min_size (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
todo!()
|
||||
//Align::Center(()).layout(to)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,9 @@ pub struct PhraseView<'a> {
|
|||
now: &'a Arc<Pulse>,
|
||||
size: &'a Measure<Tui>,
|
||||
view_mode: &'a PhraseViewMode,
|
||||
|
||||
note_point: usize,
|
||||
note_range: (usize, usize),
|
||||
note_names: (&'a str, &'a str),
|
||||
|
||||
time_start: usize,
|
||||
time_point: usize,
|
||||
}
|
||||
|
|
@ -24,7 +22,7 @@ impl<'a, T: HasEditor> From<&'a T> for PhraseView<'a> {
|
|||
let height = editor.size.h();
|
||||
let note_point = editor.note_point.load(Ordering::Relaxed);
|
||||
let mut note_lo = editor.note_lo.load(Ordering::Relaxed);
|
||||
let mut note_hi = 127.min(note_lo + height + 1);
|
||||
let mut note_hi = 127.min(note_lo + height);
|
||||
if note_point < note_lo {
|
||||
note_lo = note_point;
|
||||
editor.note_lo.store(note_lo, Ordering::Relaxed);
|
||||
|
|
@ -84,10 +82,10 @@ impl<'a> Content for PhraseView<'a> {
|
|||
);
|
||||
|
||||
let mut lower_right = format!(
|
||||
"┤{}├", size.format()
|
||||
" {} ", size.format()
|
||||
);
|
||||
if *focused && *entered {
|
||||
lower_right = format!("┤Note: {} ({}) {}├─{lower_right}",
|
||||
lower_right = format!(" Note: {} ({}) {} {lower_right}",
|
||||
note_point, to_note_name(*note_point), pulses_to_name(*note_len)
|
||||
);
|
||||
}
|
||||
|
|
@ -97,7 +95,7 @@ impl<'a> Content for PhraseView<'a> {
|
|||
if *entered {"■"} else {" "}
|
||||
);
|
||||
if let Some(phrase) = phrase {
|
||||
upper_right = format!("┤Time: {}/{} {}├{upper_right}",
|
||||
upper_right = format!(" Time: {}/{} {} {upper_right}",
|
||||
time_point, phrase.read().unwrap().length, pulses_to_name(view_mode.time_zoom()),
|
||||
)
|
||||
};
|
||||
|
|
@ -108,7 +106,7 @@ impl<'a> Content for PhraseView<'a> {
|
|||
row!(
|
||||
CustomWidget::new(|to:[u16;2]|Ok(Some(to.clip_w(2))), move|to: &mut TuiOutput|{
|
||||
Ok(if to.area().h() >= 2 {
|
||||
view_mode.blit_keys(to, *note_hi, *note_lo)
|
||||
view_mode.render_keys(to, *note_hi, *note_lo)
|
||||
})
|
||||
}).fill_y(),
|
||||
lay!(
|
||||
|
|
@ -116,14 +114,14 @@ impl<'a> Content for PhraseView<'a> {
|
|||
size.set_wh(to.area.w(), to.area.h() as usize - 1);
|
||||
let draw = to.area().h() >= 2;
|
||||
Ok(if draw {
|
||||
view_mode.blit_notes(
|
||||
view_mode.render_notes(
|
||||
to, buffer, *time_start, *note_hi
|
||||
)
|
||||
})
|
||||
}).fill_x(),
|
||||
CustomWidget::new(|to|Ok(Some(to)), move|to: &mut TuiOutput|{
|
||||
Ok(if *focused && *entered {
|
||||
view_mode.blit_cursor(
|
||||
view_mode.render_cursor(
|
||||
to,
|
||||
*time_point, *time_start, view_mode.time_zoom(),
|
||||
*note_point, *note_len, *note_hi, *note_lo,
|
||||
|
|
@ -131,13 +129,14 @@ impl<'a> Content for PhraseView<'a> {
|
|||
})
|
||||
})
|
||||
).fill_x()
|
||||
).fill_x()
|
||||
.bg(Color::Rgb(40, 50, 30))
|
||||
.border(Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(if *focused{
|
||||
Color::Rgb(100, 110, 40)
|
||||
} else {
|
||||
Color::Rgb(70, 80, 50)
|
||||
}))),
|
||||
)
|
||||
.fill_x()
|
||||
.bg(Color::Rgb(40, 50, 30)),
|
||||
//.border(Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(if *focused{
|
||||
//Color::Rgb(100, 110, 40)
|
||||
//} else {
|
||||
//Color::Rgb(70, 80, 50)
|
||||
//}))),
|
||||
CustomWidget::new(|to:[u16;2]|Ok(Some(to.clip_h(1))), move|to: &mut TuiOutput|{
|
||||
//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();
|
||||
|
|
@ -214,7 +213,7 @@ impl PhraseViewMode {
|
|||
buffer
|
||||
}
|
||||
/// Draw a subsection of the [BigBuffer] onto a regular ratatui [Buffer].
|
||||
fn blit_notes (
|
||||
fn render_notes (
|
||||
&self,
|
||||
target: &mut TuiOutput,
|
||||
source: &BigBuffer,
|
||||
|
|
@ -228,6 +227,9 @@ impl PhraseViewMode {
|
|||
let [x0, y0, w, h] = area.xywh();
|
||||
for (x, target_x) in (x0..x0+w).enumerate() {
|
||||
for (y, target_y) in (y0..y0+h).enumerate() {
|
||||
if y > note_hi {
|
||||
break
|
||||
}
|
||||
let source_x = time_start + x;
|
||||
let source_y = note_hi - y;
|
||||
// TODO: enable loop rollover:
|
||||
|
|
@ -245,7 +247,7 @@ impl PhraseViewMode {
|
|||
_ => unimplemented!()
|
||||
}
|
||||
}
|
||||
fn blit_keys (&self, to: &mut TuiOutput, note_hi: usize, note_lo: usize) {
|
||||
fn render_keys (&self, to: &mut TuiOutput, note_hi: usize, note_lo: usize) {
|
||||
let style = Some(Style::default().fg(Color::Rgb(192, 192, 192)).bg(Color::Rgb(0, 0, 0)));
|
||||
match self {
|
||||
Self::PianoHorizontal { .. } => {
|
||||
|
|
@ -271,7 +273,7 @@ impl PhraseViewMode {
|
|||
_ => unimplemented!()
|
||||
}
|
||||
}
|
||||
fn blit_cursor (
|
||||
fn render_cursor (
|
||||
&self,
|
||||
to: &mut TuiOutput,
|
||||
time_point: usize,
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use crate::*;
|
|||
|
||||
impl Widget for TransportTui {
|
||||
type Engine = Tui;
|
||||
fn layout (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
TransportView::from(self).layout(to)
|
||||
fn min_size (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
TransportView::from(self).min_size(to)
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
TransportView::from(self).render(to)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue