1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-08-02 20:08:31 +00:00

TR-rust/bootloader: make it compile - TODO: get rid of StrBuffer dependence

This commit is contained in:
grdddj 2023-03-31 15:08:31 +02:00
parent a4f55c9680
commit 16e7a492dd
5 changed files with 31 additions and 39 deletions

View File

@ -32,8 +32,8 @@ pub struct Confirm {
bg_color: Color, bg_color: Color,
icon: Option<Icon>, icon: Option<Icon>,
message: Child<Paragraphs<ParagraphVecShort<&'static str>>>, message: Child<Paragraphs<ParagraphVecShort<&'static str>>>,
left: Child<Button<&'static str>>, left: Child<Button>,
right: Child<Button<&'static str>>, right: Child<Button>,
confirm_left: bool, confirm_left: bool,
} }
@ -42,8 +42,8 @@ impl Confirm {
bg_color: Color, bg_color: Color,
icon: Option<Icon>, icon: Option<Icon>,
message: Paragraphs<ParagraphVecShort<&'static str>>, message: Paragraphs<ParagraphVecShort<&'static str>>,
left: Button<&'static str>, left: Button,
right: Button<&'static str>, right: Button,
confirm_left: bool, confirm_left: bool,
) -> Self { ) -> Self {
let mut instance = Self { let mut instance = Self {
@ -111,6 +111,7 @@ impl Component for Confirm {
self.right.paint(); self.right.paint();
} }
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) { fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.left.bounds(sink); self.left.bounds(sink);
self.right.bounds(sink); self.right.bounds(sink);

View File

@ -35,8 +35,8 @@ impl ReturnToC for IntroMsg {
pub struct Intro { pub struct Intro {
bg: Pad, bg: Pad,
title: Child<Title>, title: Child<Title>,
host: Child<Button<&'static str>>, host: Child<Button>,
menu: Child<Button<&'static str>>, menu: Child<Button>,
text: Child<Paragraphs<ParagraphVecShort<&'static str>>>, text: Child<Paragraphs<ParagraphVecShort<&'static str>>>,
} }
@ -55,12 +55,14 @@ impl Intro {
title: Child::new(Title::new(bld_version)), title: Child::new(Title::new(bld_version)),
host: Child::new(Button::with_text( host: Child::new(Button::with_text(
ButtonPos::Left, ButtonPos::Left,
"INSTALL FIRMWARE", // TODO: this relies on StrBuffer support for bootloader, decide what to do
"INSTALL FIRMWARE".into(),
bld_button_default(), bld_button_default(),
)), )),
menu: Child::new(Button::with_text( menu: Child::new(Button::with_text(
ButtonPos::Right, ButtonPos::Right,
"MENU", // TODO: this relies on StrBuffer support for bootloader, decide what to do
"MENU".into(),
bld_button_default(), bld_button_default(),
)), )),
text: Child::new(p1), text: Child::new(p1),
@ -107,6 +109,7 @@ impl Component for Intro {
self.menu.paint(); self.menu.paint();
} }
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) { fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.title.bounds(sink); self.title.bounds(sink);
self.text.bounds(sink); self.text.bounds(sink);

View File

@ -78,7 +78,7 @@ where
{ {
frame.place(SCREEN_ADJ); frame.place(SCREEN_ADJ);
frame.paint(); frame.paint();
fade_backlight_duration(BACKLIGHT_NORMAL as _, 500); fade_backlight_duration(BACKLIGHT_NORMAL, 500);
while button_eval().is_some() {} while button_eval().is_some() {}
@ -139,8 +139,9 @@ extern "C" fn screen_install_confirm(
message.add(Paragraph::new(&theme::TEXT_BOLD, "Seed will be erased!").centered()); message.add(Paragraph::new(&theme::TEXT_BOLD, "Seed will be erased!").centered());
} }
let left = Button::with_text(ButtonPos::Left, "CANCEL", bld_button_cancel()); // TODO: this relies on StrBuffer support for bootloader, decide what to do
let right = Button::with_text(ButtonPos::Right, "INSTALL", bld_button_default()); let left = Button::with_text(ButtonPos::Left, "CANCEL".into(), bld_button_cancel());
let right = Button::with_text(ButtonPos::Right, "INSTALL".into(), bld_button_default());
let mut frame = Confirm::new( let mut frame = Confirm::new(
BLD_BG, BLD_BG,
@ -172,8 +173,9 @@ extern "C" fn screen_wipe_confirm() -> u32 {
let message = let message =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
let left = Button::with_text(ButtonPos::Left, "WIPE", bld_button_default()); // TODO: this relies on StrBuffer support for bootloader, decide what to do
let right = Button::with_text(ButtonPos::Right, "CANCEL", bld_button_cancel()); let left = Button::with_text(ButtonPos::Left, "WIPE".into(), bld_button_default());
let right = Button::with_text(ButtonPos::Right, "CANCEL".into(), bld_button_cancel());
let mut frame = Confirm::new(BLD_BG, icon, message, left, right, true); let mut frame = Confirm::new(BLD_BG, icon, message, left, right, true);
@ -220,7 +222,14 @@ fn screen_progress(
let fill_to = (loader_area.width() as u32 * progress as u32) / 1000; let fill_to = (loader_area.width() as u32 * progress as u32) / 1000;
display::bar_with_text_and_fill(loader_area, Some(text), fg_color, bg_color, 0, fill_to as _); display::bar_with_text_and_fill(
loader_area,
Some(&text),
fg_color,
bg_color,
0,
fill_to as _,
);
display::refresh(); display::refresh();
} }

View File

@ -2,7 +2,7 @@ use crate::ui::{
component::text::TextStyle, component::text::TextStyle,
display::{Color, Font}, display::{Color, Font},
model_tr::{ model_tr::{
component::{ButtonStyle, ButtonStyleSheet}, component::ButtonStyleSheet,
theme::{BG, BLACK, FG, WHITE}, theme::{BG, BLACK, FG, WHITE},
}, },
}; };
@ -17,33 +17,11 @@ pub const RADIUS: u8 = 2;
pub const ICON_SIZE: i32 = 16; pub const ICON_SIZE: i32 = 16;
pub fn bld_button_default() -> ButtonStyleSheet { pub fn bld_button_default() -> ButtonStyleSheet {
ButtonStyleSheet { ButtonStyleSheet::new(BG, FG, false, false, None, None)
normal: &ButtonStyle {
font: Font::NORMAL,
text_color: BG,
border_horiz: true,
},
active: &ButtonStyle {
font: Font::NORMAL,
text_color: FG,
border_horiz: true,
},
}
} }
pub fn bld_button_cancel() -> ButtonStyleSheet { pub fn bld_button_cancel() -> ButtonStyleSheet {
ButtonStyleSheet { ButtonStyleSheet::new(FG, BG, false, false, None, None)
normal: &ButtonStyle {
font: Font::NORMAL,
text_color: FG,
border_horiz: false,
},
active: &ButtonStyle {
font: Font::NORMAL,
text_color: BG,
border_horiz: false,
},
}
} }
pub const TEXT_NORMAL: TextStyle = TextStyle::new(Font::NORMAL, BLD_FG, BLD_BG, BLD_FG, BLD_FG); pub const TEXT_NORMAL: TextStyle = TextStyle::new(Font::NORMAL, BLD_FG, BLD_BG, BLD_FG, BLD_FG);

View File

@ -48,5 +48,6 @@ impl Component for Title {
); );
} }
#[cfg(feature = "ui_bounds")]
fn bounds(&self, _sink: &mut dyn FnMut(Rect)) {} fn bounds(&self, _sink: &mut dyn FnMut(Rect)) {}
} }