Skip to content

render draw_value_box before render loop #54

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 22 additions & 28 deletions src/fde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::uefi::hii::{AnimationId, ImageId, StringId};
use std::uefi::text::TextInputKey;

use crate::display::{Display, Output};
use crate::key::{raw_key, Key};
use crate::key::{Key, raw_key};
use crate::ui::Ui;

// TODO: Move to uefi library {
Expand Down Expand Up @@ -399,6 +399,26 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> {

let ui = Ui::new()?;

let draw_value_box = |display: &mut Display,
x: i32,
y: i32,
value: &IfrTypeValueEnum,
highlighted: bool|
-> i32 {
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:?}"),
};

let rendered = ui.font.render(&value_string, font_size);
ui.draw_text_box(display, x, y, &rendered, true, highlighted);
rendered.height() as i32
};

'render: loop {
let mut hotkey_helps = Vec::new();
for hotkey in form.HotKeyListHead.iter() {
Expand Down Expand Up @@ -511,9 +531,7 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> {

if let Some(op) = statement.OpCode() {
macro_rules! cast {
($type:ty) => {{
op.cast::<$type>()
}};
($type:ty) => {{ op.cast::<$type>() }};
}
match op.OpCode {
IfrOpCode::Action => {
Expand Down Expand Up @@ -561,30 +579,6 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> {
'display: loop {
display.set(ui.background_color);

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
};

let draw_options_box =
|display: &mut Display, x: i32, mut y: i32, element: &Element| {
let mut w = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/security.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::proto::Protocol;
use std::uefi::{boot::InterfaceType, reset::ResetType};

use crate::display::{Display, Output};
use crate::key::{key, Key};
use crate::key::{Key, key};
use crate::rng::Rng;
use crate::ui::Ui;

Expand Down