mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-13 15:16:41 +01:00
make transport focusable
This commit is contained in:
parent
a7a798b484
commit
449615eea8
14 changed files with 220 additions and 237 deletions
|
|
@ -6,6 +6,7 @@ pub struct ChainView<'a> {
|
|||
pub track: Option<&'a Track>,
|
||||
pub direction: Direction,
|
||||
pub focused: bool,
|
||||
pub entered: bool,
|
||||
}
|
||||
|
||||
impl<'a> ChainView<'a> {
|
||||
|
|
@ -18,6 +19,7 @@ impl<'a> ChainView<'a> {
|
|||
pub fn new (app: &'a App, direction: Direction) -> Self {
|
||||
Self {
|
||||
direction,
|
||||
entered: app.entered,
|
||||
focused: app.section == AppSection::Chain,
|
||||
track: match app.track_cursor {
|
||||
0 => None,
|
||||
|
|
@ -34,14 +36,18 @@ impl<'a> Render for ChainView<'a> {
|
|||
Direction::Down => area.width = area.width.min(40),
|
||||
Direction::Right => area.width = area.width.min(10),
|
||||
}
|
||||
fill_bg(buf, area, if self.focused { Color::Rgb(20, 45, 5) } else { Color::Reset });
|
||||
self.direction
|
||||
fill_bg(buf, area, Nord::bg_lo(self.focused, self.entered));
|
||||
let area = self.direction
|
||||
.split_focus(0, track.devices.as_slice(), if self.focused {
|
||||
Style::default().green().dim()
|
||||
} else {
|
||||
Style::default().dim()
|
||||
})
|
||||
.render(buf, area)
|
||||
.render(buf, area)?;
|
||||
if self.focused && self.entered {
|
||||
Corners(Style::default().green().not_dim()).draw(buf, area)?;
|
||||
}
|
||||
Ok(area)
|
||||
} else {
|
||||
let Rect { x, y, width, height } = area;
|
||||
let label = "No track selected";
|
||||
|
|
@ -86,7 +92,7 @@ impl<'a> Render for SplitFocus<'a> {
|
|||
}
|
||||
results
|
||||
.get(self.1)
|
||||
.map(|focused|Lozenge(self.3).draw(buf, *focused))
|
||||
.map(|focused|Lozenge(self.3).draw(buf, Rect { width, ..*focused }))
|
||||
.transpose()?;
|
||||
Ok(area)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue