mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
arranger: combine grid components; highlight cell
This commit is contained in:
parent
f15efdd2ba
commit
a1a7fc3cdd
1 changed files with 8 additions and 21 deletions
|
|
@ -500,9 +500,8 @@ impl<'a, 'b> Content for ArrangerViewVertical<'a, 'b, Tui> {
|
||||||
let scenes = state.scenes.as_ref();
|
let scenes = state.scenes.as_ref();
|
||||||
let offset = 4 + scene_name_max_len(scenes) as u16;
|
let offset = 4 + scene_name_max_len(scenes) as u16;
|
||||||
Layers::new(move |add|{
|
Layers::new(move |add|{
|
||||||
add(&ColumnSeparators(offset, cols))?;
|
add(&ArrangerVerticalGrid(offset, rows, cols))?;
|
||||||
add(&RowSeparators(rows))?;
|
add(&ArrangerVerticalCursor(state.focused, state.selected, offset, cols, rows))?;
|
||||||
add(&CursorFocus(state.focused, state.selected, offset, cols, rows))?;
|
|
||||||
add(&Split::down(|add|{
|
add(&Split::down(|add|{
|
||||||
add(&Push::X(offset, Split::right(move |add|{
|
add(&Push::X(offset, Split::right(move |add|{
|
||||||
for (track, (w, _)) in tracks.iter().zip(*cols) {
|
for (track, (w, _)) in tracks.iter().zip(*cols) {
|
||||||
|
|
@ -562,13 +561,13 @@ pub fn scene_name_max_len (scenes: &[Scene]) -> usize {
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
struct ColumnSeparators<'a>(u16, &'a [(usize, usize)]);
|
struct ArrangerVerticalGrid<'a>(u16, &'a [(usize, usize)], &'a [(usize, usize)]);
|
||||||
|
|
||||||
impl<'a> Widget for ColumnSeparators<'a> {
|
impl<'a> Widget for ArrangerVerticalGrid<'a> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let Self(offset, cols) = self;
|
let Self(offset, rows, cols) = self;
|
||||||
let style = Some(Style::default().fg(Nord::SEPARATOR));
|
let style = Some(Style::default().fg(Nord::SEPARATOR));
|
||||||
for (_, x) in cols.iter() {
|
for (_, x) in cols.iter() {
|
||||||
let x = offset + area.x() + *x as u16 - 1;
|
let x = offset + area.x() + *x as u16 - 1;
|
||||||
|
|
@ -576,19 +575,6 @@ impl<'a> Widget for ColumnSeparators<'a> {
|
||||||
to.blit(&"▎", x, y, style);
|
to.blit(&"▎", x, y, style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
struct RowSeparators<'a>(&'a [(usize, usize)]);
|
|
||||||
|
|
||||||
impl<'a> Widget for RowSeparators<'a> {
|
|
||||||
type Engine = Tui;
|
|
||||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
|
||||||
let area = to.area();
|
|
||||||
let Self(rows) = self;
|
|
||||||
for (_, y) in rows.iter() {
|
for (_, y) in rows.iter() {
|
||||||
let y = area.y() + (*y / 96) as u16 + 1;
|
let y = area.y() + (*y / 96) as u16 + 1;
|
||||||
if y >= to.buffer.area.height {
|
if y >= to.buffer.area.height {
|
||||||
|
|
@ -608,11 +594,11 @@ impl<'a> Widget for RowSeparators<'a> {
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
struct CursorFocus<'a>(
|
struct ArrangerVerticalCursor<'a>(
|
||||||
bool, ArrangerFocus, u16, &'a [(usize, usize)], &'a [(usize, usize)]
|
bool, ArrangerFocus, u16, &'a [(usize, usize)], &'a [(usize, usize)]
|
||||||
);
|
);
|
||||||
|
|
||||||
impl<'a> Widget for CursorFocus<'a> {
|
impl<'a> Widget for ArrangerVerticalCursor<'a> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
|
|
@ -670,6 +656,7 @@ impl<'a> Widget for CursorFocus<'a> {
|
||||||
}
|
}
|
||||||
if focused {
|
if focused {
|
||||||
if let Some(clip_area) = clip_area {
|
if let Some(clip_area) = clip_area {
|
||||||
|
to.render_in(clip_area, &CORNERS)?;
|
||||||
to.fill_bg(clip_area, COLOR_BG0);
|
to.fill_bg(clip_area, COLOR_BG0);
|
||||||
} else if let Some(track_area) = track_area {
|
} else if let Some(track_area) = track_area {
|
||||||
to.fill_bg(track_area, COLOR_BG0);
|
to.fill_bg(track_area, COLOR_BG0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue