mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
vertical scroll sequencer, pt.1
This commit is contained in:
parent
05ee05485e
commit
767b9ff983
2 changed files with 15 additions and 9 deletions
|
|
@ -6,7 +6,7 @@ pub use clap;
|
||||||
pub use std::sync::{Arc, Mutex, LockResult, RwLock, RwLockReadGuard, RwLockWriteGuard};
|
pub use std::sync::{Arc, Mutex, LockResult, RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||||
pub use std::collections::BTreeMap;
|
pub use std::collections::BTreeMap;
|
||||||
pub use once_cell::sync::Lazy;
|
pub use once_cell::sync::Lazy;
|
||||||
pub use std::sync::atomic::{Ordering, AtomicBool, AtomicUsize};
|
pub use std::sync::atomic::{Ordering, AtomicBool, AtomicUsize, AtomicU16};
|
||||||
pub use std::rc::Rc;
|
pub use std::rc::Rc;
|
||||||
pub use std::cell::RefCell;
|
pub use std::cell::RefCell;
|
||||||
pub use std::marker::PhantomData;
|
pub use std::marker::PhantomData;
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,16 @@ impl Content for PhraseEditor<Tui> {
|
||||||
}).fill_y();
|
}).fill_y();
|
||||||
let notes_bg_null = Color::Rgb(28, 35, 25);
|
let notes_bg_null = Color::Rgb(28, 35, 25);
|
||||||
let notes = CustomWidget::new(|to|Ok(Some(to)), move|to: &mut TuiOutput|{
|
let notes = CustomWidget::new(|to|Ok(Some(to)), move|to: &mut TuiOutput|{
|
||||||
self.width.store(to.area.w() as usize, Ordering::Relaxed);
|
let w = to.area.w() as usize;
|
||||||
self.height.store(to.area.h() as usize, Ordering::Relaxed);
|
let h = to.area.h() as usize;
|
||||||
|
self.width.store(w, Ordering::Relaxed);
|
||||||
|
self.height.store(h, Ordering::Relaxed);
|
||||||
|
let mut axis = self.note_axis.write().unwrap();
|
||||||
|
if let Some(point) = axis.point {
|
||||||
|
if point.saturating_sub(axis.start) / 2 > h {
|
||||||
|
axis.start += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
if to.area().h() >= 2 {
|
if to.area().h() >= 2 {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
to.buffer_update(area, &move |cell, x, y|{
|
to.buffer_update(area, &move |cell, x, y|{
|
||||||
|
|
@ -81,7 +89,7 @@ impl Content for PhraseEditor<Tui> {
|
||||||
let src_x = (x as usize + time_start) * time_scale;
|
let src_x = (x as usize + time_start) * time_scale;
|
||||||
let src_y = y as usize + note_start;
|
let src_y = y as usize + note_start;
|
||||||
if src_x < buffer.width && src_y < buffer.height - 1 {
|
if src_x < buffer.width && src_y < buffer.height - 1 {
|
||||||
buffer.get(src_x, buffer.height - src_y).map(|src|{
|
buffer.get(src_x, buffer.height - src_y - 1).map(|src|{
|
||||||
cell.set_symbol(src.symbol());
|
cell.set_symbol(src.symbol());
|
||||||
cell.set_fg(src.fg);
|
cell.set_fg(src.fg);
|
||||||
cell.set_bg(src.bg);
|
cell.set_bg(src.bg);
|
||||||
|
|
@ -97,7 +105,7 @@ impl Content for PhraseEditor<Tui> {
|
||||||
if let (Some(time), Some(note)) = (time_point, note_point) {
|
if let (Some(time), Some(note)) = (time_point, note_point) {
|
||||||
let x1 = area.x() + (time / time_scale) as u16;
|
let x1 = area.x() + (time / time_scale) as u16;
|
||||||
let x2 = x1 + (self.note_len / time_scale) as u16;
|
let x2 = x1 + (self.note_len / time_scale) as u16;
|
||||||
let y = area.y() + 1 + note as u16 / 2;
|
let y = area.y() + note as u16 / 2;
|
||||||
let c = if note % 2 == 0 { "▀" } else { "▄" };
|
let c = if note % 2 == 0 { "▀" } else { "▄" };
|
||||||
for x in x1..x2 {
|
for x in x1..x2 {
|
||||||
to.blit(&c, x, y, Some(Style::default().fg(color)));
|
to.blit(&c, x, y, Some(Style::default().fg(color)));
|
||||||
|
|
@ -142,10 +150,8 @@ impl Content for PhraseEditor<Tui> {
|
||||||
}
|
}
|
||||||
let mut upper_right = format!("Zoom: {} (+{}:{}*{}|{})",
|
let mut upper_right = format!("Zoom: {} (+{}:{}*{}|{})",
|
||||||
pulses_to_name(time_scale),
|
pulses_to_name(time_scale),
|
||||||
time_start,
|
time_start, time_point.unwrap_or(0),
|
||||||
time_point.unwrap_or(0),
|
time_scale, time_clamp.unwrap_or(0),
|
||||||
time_scale,
|
|
||||||
time_clamp.unwrap_or(0),
|
|
||||||
);
|
);
|
||||||
if *focused && *entered {
|
if *focused && *entered {
|
||||||
upper_right = format!("Note: {} (+{}:{}|{}) {upper_right}",
|
upper_right = format!("Note: {} (+{}:{}|{}) {upper_right}",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue