mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +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::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub struct Chain {
|
pub struct Chain {
|
||||||
name: String,
|
pub name: String,
|
||||||
focused: bool,
|
pub focused: bool,
|
||||||
focus: usize,
|
pub focus: usize,
|
||||||
items: Vec<Box<dyn Device>>,
|
pub items: Vec<Box<dyn Device>>,
|
||||||
view: ChainView
|
pub view: ChainView
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum ChainView {
|
pub enum ChainView {
|
||||||
|
|
@ -97,7 +97,7 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
||||||
|
|
||||||
pub fn draw_as_row (
|
pub fn draw_as_row (
|
||||||
state: &Chain, buf: &mut Buffer, area: Rect, selected: Option<Style>
|
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 Rect { mut x, mut y, width, height } = area;
|
||||||
let mut w = 0u16;
|
let mut w = 0u16;
|
||||||
let mut h = 0u16;
|
let mut h = 0u16;
|
||||||
|
|
@ -113,7 +113,7 @@ pub fn draw_as_row (
|
||||||
h = h.max(frame.height);
|
h = h.max(frame.height);
|
||||||
x = x + frame.width;
|
x = x + frame.width;
|
||||||
}
|
}
|
||||||
Ok(area)
|
Ok((area, frames))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_as_column (
|
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 + 5, Some(Style::default().dim()));
|
||||||
separator.blit(buf, x, y + 22, Some(Style::default().dim()));
|
separator.blit(buf, x, y + 22, Some(Style::default().dim()));
|
||||||
separator.blit(buf, x, y + 41, 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 {
|
if state.col() == 0 {
|
||||||
highlight = Some(scenes);
|
track_highlight = Some(scenes);
|
||||||
}
|
}
|
||||||
draw_crossings(state, buf, x + w - 2, y + 1);
|
draw_crossings(state, buf, x + w - 2, y + 1);
|
||||||
draw_box(buf, Rect { x, y: y + 1, width, height: height - 1 });
|
draw_box(buf, Rect { x, y: y + 1, width, height: height - 1 });
|
||||||
let style = Some(Style::default().green().dim());
|
let style = Some(Style::default().green().dim());
|
||||||
crate::device::chain::draw_as_row(
|
let chain = &*state.chains[0].state();
|
||||||
&*state.chains[0].state(), buf, chain_area, style
|
let (_, plugins) = crate::device::chain::draw_as_row(chain, buf, chain_area, style)?;
|
||||||
)?;
|
|
||||||
match state.view {
|
match state.view {
|
||||||
LauncherView::Tracks => draw_box_styled(buf, track_area, style),
|
LauncherView::Tracks => draw_box_styled(buf, track_area, style),
|
||||||
LauncherView::Sequencer => draw_box_styled(buf, seq_area, style),
|
LauncherView::Sequencer => draw_box_styled(buf, seq_area, style),
|
||||||
LauncherView::Chains => draw_box_styled(buf, Rect { height: 18, ..chain_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)?;
|
draw_sequencer(state, buf, seq_area.x, seq_area.y + 1, seq_area.width, seq_area.height - 2)?;
|
||||||
if state.show_help {
|
if state.show_help {
|
||||||
let style = Some(Style::default().bold().white().not_dim().on_black().italic());
|
let style = Some(Style::default().bold().white().not_dim().on_black().italic());
|
||||||
//" [Tab] ".blit(buf, 1, match state.view {
|
let hide = "[Left/Right] Track [Up/Down] Scene [,/.] Value [F1] Toggle help ";
|
||||||
//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 ";
|
|
||||||
hide.blit(buf, width - hide.len() as u16, height - 1, style);
|
hide.blit(buf, width - hide.len() as u16, height - 1, style);
|
||||||
}
|
}
|
||||||
Ok(area)
|
Ok(area)
|
||||||
|
|
@ -293,16 +289,19 @@ fn draw_sequencer (
|
||||||
&sequencer.state(), buf, x, y + 1, width,
|
&sequencer.state(), buf, x, y + 1, width,
|
||||||
);
|
);
|
||||||
crate::device::sequencer::horizontal::cursor(
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn draw_highlight (
|
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 {
|
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);
|
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> {
|
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);
|
timer(s, buf, x, y, beat);
|
||||||
let height = 32.max(s.note_axis.1 - s.note_axis.0) / 2;
|
let height = 32.max(s.note_axis.1 - s.note_axis.0) / 2;
|
||||||
lanes(s, buf, x, y, width);
|
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);
|
footer(s, buf, x, y, width, height);
|
||||||
Ok(Rect {
|
Ok(Rect {
|
||||||
x: x - 13,
|
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(
|
buf.set_string(
|
||||||
x + 5 + s.time_cursor,
|
x + 5 + s.time_cursor,
|
||||||
y + s.note_cursor / 2,
|
y + s.note_cursor / 2,
|
||||||
if s.note_cursor % 2 == 0 { "▀" } else { "▄" },
|
if s.note_cursor % 2 == 0 { "▀" } else { "▄" },
|
||||||
Style::default().green().not_dim()
|
style
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue