mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
arranger: border instead of background for cursor
This commit is contained in:
parent
08327d2ec0
commit
5ff7e32a46
2 changed files with 36 additions and 11 deletions
|
|
@ -37,6 +37,13 @@ pub fn fill_bg (buf: &mut Buffer, area: Rect, color: Color) {
|
|||
buffer_update(buf, area, &|cell,_,_|{cell.set_bg(color);})
|
||||
}
|
||||
|
||||
pub fn fill_ul (buf: &mut Buffer, area: Rect, color: Color) {
|
||||
buffer_update(buf, area, &|cell,_,_|{
|
||||
cell.modifier = ratatui::prelude::Modifier::UNDERLINED;
|
||||
cell.underline_color = color;
|
||||
})
|
||||
}
|
||||
|
||||
pub fn fill_char (buf: &mut Buffer, area: Rect, c: char) {
|
||||
buffer_update(buf, area, &|cell,_,_|{cell.set_char(c);})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,11 +36,11 @@ pub fn draw (
|
|||
Layered::new()
|
||||
//.add_ref(&FillBg(Color::Rgb(30, 33, 36)))//COLOR_BG1))//bg_lo(state.focused, state.entered)))
|
||||
.add_ref(&ColumnSeparators(offset, cols))
|
||||
.add_ref(&RowSeparators(rows))
|
||||
.add_ref(&CursorFocus(focus_sequencer, focused, entered, selected, offset, cols, rows))
|
||||
.add_ref(&Split::down()
|
||||
.add_ref(&TracksHeader(offset, cols, tracks))
|
||||
.add_ref(&SceneRows(offset, cols, rows, tracks, scenes)))
|
||||
.add_ref(&CursorFocus(focus_sequencer, focused, entered, selected, offset, cols, rows))
|
||||
.add_ref(&RowSeparators(rows))
|
||||
.render(buf, area)
|
||||
}
|
||||
|
||||
|
|
@ -87,46 +87,64 @@ struct CursorFocus<'a>(
|
|||
impl<'a> Render for CursorFocus<'a> {
|
||||
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let Self(focus_sequencer, focused, entered, selected, offset, cols, rows) = *self;
|
||||
let track_area = |t: usize| Rect {
|
||||
let get_track_area = |t: usize| Rect {
|
||||
x: offset + area.x + cols[t].1 as u16 - 1,
|
||||
y: area.y,
|
||||
width: cols[t].0 as u16,
|
||||
height: area.height
|
||||
};
|
||||
let scene_area = |s: usize| Rect {
|
||||
let get_scene_area = |s: usize| Rect {
|
||||
x: area.x,
|
||||
y: 2 + area.y + (rows[s].1 / 96) as u16,
|
||||
width: area.width,
|
||||
height: (rows[s].0 / 96) as u16
|
||||
};
|
||||
let clip_area = |t: usize, s: usize| Rect {
|
||||
let get_clip_area = |t: usize, s: usize| Rect {
|
||||
x: offset + area.x + cols[t].1 as u16 - 1,
|
||||
y: 2 + area.y + (rows[s].1 / 96) as u16,
|
||||
width: cols[t].0 as u16,
|
||||
height: (rows[s].0 / 96) as u16
|
||||
};
|
||||
let mut track_area: Option<Rect> = None;
|
||||
let mut scene_area: Option<Rect> = None;
|
||||
let mut clip_area: Option<Rect> = None;
|
||||
let area = match selected {
|
||||
ArrangerFocus::Mix => if focused && entered && selected == ArrangerFocus::Mix {
|
||||
fill_bg(buf, area, COLOR_BG3);
|
||||
fill_bg(buf, area, COLOR_BG0);
|
||||
area
|
||||
} else {
|
||||
area
|
||||
},
|
||||
ArrangerFocus::Track(t) => {
|
||||
fill_bg(buf, track_area(t), COLOR_BG3);
|
||||
track_area = Some(get_track_area(t));
|
||||
area
|
||||
},
|
||||
ArrangerFocus::Scene(s) => {
|
||||
fill_bg(buf, scene_area(s), COLOR_BG3);
|
||||
scene_area = Some(get_scene_area(s));
|
||||
area
|
||||
},
|
||||
ArrangerFocus::Clip(t, s) => {
|
||||
fill_bg(buf, track_area(t), COLOR_BG2);
|
||||
fill_bg(buf, scene_area(s), COLOR_BG2);
|
||||
fill_bg(buf, clip_area(t, s), COLOR_BG3);
|
||||
track_area = Some(get_track_area(t));
|
||||
scene_area = Some(get_scene_area(s));
|
||||
clip_area = Some(get_clip_area(t, s));
|
||||
area
|
||||
},
|
||||
};
|
||||
if let Some(Rect { x, y, width, height }) = track_area {
|
||||
fill_fg(buf, Rect { x, y, width: 1, height }, COLOR_BG5);
|
||||
fill_fg(buf, Rect { x: x + width, y, width: 1, height }, COLOR_BG5);
|
||||
}
|
||||
if let Some(Rect { y, height, .. }) = scene_area {
|
||||
fill_ul(buf, Rect { x: area.x, y: y - 1, width: area.width, height: 1 }, COLOR_BG5);
|
||||
fill_ul(buf, Rect { x: area.x, y: y + height - 1, width: area.width, height: 1 }, COLOR_BG5);
|
||||
}
|
||||
if let Some(clip_area) = clip_area {
|
||||
fill_bg(buf, clip_area, COLOR_BG0);
|
||||
} else if let Some(track_area) = track_area {
|
||||
fill_bg(buf, track_area, COLOR_BG0);
|
||||
} else if let Some(scene_area) = scene_area {
|
||||
fill_bg(buf, scene_area, COLOR_BG0);
|
||||
}
|
||||
if !focus_sequencer {
|
||||
Corners(Style::default().green().not_dim()).draw(buf, area)?;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue