mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
scale and highlight playhead properly
This commit is contained in:
parent
ea397b7ed7
commit
c88cb86532
2 changed files with 14 additions and 12 deletions
|
|
@ -230,7 +230,7 @@ impl<E: Engine> PhraseEditor<E> {
|
|||
keys: keys_vert(),
|
||||
buffer: Default::default(),
|
||||
note_axis: FixedAxis { start: 12, point: Some(36), clamp: Some(127) },
|
||||
time_axis: ScaledAxis { start: 0, point: Some(0), clamp: Some(0), scale: 24 },
|
||||
time_axis: ScaledAxis { start: 00, point: Some(00), clamp: Some(000), scale: 24 },
|
||||
focused: false,
|
||||
entered: false,
|
||||
mode: false,
|
||||
|
|
|
|||
|
|
@ -97,22 +97,22 @@ impl Content for PhraseEditor<Tui> {
|
|||
Ok(())
|
||||
});
|
||||
let playhead_inactive = Style::default().fg(Color::Rgb(255,255,255)).bg(Color::Rgb(0,0,0));
|
||||
let playhead_active = playhead_inactive.yellow().bold().not_dim();
|
||||
let playhead_active = playhead_inactive.clone().yellow().bold().not_dim();
|
||||
let playhead = CustomWidget::new(
|
||||
|to:[u16;2]|Ok(Some(to.clip_h(1))),
|
||||
move|to: &mut TuiOutput|{
|
||||
if let Some(_) = phrase {
|
||||
let now = 0; // TODO FIXME: self.now % phrase.read().unwrap().length;
|
||||
let ScaledAxis { start: first_beat, scale: time_zoom, .. } = time_axis;
|
||||
for x in 0..10 {
|
||||
let this_step = (first_beat + 0) * time_zoom;
|
||||
let next_step = (first_beat + 1) * time_zoom;
|
||||
let x = to.area().x() + x;
|
||||
to.blit(&"-", x, to.area.y(), Some(if this_step <= now && now < next_step {
|
||||
playhead_active
|
||||
} else {
|
||||
playhead_active
|
||||
}));
|
||||
let ScaledAxis { start: first_beat, scale: time_zoom, clamp, .. } = time_axis;
|
||||
let clamp = clamp.expect("time_axis of sequencer expected to be clamped");
|
||||
for x in 0..clamp/time_zoom {
|
||||
let this_step = (x * time_zoom + first_beat + 0) * time_zoom;
|
||||
let next_step = (x * time_zoom + first_beat + 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(())
|
||||
|
|
@ -169,9 +169,11 @@ impl<E: Engine> PhraseEditor<E> {
|
|||
pub fn show (&mut self, phrase: Option<&Arc<RwLock<Phrase>>>) {
|
||||
if let Some(phrase) = phrase {
|
||||
self.phrase = Some(phrase.clone());
|
||||
self.time_axis.clamp = Some(phrase.read().unwrap().length);
|
||||
self.buffer = Self::redraw(&*phrase.read().unwrap());
|
||||
} else {
|
||||
self.phrase = None;
|
||||
self.time_axis.clamp = Some(0);
|
||||
self.buffer = Default::default();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue