mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
placebo
This commit is contained in:
parent
3ae2467acc
commit
94c1f83ef2
13 changed files with 277 additions and 124 deletions
|
|
@ -1,17 +1,36 @@
|
|||
use crate::core::*;
|
||||
use super::*;
|
||||
pub struct LauncherGrid<'a> {
|
||||
state: &'a Launcher,
|
||||
buf: &'a mut Buffer,
|
||||
area: Rect,
|
||||
focused: bool,
|
||||
pub struct SceneGrid<'a> {
|
||||
pub buf: &'a mut Buffer,
|
||||
pub area: Rect,
|
||||
pub name: &'a str,
|
||||
pub focused: bool,
|
||||
pub scenes: &'a[Scene],
|
||||
pub tracks: &'a[Track],
|
||||
pub cursor: &'a(usize, usize),
|
||||
}
|
||||
impl<'a> LauncherGrid<'a> {
|
||||
pub fn new (state: &'a Launcher, buf: &'a mut Buffer, area: Rect, focused: bool) -> Self {
|
||||
Self { state, buf, area, focused }
|
||||
impl<'a> SceneGrid<'a> {
|
||||
pub fn new (
|
||||
buf: &'a mut Buffer,
|
||||
area: Rect,
|
||||
name: &'a str,
|
||||
focused: bool,
|
||||
scenes: &'a[Scene],
|
||||
tracks: &'a[Track],
|
||||
cursor: &'a(usize, usize),
|
||||
) -> Self {
|
||||
Self {
|
||||
buf,
|
||||
area,
|
||||
name,
|
||||
focused,
|
||||
scenes,
|
||||
tracks,
|
||||
cursor,
|
||||
}
|
||||
}
|
||||
pub fn draw (&mut self) -> Usually<Rect> {
|
||||
self.area.height = self.state.scenes.len() as u16 + 2;
|
||||
self.area.height = self.scenes.len() as u16 + 2;
|
||||
let style = Some(Style::default().green().dim());
|
||||
if self.focused {
|
||||
let Rect { x, y, width, height } = self.area;
|
||||
|
|
@ -24,9 +43,9 @@ impl<'a> LauncherGrid<'a> {
|
|||
if x >= self.area.x + self.area.width {
|
||||
break
|
||||
}
|
||||
self.separator_v(x, i == self.state.cursor.0);
|
||||
self.separator_v(x, i == self.cursor.0);
|
||||
x = x + w;
|
||||
self.separator_v(x, i == self.state.cursor.0);
|
||||
self.separator_v(x, i == self.cursor.0);
|
||||
}
|
||||
let (mut x, y) = (self.area.x, self.area.y);
|
||||
for (i, title) in columns.iter().enumerate() {
|
||||
|
|
@ -34,7 +53,7 @@ impl<'a> LauncherGrid<'a> {
|
|||
break
|
||||
}
|
||||
title.blit(
|
||||
self.buf, x+1, y, Some(self.highlight(i == self.state.cursor.0).bold())
|
||||
self.buf, x+1, y, Some(self.highlight(i == self.cursor.0).bold())
|
||||
);
|
||||
if i == 0 {
|
||||
self.scenes(x+1, y + 1);
|
||||
|
|
@ -49,8 +68,8 @@ impl<'a> LauncherGrid<'a> {
|
|||
}
|
||||
|
||||
fn column_names (&self) -> Vec<&'a str> {
|
||||
let mut column_names = vec![self.state.name.as_str()];
|
||||
for track in self.state.tracks.iter() {
|
||||
let mut column_names = vec![self.name];
|
||||
for track in self.tracks.iter() {
|
||||
column_names.push(track.name.as_str());
|
||||
}
|
||||
column_names
|
||||
|
|
@ -63,23 +82,23 @@ impl<'a> LauncherGrid<'a> {
|
|||
fn scenes (&mut self, x: u16, y: u16) -> u16 {
|
||||
let mut index = 0usize;
|
||||
loop {
|
||||
if index >= self.state.scenes.len() {
|
||||
if index >= self.scenes.len() {
|
||||
break
|
||||
}
|
||||
if y + index as u16 >= self.area.height {
|
||||
break
|
||||
}
|
||||
if let Some(scene) = self.state.scenes.get(index) {
|
||||
if let Some(scene) = self.scenes.get(index) {
|
||||
let style = Some(self.highlight(
|
||||
(0 == self.state.cursor.0) && (index + 1 == self.state.cursor.1)
|
||||
(0 == self.cursor.0) && (index + 1 == self.cursor.1)
|
||||
).bold());
|
||||
"⯈".blit(self.buf, x, y + index as u16, style);
|
||||
scene.name.blit(self.buf, x+1, y + index as u16, style);
|
||||
}
|
||||
index = index + 1;
|
||||
}
|
||||
let hi = (0 == self.state.cursor.0) &&
|
||||
(self.state.scenes.len() + 1 == self.state.cursor.1);
|
||||
let hi = (0 == self.cursor.0) &&
|
||||
(self.scenes.len() + 1 == self.cursor.1);
|
||||
"+Add scene…".blit(self.buf, x, y + index as u16, Some(if hi {
|
||||
self.highlight(true)
|
||||
} else {
|
||||
|
|
@ -91,20 +110,20 @@ impl<'a> LauncherGrid<'a> {
|
|||
fn clips (&mut self, x: u16, y: u16, track: usize) -> u16 {
|
||||
let mut index = 0;
|
||||
loop {
|
||||
if index >= self.state.scenes.len() {
|
||||
if index >= self.scenes.len() {
|
||||
break
|
||||
}
|
||||
if y + index as u16 >= self.area.height {
|
||||
break
|
||||
}
|
||||
if let Some(scene) = self.state.scenes.get(index) {
|
||||
let hi = (track + 1 == self.state.cursor.0) &&
|
||||
(index + 1 == self.state.cursor.1);
|
||||
if let Some(scene) = self.scenes.get(index) {
|
||||
let hi = (track + 1 == self.cursor.0) &&
|
||||
(index + 1 == self.cursor.1);
|
||||
let style = Some(self.highlight(hi));
|
||||
let clip = scene.clips.get(track);
|
||||
let index = index as u16;
|
||||
let label = if let Some(Some(clip)) = clip {
|
||||
let track = self.state.tracks[track].sequencer.state();
|
||||
let track = self.tracks[track].sequencer.state();
|
||||
let phrase = track.phrases.get(*clip);
|
||||
if let Some(phrase) = phrase {
|
||||
format!("⯈{}", phrase.name)
|
||||
|
|
@ -118,8 +137,8 @@ impl<'a> LauncherGrid<'a> {
|
|||
}
|
||||
index = index + 1;
|
||||
}
|
||||
let hi = (track + 1 == self.state.cursor.0) &&
|
||||
(self.state.scenes.len() + 1 == self.state.cursor.1);
|
||||
let hi = (track + 1 == self.cursor.0) &&
|
||||
(self.scenes.len() + 1 == self.cursor.1);
|
||||
" + Add clip".blit(self.buf, x, y + index as u16, Some(if hi {
|
||||
self.highlight(true)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue