mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
almost sane focus higlighting
This commit is contained in:
parent
4c9eed6fce
commit
c06b9d16e2
4 changed files with 30 additions and 31 deletions
|
|
@ -1,11 +1,11 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub struct Chain {
|
||||
name: String,
|
||||
focused: bool,
|
||||
focus: usize,
|
||||
items: Vec<Box<dyn Device>>,
|
||||
view: ChainView
|
||||
pub name: String,
|
||||
pub focused: bool,
|
||||
pub focus: usize,
|
||||
pub items: Vec<Box<dyn Device>>,
|
||||
pub view: ChainView
|
||||
}
|
||||
|
||||
pub enum ChainView {
|
||||
|
|
@ -97,7 +97,7 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
|||
|
||||
pub fn draw_as_row (
|
||||
state: &Chain, buf: &mut Buffer, area: Rect, selected: Option<Style>
|
||||
) -> Usually<Rect> {
|
||||
) -> Usually<(Rect, Vec<Rect>)> {
|
||||
let Rect { mut x, mut y, width, height } = area;
|
||||
let mut w = 0u16;
|
||||
let mut h = 0u16;
|
||||
|
|
@ -113,7 +113,7 @@ pub fn draw_as_row (
|
|||
h = h.max(frame.height);
|
||||
x = x + frame.width;
|
||||
}
|
||||
Ok(area)
|
||||
Ok((area, frames))
|
||||
}
|
||||
|
||||
pub fn draw_as_column (
|
||||
|
|
|
|||
|
|
@ -145,36 +145,32 @@ pub fn render (state: &Launcher, buf: &mut Buffer, area: Rect) -> Usually<Rect>
|
|||
separator.blit(buf, x, y + 5, Some(Style::default().dim()));
|
||||
separator.blit(buf, x, y + 22, Some(Style::default().dim()));
|
||||
separator.blit(buf, x, y + 41, Some(Style::default().dim()));
|
||||
let (w, mut highlight) = draw_tracks(state, buf, track_area.x, track_area.y);
|
||||
let (w, mut track_highlight) = draw_tracks(state, buf, track_area.x, track_area.y);
|
||||
if state.col() == 0 {
|
||||
highlight = Some(scenes);
|
||||
track_highlight = Some(scenes);
|
||||
}
|
||||
draw_crossings(state, buf, x + w - 2, y + 1);
|
||||
draw_box(buf, Rect { x, y: y + 1, width, height: height - 1 });
|
||||
let style = Some(Style::default().green().dim());
|
||||
crate::device::chain::draw_as_row(
|
||||
&*state.chains[0].state(), buf, chain_area, style
|
||||
)?;
|
||||
let chain = &*state.chains[0].state();
|
||||
let (_, plugins) = crate::device::chain::draw_as_row(chain, buf, chain_area, style)?;
|
||||
match state.view {
|
||||
LauncherView::Tracks => draw_box_styled(buf, track_area, style),
|
||||
LauncherView::Sequencer => draw_box_styled(buf, seq_area, style),
|
||||
LauncherView::Chains => draw_box_styled(buf, Rect { height: 18, ..chain_area }, style),
|
||||
};
|
||||
draw_highlight(state, buf, &highlight);
|
||||
draw_highlight(state, buf, &track_highlight, match state.view {
|
||||
LauncherView::Tracks => Style::default().green().not_dim(),
|
||||
_ => Style::default().green().dim()
|
||||
});
|
||||
draw_highlight(state, buf, &Some(plugins[chain.focus]), match state.view {
|
||||
LauncherView::Chains => Style::default().green().not_dim(),
|
||||
_ => Style::default().green().dim()
|
||||
});
|
||||
draw_sequencer(state, buf, seq_area.x, seq_area.y + 1, seq_area.width, seq_area.height - 2)?;
|
||||
if state.show_help {
|
||||
let style = Some(Style::default().bold().white().not_dim().on_black().italic());
|
||||
//" [Tab] ".blit(buf, 1, match state.view {
|
||||
//LauncherView::Tracks => 21,
|
||||
//LauncherView::Sequencer => 40,
|
||||
//LauncherView::Chains => 0,
|
||||
//}, style);
|
||||
//" [Shift-Tab] ".blit(buf, 1, match state.view {
|
||||
//LauncherView::Tracks => 40,
|
||||
//LauncherView::Sequencer => 0,
|
||||
//LauncherView::Chains => 21,
|
||||
//}, style);
|
||||
let hide = "[F1] Toggle help ";
|
||||
let hide = "[Left/Right] Track [Up/Down] Scene [,/.] Value [F1] Toggle help ";
|
||||
hide.blit(buf, width - hide.len() as u16, height - 1, style);
|
||||
}
|
||||
Ok(area)
|
||||
|
|
@ -293,16 +289,19 @@ fn draw_sequencer (
|
|||
&sequencer.state(), buf, x, y + 1, width,
|
||||
);
|
||||
crate::device::sequencer::horizontal::cursor(
|
||||
&sequencer.state(), buf, x, y + 1,
|
||||
&sequencer.state(), buf, x, y + 1, match state.view {
|
||||
LauncherView::Sequencer => Style::default().green().not_dim(),
|
||||
_ => Style::default().green().dim(),
|
||||
}
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn draw_highlight (
|
||||
state: &Launcher, buf: &mut Buffer, highlight: &Option<Rect>
|
||||
state: &Launcher, buf: &mut Buffer, highlight: &Option<Rect>, style: Style
|
||||
) {
|
||||
if let Some(area) = highlight {
|
||||
draw_box_styled(buf, *area, Some(Style::default().green().dim()));
|
||||
draw_box_styled(buf, *area, Some(style));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ pub fn render (state: &Plugin, buf: &mut Buffer, area: Rect)
|
|||
}
|
||||
};
|
||||
draw_header(state, buf, area.x, area.y, width);
|
||||
Ok(area)
|
||||
Ok(Rect { width, ..area })
|
||||
}
|
||||
|
||||
fn draw_header (state: &Plugin, buf: &mut Buffer, x: u16, y: u16, w: u16) -> Usually<Rect> {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub fn draw (
|
|||
timer(s, buf, x, y, beat);
|
||||
let height = 32.max(s.note_axis.1 - s.note_axis.0) / 2;
|
||||
lanes(s, buf, x, y, width);
|
||||
cursor(s, buf, x, y);
|
||||
cursor(s, buf, x, y, Style::default().green().not_dim());
|
||||
footer(s, buf, x, y, width, height);
|
||||
Ok(Rect {
|
||||
x: x - 13,
|
||||
|
|
@ -94,12 +94,12 @@ pub fn lanes (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, width: u16) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn cursor (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16) {
|
||||
pub fn cursor (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, style: Style) {
|
||||
buf.set_string(
|
||||
x + 5 + s.time_cursor,
|
||||
y + s.note_cursor / 2,
|
||||
if s.note_cursor % 2 == 0 { "▀" } else { "▄" },
|
||||
Style::default().green().not_dim()
|
||||
style
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue