mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
IT BOPS
This commit is contained in:
parent
0ba14bf2da
commit
3ba5e253b0
5 changed files with 120 additions and 59 deletions
|
|
@ -171,13 +171,24 @@ pub fn render (state: &Plugin, buf: &mut Buffer, area: Rect)
|
|||
let Rect { x, y, height, .. } = area;
|
||||
let mut width = 40u16;
|
||||
match &state.plugin {
|
||||
Some(PluginKind::LV2 { portList, .. }) => {
|
||||
Some(PluginKind::LV2 { portList, instance, .. }) => {
|
||||
let start = state.selected.saturating_sub((height as usize / 2).saturating_sub(1));
|
||||
let end = start + height as usize - 2;
|
||||
//draw_box(buf, Rect { x, y, width, height });
|
||||
for i in 0..height-3 {
|
||||
if let Some(port) = portList.get(i as usize) {
|
||||
let label = &format!("C·· M·· {:25} = {:03}", port.name, port.default_value);
|
||||
for i in start..end {
|
||||
if let Some(port) = portList.get(i) {
|
||||
let value = if let Some(value) = instance.control_input(port.index) {
|
||||
value
|
||||
} else {
|
||||
port.default_value
|
||||
};
|
||||
let label = &format!("C·· M·· {:25} = {value:.03}", port.name);
|
||||
width = width.max(label.len() as u16);
|
||||
label.blit(buf, x + 2, y + 2 + i as u16, None);
|
||||
label.blit(buf, x + 2, y + 1 + i as u16 - start as u16, if i == state.selected {
|
||||
Some(Style::default().green())
|
||||
} else {
|
||||
None
|
||||
});
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
|
@ -200,26 +211,67 @@ fn draw_header (state: &Plugin, buf: &mut Buffer, x: u16, y: u16, w: u16) -> Usu
|
|||
|
||||
pub fn handle (s: &mut Plugin, event: &AppEvent) -> Usually<bool> {
|
||||
handle_keymap(s, event, keymap!(Plugin {
|
||||
|
||||
[Up, NONE, "cursor_up", "move cursor up",
|
||||
|s: &mut Plugin|{
|
||||
s.selected = s.selected.saturating_sub(1);
|
||||
if s.selected < s.offset {
|
||||
s.offset = s.selected;
|
||||
if s.selected > 0 {
|
||||
s.selected = s.selected - 1
|
||||
} else {
|
||||
s.selected = match &s.plugin {
|
||||
Some(PluginKind::LV2 { portList, .. }) => portList.len() - 1,
|
||||
_ => 0
|
||||
}
|
||||
}
|
||||
Ok(true)
|
||||
}],
|
||||
|
||||
[Down, NONE, "cursor_down", "move cursor down",
|
||||
|s: &mut Plugin|{
|
||||
s.selected = s.selected + 1;
|
||||
if s.selected >= s.offset + 19 {
|
||||
s.offset = s.offset + 1;
|
||||
match &s.plugin {
|
||||
Some(PluginKind::LV2 { portList, .. }) => {
|
||||
if s.selected >= portList.len() {
|
||||
s.selected = 0;
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
Ok(true)
|
||||
}],
|
||||
|
||||
[Char(','), NONE, "decrement", "decrement value",
|
||||
|s: &mut Plugin|{
|
||||
match s.plugin.as_mut() {
|
||||
Some(PluginKind::LV2 { portList, ref mut instance, .. }) => {
|
||||
let index = portList[s.selected].index;
|
||||
if let Some(value) = instance.control_input(index) {
|
||||
instance.set_control_input(index, value - 0.01);
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
Ok(true)
|
||||
}],
|
||||
|
||||
[Char('.'), NONE, "increment", "increment value",
|
||||
|s: &mut Plugin|{
|
||||
match s.plugin.as_mut() {
|
||||
Some(PluginKind::LV2 { portList, ref mut instance, .. }) => {
|
||||
let index = portList[s.selected].index;
|
||||
if let Some(value) = instance.control_input(index) {
|
||||
instance.set_control_input(index, value + 0.01);
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
Ok(true)
|
||||
}],
|
||||
|
||||
[Char('m'), NONE, "toggle_midi_map", "toggle midi map mode",
|
||||
|s: &mut Plugin|{
|
||||
s.mapping = !s.mapping;
|
||||
Ok(true)
|
||||
}]
|
||||
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue