firmware-setup icon indicating copy to clipboard operation
firmware-setup copied to clipboard

render draw_value_box before render loop

Open mateolafalce opened this issue 10 months ago • 2 comments

draw_value_box could be render before loops. Others TODOs needs more logic

mateolafalce avatar Feb 28 '25 12:02 mateolafalce

Have you tested this?

jackpot51 avatar Feb 28 '25 14:02 jackpot51

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

mateolafalce avatar Feb 28 '25 15:02 mateolafalce