mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +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(),
|
keys: keys_vert(),
|
||||||
buffer: Default::default(),
|
buffer: Default::default(),
|
||||||
note_axis: FixedAxis { start: 12, point: Some(36), clamp: Some(127) },
|
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,
|
focused: false,
|
||||||
entered: false,
|
entered: false,
|
||||||
mode: false,
|
mode: false,
|
||||||
|
|
|
||||||
|
|
@ -97,22 +97,22 @@ impl Content for PhraseEditor<Tui> {
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
let playhead_inactive = Style::default().fg(Color::Rgb(255,255,255)).bg(Color::Rgb(0,0,0));
|
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(
|
let playhead = CustomWidget::new(
|
||||||
|to:[u16;2]|Ok(Some(to.clip_h(1))),
|
|to:[u16;2]|Ok(Some(to.clip_h(1))),
|
||||||
move|to: &mut TuiOutput|{
|
move|to: &mut TuiOutput|{
|
||||||
if let Some(_) = phrase {
|
if let Some(_) = phrase {
|
||||||
let now = 0; // TODO FIXME: self.now % phrase.read().unwrap().length;
|
let now = 0; // TODO FIXME: self.now % phrase.read().unwrap().length;
|
||||||
let ScaledAxis { start: first_beat, scale: time_zoom, .. } = time_axis;
|
let ScaledAxis { start: first_beat, scale: time_zoom, clamp, .. } = time_axis;
|
||||||
for x in 0..10 {
|
let clamp = clamp.expect("time_axis of sequencer expected to be clamped");
|
||||||
let this_step = (first_beat + 0) * time_zoom;
|
for x in 0..clamp/time_zoom {
|
||||||
let next_step = (first_beat + 1) * time_zoom;
|
let this_step = (x * time_zoom + first_beat + 0) * time_zoom;
|
||||||
let x = to.area().x() + x;
|
let next_step = (x * time_zoom + first_beat + 1) * time_zoom;
|
||||||
to.blit(&"-", x, to.area.y(), Some(if this_step <= now && now < next_step {
|
let x = to.area().x() + x as u16;
|
||||||
playhead_active
|
let active = this_step <= now && now < next_step;
|
||||||
} else {
|
let character = if active { "|" } else { "·" };
|
||||||
playhead_active
|
let style = if active { playhead_active } else { playhead_inactive };
|
||||||
}));
|
to.blit(&character, x, to.area.y(), Some(style));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -169,9 +169,11 @@ impl<E: Engine> PhraseEditor<E> {
|
||||||
pub fn show (&mut self, phrase: Option<&Arc<RwLock<Phrase>>>) {
|
pub fn show (&mut self, phrase: Option<&Arc<RwLock<Phrase>>>) {
|
||||||
if let Some(phrase) = phrase {
|
if let Some(phrase) = phrase {
|
||||||
self.phrase = Some(phrase.clone());
|
self.phrase = Some(phrase.clone());
|
||||||
|
self.time_axis.clamp = Some(phrase.read().unwrap().length);
|
||||||
self.buffer = Self::redraw(&*phrase.read().unwrap());
|
self.buffer = Self::redraw(&*phrase.read().unwrap());
|
||||||
} else {
|
} else {
|
||||||
self.phrase = None;
|
self.phrase = None;
|
||||||
|
self.time_axis.clamp = Some(0);
|
||||||
self.buffer = Default::default();
|
self.buffer = Default::default();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue