mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-07-17 15:56:57 +02:00
argh
This commit is contained in:
parent
5ffa9472e1
commit
89df3cf191
7 changed files with 164 additions and 95 deletions
|
|
@ -167,19 +167,19 @@ pub trait MidiViewer: MidiRange + MidiPoint + Debug + Send + Sync {
|
|||
let note_lo = self.get_note_lo();
|
||||
let note_hi = self.get_note_hi();
|
||||
if note_pos < note_lo {
|
||||
self.note_lo().set(note_pos);
|
||||
self.note_lo().store(note_pos, Relaxed);
|
||||
} else if note_pos > note_hi {
|
||||
self.note_lo().set((note_lo + note_pos).saturating_sub(note_hi));
|
||||
self.note_lo().store((note_lo + note_pos).saturating_sub(note_hi), Relaxed);
|
||||
}
|
||||
}
|
||||
/// Make sure time range is within display
|
||||
fn autozoom (&self) {
|
||||
if self.time_lock().get() {
|
||||
if self.time_lock().load(Relaxed) {
|
||||
let time_len = self.get_time_len();
|
||||
let time_axis = self.get_time_axis();
|
||||
let time_zoom = self.get_time_zoom();
|
||||
loop {
|
||||
let time_zoom = self.time_zoom().get();
|
||||
let time_zoom = self.time_zoom().load(Relaxed);
|
||||
let time_area = time_axis * time_zoom;
|
||||
if time_area > time_len {
|
||||
let next_time_zoom = note_duration_prev(time_zoom);
|
||||
|
|
@ -205,7 +205,7 @@ pub trait MidiViewer: MidiRange + MidiPoint + Debug + Send + Sync {
|
|||
}
|
||||
}
|
||||
}
|
||||
if time_zoom != self.time_zoom().get() {
|
||||
if time_zoom != self.time_zoom().load(Relaxed) {
|
||||
self.redraw()
|
||||
}
|
||||
}
|
||||
|
|
@ -289,7 +289,7 @@ pub trait TimeRange {
|
|||
self.time_axis().load(Relaxed)
|
||||
}
|
||||
fn get_time_end (&self) -> usize {
|
||||
self.time_start().get() + self.time_axis().get() * self.time_zoom().get()
|
||||
self.time_start().load(Relaxed) + self.time_axis().load(Relaxed) * self.time_zoom().load(Relaxed)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -419,13 +419,13 @@ impl MidiEditor {
|
|||
w_exact(20, south!(
|
||||
w_full(origin_w(east(
|
||||
button_2("f2", "name ", false),
|
||||
w_full(origin_e(Tui::fg(Rgb(255, 255, 255), format!("{name} "))))))),
|
||||
w_full(origin_e(fg(Rgb(255, 255, 255), format!("{name} "))))))),
|
||||
w_full(origin_w(east(
|
||||
button_2("l", "ength ", false),
|
||||
w_full(origin_e(Tui::fg(Rgb(255, 255, 255), format!("{length} "))))))),
|
||||
w_full(origin_e(fg(Rgb(255, 255, 255), format!("{length} "))))))),
|
||||
w_full(origin_w(east(
|
||||
button_2("r", "epeat ", false),
|
||||
w_full(origin_e(Tui::fg(Rgb(255, 255, 255), format!("{looped} "))))))),
|
||||
w_full(origin_e(fg(Rgb(255, 255, 255), format!("{looped} "))))))),
|
||||
))
|
||||
}
|
||||
pub fn edit_status (&self) -> impl Draw<Tui> + '_ {
|
||||
|
|
@ -442,15 +442,15 @@ impl MidiEditor {
|
|||
w_exact(20, south!(
|
||||
w_full(origin_w(east(
|
||||
button_2("t", "ime ", false),
|
||||
w_full(origin_e(Tui::fg(Rgb(255, 255, 255),
|
||||
w_full(origin_e(fg(Rgb(255, 255, 255),
|
||||
format!("{length} /{time_zoom} +{time_pos} "))))))),
|
||||
w_full(origin_w(east(
|
||||
button_2("z", "lock ", false),
|
||||
w_full(origin_e(Tui::fg(Rgb(255, 255, 255),
|
||||
w_full(origin_e(fg(Rgb(255, 255, 255),
|
||||
format!("{time_lock}"))))))),
|
||||
w_full(origin_w(east(
|
||||
button_2("x", "note ", false),
|
||||
w_full(origin_e(Tui::fg(Rgb(255, 255, 255),
|
||||
w_full(origin_e(fg(Rgb(255, 255, 255),
|
||||
format!("{note_name} {note_pos} {note_len}"))))))),
|
||||
))
|
||||
}
|
||||
|
|
@ -665,7 +665,7 @@ impl PianoHorizontal {
|
|||
let note_hi = state.get_note_hi();
|
||||
let note_pos = state.get_note_pos();
|
||||
let key_style = Some(Style::default().fg(Rgb(192, 192, 192)).bg(Rgb(0, 0, 0)));
|
||||
let off_style = Some(Style::default().fg(Tui::g(255)));
|
||||
let off_style = Some(Style::default().fg(g(255)));
|
||||
let on_style = Some(Style::default().fg(Rgb(255,0,0)).bg(color.base.term).bold());
|
||||
h_full(w_exact(self.keys_width, Thunk::new(move|to: &mut Tui|{
|
||||
let XYWH(x, y0, _w, _h) = to.area();
|
||||
|
|
@ -688,7 +688,7 @@ impl PianoHorizontal {
|
|||
let style = Some(Style::default().dim());
|
||||
let length = self.clip.as_ref().map(|p|p.read().unwrap().length).unwrap_or(1);
|
||||
for (area_x, screen_x) in (0..w).map(|d|(d, d+x)) {
|
||||
let t = area_x as usize * self.time_zoom().get();
|
||||
let t = area_x as usize * self.time_zoom().load(Relaxed);
|
||||
if t < length {
|
||||
to.blit(&"|", screen_x, y, style);
|
||||
}
|
||||
|
|
@ -724,7 +724,7 @@ impl MidiViewer for PianoHorizontal {
|
|||
fn clip_mut (&mut self) -> &mut Option<Arc<RwLock<MidiClip>>> { &mut self.clip }
|
||||
/// Determine the required space to render the clip.
|
||||
fn buffer_size (&self, clip: &MidiClip) -> (usize, usize) {
|
||||
(clip.length / self.range.time_zoom().get(), 128)
|
||||
(clip.length / self.range.time_zoom().load(Relaxed), 128)
|
||||
}
|
||||
fn redraw (&self) {
|
||||
*self.buffer.write().unwrap() = if let Some(clip) = self.clip.as_ref() {
|
||||
|
|
@ -765,12 +765,12 @@ impl OctaveVertical {
|
|||
impl OctaveVertical {
|
||||
fn tui (&self) -> impl Draw<Tui> {
|
||||
east!(
|
||||
Tui::fg_bg(self.color(0), self.color(1), "▙"),
|
||||
Tui::fg_bg(self.color(2), self.color(3), "▙"),
|
||||
Tui::fg_bg(self.color(4), self.color(5), "▌"),
|
||||
Tui::fg_bg(self.color(6), self.color(7), "▟"),
|
||||
Tui::fg_bg(self.color(8), self.color(9), "▟"),
|
||||
Tui::fg_bg(self.color(10), self.color(11), "▟"),
|
||||
fg_bg(self.color(0), self.color(1), "▙"),
|
||||
fg_bg(self.color(2), self.color(3), "▙"),
|
||||
fg_bg(self.color(4), self.color(5), "▌"),
|
||||
fg_bg(self.color(6), self.color(7), "▟"),
|
||||
fg_bg(self.color(8), self.color(9), "▟"),
|
||||
fg_bg(self.color(10), self.color(11), "▟"),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue