mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: long awaited fixes to main sequencer
This commit is contained in:
parent
2837ffff4a
commit
78e5469b32
17 changed files with 391 additions and 563 deletions
|
|
@ -1,22 +1,16 @@
|
|||
use crate::core::*;
|
||||
use super::*;
|
||||
pub struct LauncherGridView<'a> {
|
||||
pub struct LauncherGrid<'a> {
|
||||
state: &'a Launcher,
|
||||
buf: &'a mut Buffer,
|
||||
area: Rect,
|
||||
focused: bool,
|
||||
separator: String
|
||||
}
|
||||
impl<'a> LauncherGridView<'a> {
|
||||
impl<'a> LauncherGrid<'a> {
|
||||
pub fn new (state: &'a Launcher, buf: &'a mut Buffer, area: Rect, focused: bool) -> Self {
|
||||
let separator = format!("├{}┤", "-".repeat((area.width - 2).into()));
|
||||
Self { state, buf, area, separator, focused }
|
||||
Self { state, buf, area, focused }
|
||||
}
|
||||
pub fn draw (&mut self) -> Usually<Rect> {
|
||||
//self.separator_h(0, false);
|
||||
//self.separator_h(2, false);
|
||||
//self.separator_h((self.state.cursor.1 * 2) as u16, true);
|
||||
//self.separator_h(((self.state.cursor.1 + 1) * 2) as u16, true);
|
||||
self.area.height = self.state.scenes.len() as u16 + 2;
|
||||
let style = Some(Style::default().green().dim());
|
||||
if self.focused {
|
||||
|
|
@ -24,9 +18,7 @@ impl<'a> LauncherGridView<'a> {
|
|||
lozenge_left(self.buf, x, y, height, style);
|
||||
lozenge_right(self.buf, x + width - 1, y, height, style);
|
||||
}
|
||||
|
||||
let columns = self.column_names();
|
||||
|
||||
let mut x = self.area.x;
|
||||
for (i, w) in self.column_widths().iter().enumerate() {
|
||||
if x >= self.area.x + self.area.width {
|
||||
|
|
@ -36,7 +28,6 @@ impl<'a> LauncherGridView<'a> {
|
|||
x = x + w;
|
||||
self.separator_v(x, i == self.state.cursor.0);
|
||||
}
|
||||
|
||||
let (mut x, y) = (self.area.x, self.area.y);
|
||||
for (i, title) in columns.iter().enumerate() {
|
||||
if x >= self.area.x + self.area.width {
|
||||
|
|
@ -53,17 +44,16 @@ impl<'a> LauncherGridView<'a> {
|
|||
let w = (title.len() as u16).max(10) + 3;
|
||||
x = x + w;
|
||||
}
|
||||
|
||||
"+Add track…".blit(self.buf, x + 2, y, Some(Style::default().dim()));
|
||||
Ok(self.area)
|
||||
}
|
||||
|
||||
fn column_names (&self) -> Vec<&'a str> {
|
||||
let mut columns = vec![self.state.name.as_str()];
|
||||
let mut column_names = vec![self.state.name.as_str()];
|
||||
for track in self.state.tracks.iter() {
|
||||
columns.push(track.name.as_str());
|
||||
column_names.push(track.name.as_str());
|
||||
}
|
||||
columns
|
||||
column_names
|
||||
}
|
||||
|
||||
fn column_widths (&self) -> Vec<u16> {
|
||||
|
|
@ -150,18 +140,11 @@ impl<'a> LauncherGridView<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn separator_h (&mut self, y: u16, highlight: bool) {
|
||||
let style = Some(self.highlight(highlight));
|
||||
self.separator.blit(self.buf, self.area.x, self.area.y + y, style);
|
||||
}
|
||||
|
||||
fn separator_v (&mut self, x: u16, highlight: bool) {
|
||||
let style = Some(self.highlight(highlight));
|
||||
//"┬".blit(self.buf, x, self.area.y + 0, style);
|
||||
for y in self.area.y+1..self.area.y+self.area.height-1 {
|
||||
"┊".blit(self.buf, x, y, style);
|
||||
}
|
||||
//"┴".blit(self.buf, x, self.area.y+self.area.height-1, style);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue