mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 12:46:42 +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 Rect { x, y, .. } = area;
|
||||||
let (time0, time1) = s.time_axis;
|
let (time0, time1) = s.time_axis;
|
||||||
let (note0, note1) = s.note_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();
|
let bg = Style::default().on_black();
|
||||||
for key in note0..note1 {
|
for key in note0..note1 {
|
||||||
let x = x + 5 + key - note0;
|
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, true) => ("█", bg),
|
||||||
(true, false) => ("▀", bg),
|
(true, false) => ("▀", bg),
|
||||||
(false, true) => ("▄", bg),
|
(false, true) => ("▄", bg),
|
||||||
(false, false) => (" ", bg),
|
(false, false) => ("·", bw),
|
||||||
};
|
};
|
||||||
buf.set_string(x + 5 + k - note0, y, character, style);
|
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.x = area.width.saturating_sub(80) / 2;
|
||||||
//area.width = area.width.min(80);
|
//area.width = area.width.min(80);
|
||||||
area.height = 5;
|
area.height = 3;
|
||||||
//draw_box(buf, area);
|
draw_box(buf, area);
|
||||||
let label = Style::default().white().not_dim();
|
let label = Style::default().white().not_dim();
|
||||||
let border = Style::default().gray().dim();
|
let border = Style::default().gray().dim();
|
||||||
let mut x = 2;
|
let mut x = 2;
|
||||||
|
|
@ -79,13 +79,12 @@ pub fn render (state: &Transport, buf: &mut Buffer, mut area: Rect)
|
||||||
state.timebase.tempo() % 1000,
|
state.timebase.tempo() % 1000,
|
||||||
)
|
)
|
||||||
].iter() {
|
].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;
|
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 + 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;
|
x = x + 2;
|
||||||
}
|
}
|
||||||
|
Ok(area)
|
||||||
//buf.set_string(area.x, area.y + 5, "Witty Gerbil - Sha Na Na", label.bold());
|
//buf.set_string(area.x, area.y + 5, "Witty Gerbil - Sha Na Na", label.bold());
|
||||||
//&format!(" │ 00:00.00 / 00:00.00"), style);
|
//&format!(" │ 00:00.00 / 00:00.00"), style);
|
||||||
//draw_leaf(buf, area, 1, 0, "REC");
|
//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)")
|
//None => String::from("(none)")
|
||||||
//}).render(area.clone().offset(Offset { x: 50, y: 2 }), buf);
|
//}).render(area.clone().offset(Offset { x: 50, y: 2 }), buf);
|
||||||
//}
|
//}
|
||||||
Ok(area)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//pub fn render (
|
//pub fn render (
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,12 @@ fn handle_focus <T: Device + Focus> (
|
||||||
event: &AppEvent,
|
event: &AppEvent,
|
||||||
keymap: &[KeyBinding<T>]
|
keymap: &[KeyBinding<T>]
|
||||||
) -> Usually<bool> {
|
) -> Usually<bool> {
|
||||||
return Ok(if let Some(focused) = state.focused_mut() {
|
let handled = if let Some(focused) = state.focused_mut() {
|
||||||
focused.handle(event)
|
focused.handle(event)
|
||||||
} else {
|
} else {
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}? || handle_keymap(
|
};
|
||||||
|
return Ok(handled? || handle_keymap(
|
||||||
state, event, keymap
|
state, event, keymap
|
||||||
)?)
|
)?)
|
||||||
}
|
}
|
||||||
|
|
@ -154,18 +155,17 @@ impl Device for Rows {
|
||||||
width: area.width,
|
width: area.width,
|
||||||
height: area.height - h
|
height: area.height - h
|
||||||
})?;
|
})?;
|
||||||
if !self.focused && i == self.focus {
|
if i == self.focus {
|
||||||
draw_box_styled(buf, result, Some(Style::default().green().dim().bold()));
|
draw_box_styled(buf, result, Some(if true || self.focused {
|
||||||
|
Style::default().green()
|
||||||
|
} else {
|
||||||
|
Style::default()
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
w = w.max(result.width);
|
w = w.max(result.width);
|
||||||
h = h + result.height;
|
h = h + result.height;
|
||||||
}
|
}
|
||||||
Ok(Rect {
|
Ok(Rect { x: area.x, y: area.y, width: w, height: h })
|
||||||
x: area.x,
|
|
||||||
y: area.y,
|
|
||||||
width: w,
|
|
||||||
height: h
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,17 +193,16 @@ impl Device for Columns {
|
||||||
width: area.width - w,
|
width: area.width - w,
|
||||||
height: area.height
|
height: area.height
|
||||||
})?;
|
})?;
|
||||||
if !self.focused && i == self.focus {
|
if i == self.focus {
|
||||||
draw_box_styled(buf, result, Some(Style::default().green()));
|
draw_box_styled(buf, result, Some(if true || self.focused {
|
||||||
|
Style::default().green()
|
||||||
|
} else {
|
||||||
|
Style::default()
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
w = w + result.width;
|
w = w + result.width;
|
||||||
h = h.max(result.height);
|
h = h.max(result.height);
|
||||||
}
|
}
|
||||||
Ok(Rect {
|
Ok(Rect { x: area.x, y: area.y, width: w, height: h })
|
||||||
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")?)
|
//crate::device::run(Sequencer::new("Rhythm#000")?)
|
||||||
let transport = Transport::new("Transport")?;
|
let transport = Transport::new("Transport")?;
|
||||||
let timebase = transport.state.lock().unwrap().timebase();
|
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(transport),
|
||||||
Box::new(Columns::new(false, vec![
|
Box::new(Columns::new(false, vec![
|
||||||
Box::new(Chain::new("Chain#0000", vec![
|
Box::new(Chain::new("Chain#0000", vec![
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue