mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
groovebox: spiffy sidebar
This commit is contained in:
parent
0f16c89248
commit
d45bd2122e
6 changed files with 137 additions and 44 deletions
|
|
@ -66,10 +66,18 @@ impl Sampler {
|
|||
//let offset = |a|Push::y(i as u16, Align::n(Fixed::y(1, Fill::x(a))));
|
||||
let mut bg = if note == note_pt { Tui::g(64) } else { Color::Reset };
|
||||
let mut fg = Tui::g(160);
|
||||
let mapped: &Option<Arc<RwLock<Sample>>> = &self.mapped[note];
|
||||
if mapped.is_some() {
|
||||
fg = Tui::g(224);
|
||||
bg = Color::Rgb(0, if note == note_pt { 96 } else { 64 }, 0);
|
||||
if let Some(mapped) = &self.mapped[note] {
|
||||
let sample = mapped.read().unwrap();
|
||||
fg = if note == note_pt {
|
||||
sample.color.lightest.rgb
|
||||
} else {
|
||||
Tui::g(224)
|
||||
};
|
||||
bg = if note == note_pt {
|
||||
sample.color.light.rgb
|
||||
} else {
|
||||
sample.color.base.rgb
|
||||
};
|
||||
}
|
||||
if let Some((index, _)) = self.recording {
|
||||
if note == index {
|
||||
|
|
@ -110,6 +118,16 @@ impl Sampler {
|
|||
})))
|
||||
}
|
||||
|
||||
pub fn view_sample_status (&self, note_pt: usize) -> impl Content<TuiOut> + use<'_> {
|
||||
Fixed::x(20, draw_info_v(if let Some((_, sample)) = &self.recording {
|
||||
Some(sample)
|
||||
} else if let Some(sample) = &self.mapped[note_pt] {
|
||||
Some(sample)
|
||||
} else {
|
||||
None
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn view_status (&self, index: usize) -> impl Content<TuiOut> {
|
||||
draw_status(self.mapped[index].as_ref())
|
||||
}
|
||||
|
|
@ -189,11 +207,11 @@ fn draw_viewer (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> +
|
|||
.y_bounds([0.0, height as f64])
|
||||
.paint(|ctx| {
|
||||
let text = "press record to begin sampling";
|
||||
ctx.print(
|
||||
(width - text.len() as u16) as f64 / 2.0,
|
||||
height as f64 / 2.0,
|
||||
text.red()
|
||||
);
|
||||
//ctx.print(
|
||||
//(width - text.len() as u16) as f64 / 2.0,
|
||||
//height as f64 / 2.0,
|
||||
//text.red()
|
||||
//);
|
||||
})
|
||||
.render(area, &mut to.buffer);
|
||||
}
|
||||
|
|
@ -203,7 +221,7 @@ fn draw_viewer (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> +
|
|||
fn draw_info (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> + use<'_> {
|
||||
When(sample.is_some(), Thunk::new(move||{
|
||||
let sample = sample.unwrap().read().unwrap();
|
||||
let theme = ItemTheme::G[96];
|
||||
let theme = sample.color;
|
||||
row!(
|
||||
FieldH(theme, "Name", format!("{:<10}", sample.name.clone())),
|
||||
FieldH(theme, "Length", format!("{:<8}", sample.channels[0].len())),
|
||||
|
|
@ -215,6 +233,21 @@ fn draw_info (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> + us
|
|||
}))
|
||||
}
|
||||
|
||||
fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> + use<'_> {
|
||||
When(sample.is_some(), Thunk::new(move||{
|
||||
let sample = sample.unwrap().read().unwrap();
|
||||
let theme = sample.color;
|
||||
Fixed::x(20, col!(
|
||||
Fill::x(Align::w(FieldH(theme, "Name ", format!("{:<10}", sample.name.clone())))),
|
||||
Fill::x(Align::w(FieldH(theme, "Length", format!("{:<8}", sample.channels[0].len())))),
|
||||
Fill::x(Align::w(FieldH(theme, "Start ", format!("{:<8}", sample.start)))),
|
||||
Fill::x(Align::w(FieldH(theme, "End ", format!("{:<8}", sample.end)))),
|
||||
Fill::x(Align::w(FieldH(theme, "Trans ", "0 "))),
|
||||
Fill::x(Align::w(FieldH(theme, "Gain ", format!("{}", sample.gain)))),
|
||||
))
|
||||
}))
|
||||
}
|
||||
|
||||
fn draw_status (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> {
|
||||
Tui::bold(true, Tui::fg(Tui::g(224), sample
|
||||
.map(|sample|{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue