mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
focus is weird
This commit is contained in:
parent
f5d02f9f08
commit
7b568c55b8
4 changed files with 24 additions and 27 deletions
|
|
@ -249,7 +249,7 @@ fn draw_vertical (s: &Sequencer, buf: &mut Buffer, area: Rect, beat: usize) -> U
|
|||
let Rect { x, y, .. } = area;
|
||||
let (time0, time1) = s.time_axis;
|
||||
let (note0, note1) = s.note_axis;
|
||||
let _bw = Style::default().dim();
|
||||
let bw = Style::default().dim().on_black();
|
||||
let bg = Style::default().on_black();
|
||||
for key in note0..note1 {
|
||||
let x = x + 5 + key - note0;
|
||||
|
|
@ -295,7 +295,7 @@ fn draw_vertical (s: &Sequencer, buf: &mut Buffer, area: Rect, beat: usize) -> U
|
|||
(true, true) => ("█", bg),
|
||||
(true, false) => ("▀", bg),
|
||||
(false, true) => ("▄", bg),
|
||||
(false, false) => (" ", bg),
|
||||
(false, false) => ("·", bw),
|
||||
};
|
||||
buf.set_string(x + 5 + k - note0, y, character, style);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ pub fn render (state: &Transport, buf: &mut Buffer, mut area: Rect)
|
|||
{
|
||||
//area.x = area.width.saturating_sub(80) / 2;
|
||||
//area.width = area.width.min(80);
|
||||
area.height = 5;
|
||||
//draw_box(buf, area);
|
||||
area.height = 3;
|
||||
draw_box(buf, area);
|
||||
let label = Style::default().white().not_dim();
|
||||
let border = Style::default().gray().dim();
|
||||
let mut x = 2;
|
||||
|
|
@ -79,13 +79,12 @@ pub fn render (state: &Transport, buf: &mut Buffer, mut area: Rect)
|
|||
state.timebase.tempo() % 1000,
|
||||
)
|
||||
].iter() {
|
||||
buf.set_string(area.x + x, area.y + 2, button, label);
|
||||
buf.set_string(area.x + x, area.y + 1, button, label);
|
||||
x = x + button.len() as u16 + 1;
|
||||
buf.set_string(area.x + x, area.y + 1, "│", border);
|
||||
buf.set_string(area.x + x, area.y + 2, "│", border);
|
||||
buf.set_string(area.x + x, area.y + 3, "│", border);
|
||||
x = x + 2;
|
||||
}
|
||||
Ok(area)
|
||||
//buf.set_string(area.x, area.y + 5, "Witty Gerbil - Sha Na Na", label.bold());
|
||||
//&format!(" │ 00:00.00 / 00:00.00"), style);
|
||||
//draw_leaf(buf, area, 1, 0, "REC");
|
||||
|
|
@ -171,7 +170,6 @@ pub fn render (state: &Transport, buf: &mut Buffer, mut area: Rect)
|
|||
//None => String::from("(none)")
|
||||
//}).render(area.clone().offset(Offset { x: 50, y: 2 }), buf);
|
||||
//}
|
||||
Ok(area)
|
||||
}
|
||||
|
||||
//pub fn render (
|
||||
|
|
|
|||
|
|
@ -18,11 +18,12 @@ fn handle_focus <T: Device + Focus> (
|
|||
event: &AppEvent,
|
||||
keymap: &[KeyBinding<T>]
|
||||
) -> Usually<bool> {
|
||||
return Ok(if let Some(focused) = state.focused_mut() {
|
||||
let handled = if let Some(focused) = state.focused_mut() {
|
||||
focused.handle(event)
|
||||
} else {
|
||||
Ok(false)
|
||||
}? || handle_keymap(
|
||||
};
|
||||
return Ok(handled? || handle_keymap(
|
||||
state, event, keymap
|
||||
)?)
|
||||
}
|
||||
|
|
@ -154,18 +155,17 @@ impl Device for Rows {
|
|||
width: area.width,
|
||||
height: area.height - h
|
||||
})?;
|
||||
if !self.focused && i == self.focus {
|
||||
draw_box_styled(buf, result, Some(Style::default().green().dim().bold()));
|
||||
if i == self.focus {
|
||||
draw_box_styled(buf, result, Some(if true || self.focused {
|
||||
Style::default().green()
|
||||
} else {
|
||||
Style::default()
|
||||
}));
|
||||
}
|
||||
w = w.max(result.width);
|
||||
h = h + result.height;
|
||||
}
|
||||
Ok(Rect {
|
||||
x: area.x,
|
||||
y: area.y,
|
||||
width: w,
|
||||
height: h
|
||||
})
|
||||
Ok(Rect { x: area.x, y: area.y, width: w, height: h })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -193,17 +193,16 @@ impl Device for Columns {
|
|||
width: area.width - w,
|
||||
height: area.height
|
||||
})?;
|
||||
if !self.focused && i == self.focus {
|
||||
draw_box_styled(buf, result, Some(Style::default().green()));
|
||||
if i == self.focus {
|
||||
draw_box_styled(buf, result, Some(if true || self.focused {
|
||||
Style::default().green()
|
||||
} else {
|
||||
Style::default()
|
||||
}));
|
||||
}
|
||||
w = w + result.width;
|
||||
h = h.max(result.height);
|
||||
}
|
||||
Ok(Rect {
|
||||
x: area.x,
|
||||
y: area.y,
|
||||
width: w,
|
||||
height: h
|
||||
})
|
||||
Ok(Rect { x: area.x, y: area.y, width: w, height: h })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ fn main () -> Result<(), Box<dyn Error>> {
|
|||
//crate::device::run(Sequencer::new("Rhythm#000")?)
|
||||
let transport = Transport::new("Transport")?;
|
||||
let timebase = transport.state.lock().unwrap().timebase();
|
||||
crate::device::run(Rows::new(false, vec![
|
||||
crate::device::run(Rows::new(true, vec![
|
||||
Box::new(transport),
|
||||
Box::new(Columns::new(false, vec![
|
||||
Box::new(Chain::new("Chain#0000", vec![
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue