firmware-setup
firmware-setup copied to clipboard
render draw_value_box before render loop
draw_value_box could be render before loops. Others TODOs needs more logic
Have you tested this?
Yes, it almost works in QEMU.
You could try moving the line of code deleted before the loop (right after let ui = Ui::new()?).
let draw_value_box = |display: &mut Display,
x: i32,
y: i32,
value: &IfrTypeValueEnum,
highlighted: bool|
-> i32 {
//TODO: Do not format in drawing loop
let value_string = match value {
IfrTypeValueEnum::U8(value) => format!("{value}"),
IfrTypeValueEnum::U16(value) => format!("{value}"),
IfrTypeValueEnum::U32(value) => format!("{value}"),
IfrTypeValueEnum::U64(value) => format!("{value}"),
IfrTypeValueEnum::Bool(value) => {
return ui.draw_check_box(display, x, y, *value)
}
other => format!("{other:?}"),
};
// TODO: Do not render in drawing loop
let rendered = ui.font.render(&value_string, font_size);
ui.draw_text_box(display, x, y, &rendered, true, highlighted);
rendered.height() as i32
};
The new line is the same but without //TODO