Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render draw_value_box before render loop #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mateolafalce
Copy link

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

@jackpot51
Copy link
Member

Have you tested this?

@mateolafalce
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants