mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
remove some old functions
This commit is contained in:
parent
449d56a2af
commit
ec9352e0f8
1 changed files with 8 additions and 31 deletions
|
|
@ -62,6 +62,8 @@ impl Content for PhraseEditor<Tui> {
|
||||||
focused, entered, time_axis, note_axis, keys, phrase, buffer, note_len, ..
|
focused, entered, time_axis, note_axis, keys, phrase, buffer, note_len, ..
|
||||||
} = self;
|
} = self;
|
||||||
let offset = Self::H_KEYS_OFFSET as u16;
|
let offset = Self::H_KEYS_OFFSET as u16;
|
||||||
|
let color = Color::Rgb(0,255,0);
|
||||||
|
let color = phrase.as_ref().map(|p|p.read().unwrap().color).unwrap_or(color);
|
||||||
let keys = CustomWidget::new(|_|Ok(Some([32u16,4u16])), move|to: &mut TuiOutput|{
|
let keys = CustomWidget::new(|_|Ok(Some([32u16,4u16])), move|to: &mut TuiOutput|{
|
||||||
if to.area().h() >= 2 {
|
if to.area().h() >= 2 {
|
||||||
to.buffer_update(to.area().set_w(5), &|cell, x, y|{
|
to.buffer_update(to.area().set_w(5), &|cell, x, y|{
|
||||||
|
|
@ -84,9 +86,11 @@ impl Content for PhraseEditor<Tui> {
|
||||||
for x in x2..x3 {
|
for x in x2..x3 {
|
||||||
let step = (time_0 + x2) * time_z;
|
let step = (time_0 + x2) * time_z;
|
||||||
let next_step = (time_0 + x2 + 1) * time_z;
|
let next_step = (time_0 + x2 + 1) * time_z;
|
||||||
to.blit(&"-", x as u16, y, Some(PhraseEditor::<Tui>::style_timer_step(
|
let mut style = Style::default();
|
||||||
now, step as usize, next_step as usize
|
if step <= now && now < next_step {
|
||||||
)));
|
style = style.yellow().bold().not_dim()
|
||||||
|
}
|
||||||
|
to.blit(&"-", x as u16, y, Some(style));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -115,7 +119,7 @@ impl Content for PhraseEditor<Tui> {
|
||||||
let x = area.x() + Self::H_KEYS_OFFSET as u16 + time as u16;
|
let x = area.x() + Self::H_KEYS_OFFSET as u16 + time as u16;
|
||||||
let y = area.y() + 1 + note as u16 / 2;
|
let y = area.y() + 1 + note as u16 / 2;
|
||||||
let c = if note % 2 == 0 { "▀" } else { "▄" };
|
let c = if note % 2 == 0 { "▀" } else { "▄" };
|
||||||
to.blit(&c, x, y, self.style_focus());
|
to.blit(&c, x, y, Some(Style::default().fg(color)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -239,33 +243,6 @@ impl PhraseEditor<Tui> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub(crate) fn style_focus (&self) -> Option<Style> {
|
|
||||||
Some(if self.focused {
|
|
||||||
Style::default().green().not_dim()
|
|
||||||
} else {
|
|
||||||
Style::default().green().dim()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
pub(crate) fn style_timer_step (now: usize, step: usize, next_step: usize) -> Style {
|
|
||||||
if step <= now && now < next_step {
|
|
||||||
Style::default().yellow().bold().not_dim()
|
|
||||||
} else {
|
|
||||||
Style::default()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn index_to_color (&self, index: u16, default: Color) -> Color {
|
|
||||||
let index = index as usize;
|
|
||||||
let (notes_in, notes_out) = (self.notes_in.read().unwrap(), self.notes_out.read().unwrap());
|
|
||||||
if notes_in[index] && notes_out[index] {
|
|
||||||
Color::Yellow
|
|
||||||
} else if notes_in[index] {
|
|
||||||
Color::Red
|
|
||||||
} else if notes_out[index] {
|
|
||||||
Color::Green
|
|
||||||
} else {
|
|
||||||
default
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// Colors of piano keys
|
/// Colors of piano keys
|
||||||
const KEY_COLORS: [(Color, Color);6] = [
|
const KEY_COLORS: [(Color, Color);6] = [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue