mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: launcher grid
This commit is contained in:
parent
55e6c19c92
commit
1f194dafd8
5 changed files with 371 additions and 129 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use super::*;
|
||||
|
||||
pub fn draw_horizontal (
|
||||
pub fn draw (
|
||||
s: &Sequencer,
|
||||
buf: &mut Buffer,
|
||||
mut area: Rect,
|
||||
|
|
@ -14,7 +14,7 @@ pub fn draw_horizontal (
|
|||
let height = 32.max(s.note_axis.1 - s.note_axis.0) / 2;
|
||||
lanes(s, buf, x, y, width);
|
||||
cursor(s, buf, x, y);
|
||||
footer(s, buf, x, y, width, height);
|
||||
footer(s, buf, x - 13, y, width, height);
|
||||
Ok(Rect {
|
||||
x: x - 13,
|
||||
y: y,
|
||||
|
|
@ -23,7 +23,7 @@ pub fn draw_horizontal (
|
|||
})
|
||||
}
|
||||
|
||||
fn timer (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, beat: usize) {
|
||||
pub fn timer (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, beat: usize) {
|
||||
let bw = Style::default().dim();
|
||||
let bg = Style::default().on_black();
|
||||
let (time0, time1) = s.time_axis;
|
||||
|
|
@ -36,18 +36,19 @@ fn timer (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, beat: usize) {
|
|||
}
|
||||
}
|
||||
|
||||
fn lanes (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, width: u16) {
|
||||
pub fn lanes (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, width: u16) {
|
||||
let bw = Style::default().dim();
|
||||
let bg = Style::default().on_black();
|
||||
let ppq = s.timebase.ppq() as u32;
|
||||
let (time0, time1) = s.time_axis;
|
||||
let notes = &s.sequences[s.sequence].notes;
|
||||
for step in time0..time1 {
|
||||
let time_start = step as u32 * ppq;
|
||||
let time_end = (step + 1) as u32 * ppq;
|
||||
if step % s.resolution as u16 == 0 {
|
||||
buf.set_string(x + 6 + step, y - 1, &format!("{}", step + 1), Style::default());
|
||||
}
|
||||
for (_, (_, events)) in s.sequences[s.sequence].range(time_start..time_end).enumerate() {
|
||||
for (_, (_, events)) in notes.range(time_start..time_end).enumerate() {
|
||||
if events.len() > 0 {
|
||||
buf.set_string(x + 6 + step as u16, y, "█", bw);
|
||||
}
|
||||
|
|
@ -55,14 +56,16 @@ fn lanes (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, width: u16) {
|
|||
}
|
||||
}
|
||||
|
||||
fn footer (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, width: u16, height: u16) {
|
||||
pub fn footer (s: &Sequencer, buf: &mut Buffer, mut x: u16, y: u16, width: u16, height: u16) {
|
||||
let bw = Style::default().dim();
|
||||
let bg = Style::default().on_black();
|
||||
let (note0, note1) = s.note_axis;
|
||||
buf.set_string(x - 13, y + height, format!("├{}┤", "-".repeat((width - 2).into())),
|
||||
buf.set_string(x, y + height, format!("├{}┤", "-".repeat((width - 2).into())),
|
||||
Style::default().dim());
|
||||
buf.set_string(x, y + height + 2, format!("├{}┤", "-".repeat((width - 2).into())),
|
||||
Style::default().dim());
|
||||
x = x + 2;
|
||||
{
|
||||
let mut x = x - 11;
|
||||
for (i, [letter, title, value]) in [
|
||||
["S", &format!("ync"), &format!("<4/4>")],
|
||||
["Q", &format!("uant"), &format!("<1/{}>", 4 * s.resolution)],
|
||||
|
|
@ -87,7 +90,7 @@ fn footer (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, width: u16, height:
|
|||
}
|
||||
}
|
||||
|
||||
fn cursor (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16) {
|
||||
pub fn cursor (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16) {
|
||||
let bw = Style::default().dim();
|
||||
let bg = Style::default().on_black();
|
||||
buf.set_string(
|
||||
|
|
@ -98,7 +101,7 @@ fn cursor (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16) {
|
|||
);
|
||||
}
|
||||
|
||||
fn keys (s: &Sequencer, buf: &mut Buffer, mut area: Rect) -> Usually<Rect> {
|
||||
pub fn keys (s: &Sequencer, buf: &mut Buffer, mut area: Rect) -> Usually<Rect> {
|
||||
let bw = Style::default().dim();
|
||||
let bg = Style::default().on_black();
|
||||
let Rect { x, y, .. } = area;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue