mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 05:28:40 +00:00
fixup! feat(core/rust): bootloader implementation in rust
This commit is contained in:
parent
b80c1a4d70
commit
a4cf0ecb54
@ -1,5 +1,8 @@
|
||||
use crate::ui::{
|
||||
component::{text::paragraphs::Paragraphs, Child, Component, Event, EventCtx, Pad},
|
||||
component::{
|
||||
text::paragraphs::{ParagraphVecShort, Paragraphs},
|
||||
Child, Component, Event, EventCtx, Pad,
|
||||
},
|
||||
constant::screen,
|
||||
display,
|
||||
display::Color,
|
||||
@ -29,7 +32,7 @@ pub struct Confirm {
|
||||
bg: Pad,
|
||||
bg_color: Color,
|
||||
icon: Option<&'static [u8]>,
|
||||
message: Child<Paragraphs<&'static str>>,
|
||||
message: Child<Paragraphs<ParagraphVecShort<&'static str>>>,
|
||||
left: Child<Button<&'static str>>,
|
||||
right: Child<Button<&'static str>>,
|
||||
confirm_left: bool,
|
||||
@ -39,7 +42,7 @@ impl Confirm {
|
||||
pub fn new(
|
||||
bg_color: Color,
|
||||
icon: Option<&'static [u8]>,
|
||||
message: Paragraphs<&'static str>,
|
||||
message: Paragraphs<ParagraphVecShort<&'static str>>,
|
||||
left: Button<&'static str>,
|
||||
right: Button<&'static str>,
|
||||
confirm_left: bool,
|
||||
|
@ -70,7 +70,7 @@ impl Component for FwInfo {
|
||||
let ypos = (60 + i * 20) as i16;
|
||||
let idx = i * 16;
|
||||
let part = self.fingerprint.get(idx..idx + 16).unwrap_or("");
|
||||
display::text_top_left(Point::new(15, ypos), part, Font::MEDIUM, BLD_FG, BLD_BG);
|
||||
display::text_top_left(Point::new(15, ypos), part, Font::DEMIBOLD, BLD_FG, BLD_BG);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
use crate::ui::{
|
||||
component::{text::paragraphs::Paragraphs, Child, Component, Event, EventCtx, Pad},
|
||||
component::{
|
||||
text::paragraphs::{Paragraph, ParagraphVecShort, Paragraphs, VecExt},
|
||||
Child, Component, Event, EventCtx, Pad,
|
||||
},
|
||||
geometry::{Insets, LinearPlacement, Point, Rect},
|
||||
model_tt::{
|
||||
bootloader::{
|
||||
@ -33,15 +36,18 @@ pub struct Intro {
|
||||
title: Child<Title>,
|
||||
menu: Child<Button<&'static str>>,
|
||||
host: Child<Button<&'static str>>,
|
||||
text: Child<Paragraphs<&'static str>>,
|
||||
text: Child<Paragraphs<ParagraphVecShort<&'static str>>>,
|
||||
}
|
||||
|
||||
impl Intro {
|
||||
pub fn new(bld_version: &'static str, vendor: &'static str, version: &'static str) -> Self {
|
||||
let p1 = Paragraphs::new()
|
||||
.add(TEXT_NORMAL, version)
|
||||
.add(TEXT_NORMAL, vendor)
|
||||
.with_placement(LinearPlacement::vertical().align_at_start());
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
|
||||
messages.add(Paragraph::new(&TEXT_NORMAL, version));
|
||||
messages.add(Paragraph::new(&TEXT_NORMAL, vendor));
|
||||
|
||||
let p =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_start());
|
||||
|
||||
let mut instance = Self {
|
||||
bg: Pad::with_background(BLD_BG),
|
||||
@ -52,7 +58,7 @@ impl Intro {
|
||||
.with_expanded_touch_area(Insets::uniform(13)),
|
||||
),
|
||||
host: Child::new(Button::with_text("INSTALL FIRMWARE").styled(button_bld_menu_item())),
|
||||
text: Child::new(p1),
|
||||
text: Child::new(p),
|
||||
};
|
||||
|
||||
instance.bg.clear();
|
||||
|
@ -18,7 +18,7 @@ pub mod theme;
|
||||
mod title;
|
||||
|
||||
use crate::ui::{
|
||||
component::text::paragraphs::Paragraphs,
|
||||
component::text::paragraphs::{Paragraph, ParagraphVecShort, Paragraphs, VecExt},
|
||||
display::Color,
|
||||
geometry::LinearPlacement,
|
||||
model_tt::{
|
||||
@ -42,6 +42,8 @@ use confirm::Confirm;
|
||||
use fwinfo::FwInfo;
|
||||
use intro::Intro;
|
||||
use menu::Menu;
|
||||
use crate::ui::constant::screen;
|
||||
use crate::ui::model_tt::bootloader::theme::WELCOME_COLOR;
|
||||
|
||||
pub trait ReturnToC {
|
||||
fn return_to_c(self) -> u32;
|
||||
@ -128,21 +130,18 @@ extern "C" fn screen_install_confirm(
|
||||
"Update firmware by"
|
||||
};
|
||||
|
||||
let mut message = Paragraphs::new()
|
||||
.add(theme::TEXT_NORMAL, msg)
|
||||
.centered()
|
||||
.add(theme::TEXT_NORMAL, text)
|
||||
.centered()
|
||||
.add(theme::TEXT_NORMAL, version)
|
||||
.centered();
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
|
||||
messages.add(Paragraph::new(&theme::TEXT_NORMAL, msg));
|
||||
messages.add(Paragraph::new(&theme::TEXT_NORMAL, text));
|
||||
messages.add(Paragraph::new(&theme::TEXT_NORMAL, version));
|
||||
|
||||
if vendor || downgrade {
|
||||
message = message
|
||||
.add(theme::TEXT_BOLD, "Seed will be erased!")
|
||||
.centered();
|
||||
messages.add(Paragraph::new(&theme::TEXT_BOLD, "Seed will be erased!").centered());
|
||||
}
|
||||
|
||||
message = message.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
let message =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let left = Button::with_text("CANCEL").styled(button_install_cancel());
|
||||
let right = Button::with_text("INSTALL").styled(button_install_confirm());
|
||||
@ -156,12 +155,15 @@ extern "C" fn screen_install_confirm(
|
||||
extern "C" fn screen_wipe_confirm() -> u32 {
|
||||
const ICON: Option<&'static [u8]> = Some(ERASE_BIG);
|
||||
|
||||
let message = Paragraphs::new()
|
||||
.add(TEXT_ERROR_NORMAL, "Do you really want to wipe the device?")
|
||||
.centered()
|
||||
.add(TEXT_ERROR_BOLD, "Seed will be erased!")
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
|
||||
messages.add(
|
||||
Paragraph::new(&TEXT_ERROR_NORMAL, "Do you really want to wipe the device?").centered(),
|
||||
);
|
||||
messages.add(Paragraph::new(&TEXT_ERROR_BOLD, "Seed will be erased!").centered());
|
||||
|
||||
let message =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let left = Button::with_text("WIPE").styled(button_wipe_confirm());
|
||||
let right = Button::with_text("CANCEL").styled(button_wipe_cancel());
|
||||
@ -216,11 +218,9 @@ fn screen_progress(
|
||||
0
|
||||
}
|
||||
|
||||
const INITIAL_INSTALL_LOADER_COLOR: Color = Color::rgb(0x4A, 0x90, 0xE2);
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn screen_install_progress(progress: u16, initialize: bool, initial_setup: bool) -> u32 {
|
||||
let bg_color = if initial_setup { BG } else { BLD_BG };
|
||||
let bg_color = if initial_setup { WELCOME_COLOR } else { BG };
|
||||
let fg_color = if initial_setup { FG } else { BLD_FG };
|
||||
|
||||
screen_progress(
|
||||
@ -284,19 +284,20 @@ extern "C" fn screen_fwinfo(fingerprint: *const cty::c_char) -> u32 {
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn screen_wipe_success() -> u32 {
|
||||
let m_top = Paragraphs::new()
|
||||
.add(theme::TEXT_BOLD, "Device wiped")
|
||||
.centered()
|
||||
.add(theme::TEXT_BOLD, "successfully.")
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
|
||||
let m_bottom = Paragraphs::new()
|
||||
.add(theme::TEXT_SUBMSG, "PLEASE RECONNECT")
|
||||
.centered()
|
||||
.add(theme::TEXT_SUBMSG, "THE DEVICE")
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
messages.add(Paragraph::new(&theme::TEXT_BOLD, "Device wiped").centered());
|
||||
messages.add(Paragraph::new(&theme::TEXT_BOLD, "successfully.").centered());
|
||||
|
||||
let m_top =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
messages.add(Paragraph::new(&theme::TEXT_SUBMSG, "PLEASE RECONNECT").centered());
|
||||
messages.add(Paragraph::new(&theme::TEXT_SUBMSG, "THE DEVICE").centered());
|
||||
|
||||
let m_bottom =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let mut frame = ResultScreen::new(WHITE, BLD_BG, ICON_SUCCESS_SMALL, m_top, m_bottom, true);
|
||||
frame.place(constant::screen());
|
||||
@ -306,19 +307,19 @@ extern "C" fn screen_wipe_success() -> u32 {
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn screen_wipe_fail() -> u32 {
|
||||
let m_top = Paragraphs::new()
|
||||
.add(theme::TEXT_BOLD, "Device wipe was")
|
||||
.centered()
|
||||
.add(theme::TEXT_BOLD, "not successful.")
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
|
||||
let m_bottom = Paragraphs::new()
|
||||
.add(theme::TEXT_SUBMSG, "PLEASE RECONNECT")
|
||||
.centered()
|
||||
.add(theme::TEXT_SUBMSG, "THE DEVICE")
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
messages.add(Paragraph::new(&theme::TEXT_BOLD, "Device wipe was").centered());
|
||||
messages.add(Paragraph::new(&theme::TEXT_BOLD, "not successful.").centered());
|
||||
let m_top =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
|
||||
messages.add(Paragraph::new(&theme::TEXT_SUBMSG, "PLEASE RECONNECT").centered());
|
||||
messages.add(Paragraph::new(&theme::TEXT_SUBMSG, "THE DEVICE").centered());
|
||||
let m_bottom =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let mut frame = ResultScreen::new(WHITE, BLD_BG, ICON_WARN_SMALL, m_top, m_bottom, true);
|
||||
frame.place(constant::screen());
|
||||
@ -329,24 +330,25 @@ extern "C" fn screen_wipe_fail() -> u32 {
|
||||
#[no_mangle]
|
||||
extern "C" fn screen_boot_empty(firmware_present: bool) {
|
||||
let fg = if firmware_present { GREY_DARK } else { WHITE };
|
||||
display::icon(constant::screen().center(), LOGO_EMPTY, fg, BLACK);
|
||||
let bg = if firmware_present {BLACK} else {WELCOME_COLOR};
|
||||
display::rect_fill(constant::screen(), bg);
|
||||
display::icon(constant::screen().center(), LOGO_EMPTY, fg, bg);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn screen_install_fail() -> u32 {
|
||||
let m_top = Paragraphs::new()
|
||||
.add(theme::TEXT_BOLD, "Firmware installation was")
|
||||
.centered()
|
||||
.add(theme::TEXT_BOLD, "not successful.")
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
messages.add(Paragraph::new(&theme::TEXT_BOLD, "Firmware installation was").centered());
|
||||
messages.add(Paragraph::new(&theme::TEXT_BOLD, "not successful.").centered());
|
||||
|
||||
let m_bottom = Paragraphs::new()
|
||||
.add(theme::TEXT_SUBMSG, "PLEASE RECONNECT")
|
||||
.centered()
|
||||
.add(theme::TEXT_SUBMSG, "THE DEVICE")
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
let m_top =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
messages.add(Paragraph::new(&theme::TEXT_SUBMSG, "PLEASE RECONNECT").centered());
|
||||
messages.add(Paragraph::new(&theme::TEXT_SUBMSG, "THE DEVICE").centered());
|
||||
let m_bottom =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let mut frame = ResultScreen::new(WHITE, BLD_BG, ICON_WARN_SMALL, m_top, m_bottom, true);
|
||||
frame.place(constant::screen());
|
||||
@ -355,17 +357,16 @@ extern "C" fn screen_install_fail() -> u32 {
|
||||
}
|
||||
|
||||
fn screen_install_success_bld(msg: &'static str, complete_draw: bool) -> u32 {
|
||||
let m_top = Paragraphs::new()
|
||||
.add(theme::TEXT_BOLD, "Firmware installed")
|
||||
.centered()
|
||||
.add(theme::TEXT_BOLD, "successfully.")
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
messages.add(Paragraph::new(&theme::TEXT_BOLD, "Firmware installed").centered());
|
||||
messages.add(Paragraph::new(&theme::TEXT_BOLD, "successfully.").centered());
|
||||
let m_top =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let m_bottom = Paragraphs::new()
|
||||
.add(theme::TEXT_SUBMSG, msg)
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
messages.add(Paragraph::new(&theme::TEXT_SUBMSG, msg).centered());
|
||||
let m_bottom =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let mut frame = ResultScreen::new(
|
||||
WHITE,
|
||||
@ -381,19 +382,20 @@ fn screen_install_success_bld(msg: &'static str, complete_draw: bool) -> u32 {
|
||||
}
|
||||
|
||||
fn screen_install_success_initial(msg: &'static str, complete_draw: bool) -> u32 {
|
||||
let m_top = Paragraphs::new()
|
||||
.add(theme::TEXT_WELCOME_BOLD, "Firmware installed")
|
||||
.centered()
|
||||
.add(theme::TEXT_WELCOME_BOLD, "successfully.")
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
messages.add(Paragraph::new(&theme::TEXT_WELCOME_BOLD, "Firmware installed").centered());
|
||||
messages.add(Paragraph::new(&theme::TEXT_WELCOME_BOLD, "successfully.").centered());
|
||||
|
||||
let m_bottom = Paragraphs::new()
|
||||
.add(theme::TEXT_SUBMSG_INITIAL, msg)
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
let m_top =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let mut frame = ResultScreen::new(FG, BG, ICON_SUCCESS_SMALL, m_top, m_bottom, complete_draw);
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
messages.add(Paragraph::new(&theme::TEXT_SUBMSG_INITIAL, msg).centered());
|
||||
|
||||
let m_bottom =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let mut frame = ResultScreen::new(FG, WELCOME_COLOR, ICON_SUCCESS_SMALL, m_top, m_bottom, complete_draw);
|
||||
frame.place(constant::screen());
|
||||
frame.paint();
|
||||
0
|
||||
@ -415,14 +417,13 @@ extern "C" fn screen_install_success(
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn screen_welcome() -> u32 {
|
||||
let mut frame = Paragraphs::new()
|
||||
.add(theme::TEXT_WELCOME, "Get started with")
|
||||
.centered()
|
||||
.add(theme::TEXT_WELCOME, "your trezor at")
|
||||
.centered()
|
||||
.add(theme::TEXT_WELCOME_BOLD, "trezor.io/start")
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
display::rect_fill(screen(), WELCOME_COLOR);
|
||||
messages.add(Paragraph::new(&theme::TEXT_WELCOME, "Get started with").centered());
|
||||
messages.add(Paragraph::new(&theme::TEXT_WELCOME, "your trezor at").centered());
|
||||
messages.add(Paragraph::new(&theme::TEXT_WELCOME_BOLD, "trezor.io/start").centered());
|
||||
let mut frame =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
frame.place(constant::screen());
|
||||
frame.paint();
|
||||
|
@ -5,10 +5,11 @@ use crate::{
|
||||
display::{Color, Font},
|
||||
model_tt::{
|
||||
component::{ButtonStyle, ButtonStyleSheet},
|
||||
theme::{BG, FG, GREY_DARK, GREY_LIGHT, GREY_MEDIUM, WHITE},
|
||||
theme::{FG, GREY_DARK, GREY_LIGHT, GREY_MEDIUM, WHITE},
|
||||
},
|
||||
},
|
||||
};
|
||||
use crate::ui::model_tt::theme::BLACK;
|
||||
|
||||
pub const BLD_BG: Color = Color::rgb(0x00, 0x17, 0xA3);
|
||||
pub const BLD_FG: Color = WHITE;
|
||||
@ -23,8 +24,6 @@ pub const BLD_INSTALL_BTN_COLOR_ACTIVE: Color = Color::rgb(0xD9, 0xDC, 0xF1);
|
||||
pub const BLD_INSTALL_CANCEL_BTN_COLOR_ACTIVE: Color = Color::rgb(0x26, 0x3A, 0xB1);
|
||||
|
||||
pub const BLD_COLOR_SUBMSG: Color = Color::rgb(0x80, 0x8B, 0xD1);
|
||||
pub const BLD_COLOR_INITIAL_INSTALL_SUCCESS: Color = Color::rgb(0x39, 0xA8, 0x14);
|
||||
pub const BLD_COLOR_INITIAL_INSTALL_BG: Color = Color::rgb(0xDE, 0xDE, 0xDE);
|
||||
|
||||
pub const BLD_BTN_MENU_COLOR: Color = Color::alpha(BLD_BG, alpha!(0.22));
|
||||
pub const BLD_BTN_MENU_COLOR_ACTIVE: Color = Color::alpha(BLD_BG, alpha!(0.11));
|
||||
@ -33,12 +32,11 @@ pub const BLD_BTN_MENUITEM_COLOR_ACTIVE: Color =
|
||||
Color::rgba(BLD_BG, 0xFF, 0xFF, 0xFF, alpha!(0.11));
|
||||
pub const BLD_TITLE_COLOR: Color = Color::rgba(BLD_BG, 0xFF, 0xFF, 0xFF, alpha!(0.75));
|
||||
|
||||
pub const WELCOME_COLOR: Color = BLACK;
|
||||
|
||||
// Commonly used corner radius (i.e. for buttons).
|
||||
pub const RADIUS: u8 = 2;
|
||||
|
||||
// Size of icons in the UI (i.e. inside buttons).
|
||||
pub const ICON_SIZE: i32 = 16;
|
||||
|
||||
// UI icons.
|
||||
pub const ICON_CANCEL: &[u8] = include_res!("model_tt/res/cancel.toif");
|
||||
pub const ICON_CONFIRM: &[u8] = include_res!("model_tt/res/confirm.toif");
|
||||
@ -244,8 +242,10 @@ pub fn button_bld_menu_item() -> ButtonStyleSheet {
|
||||
}
|
||||
}
|
||||
pub const TEXT_WELCOME: TextStyle =
|
||||
TextStyle::new(Font::NORMAL, GREY_MEDIUM, BG, GREY_MEDIUM, GREY_MEDIUM);
|
||||
pub const TEXT_WELCOME_BOLD: TextStyle = TextStyle::new(Font::BOLD, FG, BG, FG, FG);
|
||||
TextStyle::new(Font::NORMAL, GREY_MEDIUM, WELCOME_COLOR, GREY_MEDIUM, GREY_MEDIUM);
|
||||
pub const TEXT_WELCOME_BOLD: TextStyle = TextStyle::new(Font::BOLD, FG, WELCOME_COLOR, FG, FG);
|
||||
pub const TEXT_SUBMSG_INITIAL: TextStyle =
|
||||
TextStyle::new(Font::BOLD, GREY_MEDIUM, WELCOME_COLOR, GREY_MEDIUM, GREY_MEDIUM);
|
||||
|
||||
pub const TEXT_NORMAL: TextStyle = TextStyle::new(Font::NORMAL, BLD_FG, BLD_BG, BLD_FG, BLD_FG);
|
||||
pub const TEXT_BOLD: TextStyle = TextStyle::new(Font::BOLD, BLD_FG, BLD_BG, BLD_FG, BLD_FG);
|
||||
@ -256,5 +256,3 @@ pub const TEXT_SUBMSG: TextStyle = TextStyle::new(
|
||||
BLD_COLOR_SUBMSG,
|
||||
BLD_COLOR_SUBMSG,
|
||||
);
|
||||
pub const TEXT_SUBMSG_INITIAL: TextStyle =
|
||||
TextStyle::new(Font::BOLD, GREY_MEDIUM, BG, GREY_MEDIUM, GREY_MEDIUM);
|
||||
|
@ -1,7 +1,10 @@
|
||||
use crate::{
|
||||
alpha,
|
||||
ui::{
|
||||
component::{text::paragraphs::Paragraphs, Child, Component, Event, EventCtx, Never, Pad},
|
||||
component::{
|
||||
text::paragraphs::{ParagraphVecShort, Paragraphs},
|
||||
Child, Component, Event, EventCtx, Never, Pad,
|
||||
},
|
||||
constant::screen,
|
||||
display::{self, Color},
|
||||
geometry::{Offset, Point, Rect},
|
||||
@ -16,8 +19,8 @@ pub struct ResultScreen {
|
||||
fg_color: Color,
|
||||
bg_color: Color,
|
||||
icon: &'static [u8],
|
||||
message_top: Child<Paragraphs<&'static str>>,
|
||||
message_bottom: Child<Paragraphs<&'static str>>,
|
||||
message_top: Child<Paragraphs<ParagraphVecShort<&'static str>>>,
|
||||
message_bottom: Child<Paragraphs<ParagraphVecShort<&'static str>>>,
|
||||
}
|
||||
|
||||
impl ResultScreen {
|
||||
@ -25,8 +28,8 @@ impl ResultScreen {
|
||||
fg_color: Color,
|
||||
bg_color: Color,
|
||||
icon: &'static [u8],
|
||||
message_top: Paragraphs<&'static str>,
|
||||
message_bottom: Paragraphs<&'static str>,
|
||||
message_top: Paragraphs<ParagraphVecShort<&'static str>>,
|
||||
message_bottom: Paragraphs<ParagraphVecShort<&'static str>>,
|
||||
complete_draw: bool,
|
||||
) -> Self {
|
||||
let mut instance = Self {
|
||||
|
@ -1,10 +1,13 @@
|
||||
use crate::ui::{
|
||||
component::{text::paragraphs::Paragraphs, Component},
|
||||
component::{
|
||||
text::paragraphs::{Paragraph, ParagraphVecShort, Paragraphs, VecExt},
|
||||
Component,
|
||||
},
|
||||
geometry::LinearPlacement,
|
||||
model_tt::{
|
||||
component::ResultScreen,
|
||||
constant,
|
||||
theme::{ERROR_COLOR, ICON_WARN_SMALL, TEXT_ERROR_BOLD, TEXT_ERROR_NORMAL, WHITE},
|
||||
theme::{FATAL_ERROR_COLOR, ICON_WARN_SMALL, TEXT_ERROR_BOLD, TEXT_ERROR_NORMAL, WHITE},
|
||||
},
|
||||
util::from_c_str,
|
||||
};
|
||||
@ -12,32 +15,40 @@ use crate::ui::{
|
||||
#[no_mangle]
|
||||
extern "C" fn screen_fatal_error(msg: *const cty::c_char, file: *const cty::c_char) -> u32 {
|
||||
let m_top = if msg.is_null() {
|
||||
Paragraphs::new()
|
||||
.add(TEXT_ERROR_BOLD, "FATAL ERROR!")
|
||||
.centered()
|
||||
// .add(theme::TEXT_WIPE_NORMAL, unwrap!(unsafe { from_c_str(expr) }))
|
||||
// .centered()
|
||||
.add(TEXT_ERROR_NORMAL, unwrap!(unsafe { from_c_str(file) }))
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center())
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
|
||||
messages.add(Paragraph::new(&TEXT_ERROR_BOLD, "FATAL ERROR!").centered());
|
||||
// .add(theme::TEXT_WIPE_NORMAL, unwrap!(unsafe { from_c_str(expr) }))
|
||||
// .centered()
|
||||
messages.add(
|
||||
Paragraph::new(&TEXT_ERROR_NORMAL, unwrap!(unsafe { from_c_str(file) })).centered(),
|
||||
);
|
||||
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center())
|
||||
} else {
|
||||
let msg = unwrap!(unsafe { from_c_str(msg) });
|
||||
Paragraphs::new()
|
||||
.add(TEXT_ERROR_BOLD, "FATAL ERROR!")
|
||||
.centered()
|
||||
.add(TEXT_ERROR_NORMAL, msg)
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center())
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
|
||||
messages.add(Paragraph::new(&TEXT_ERROR_BOLD, "FATAL ERROR!").centered());
|
||||
messages.add(Paragraph::new(&TEXT_ERROR_NORMAL, msg).centered());
|
||||
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center())
|
||||
};
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
|
||||
let m_bottom = Paragraphs::new()
|
||||
.add(TEXT_ERROR_BOLD, "PLEASE CONTACT")
|
||||
.centered()
|
||||
.add(TEXT_ERROR_BOLD, "TREZOR SUPPORT")
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
messages.add(Paragraph::new(&TEXT_ERROR_BOLD, "PLEASE CONTACT").centered());
|
||||
messages.add(Paragraph::new(&TEXT_ERROR_BOLD, "TREZOR SUPPORT").centered());
|
||||
let m_bottom =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let mut frame = ResultScreen::new(WHITE, ERROR_COLOR, ICON_WARN_SMALL, m_top, m_bottom, true);
|
||||
let mut frame = ResultScreen::new(
|
||||
WHITE,
|
||||
FATAL_ERROR_COLOR,
|
||||
ICON_WARN_SMALL,
|
||||
m_top,
|
||||
m_bottom,
|
||||
true,
|
||||
);
|
||||
frame.place(constant::screen());
|
||||
frame.paint();
|
||||
0
|
||||
@ -48,28 +59,34 @@ extern "C" fn screen_error_shutdown(label: *const cty::c_char, msg: *const cty::
|
||||
let label = unwrap!(unsafe { from_c_str(label) });
|
||||
|
||||
let m_top = if msg.is_null() {
|
||||
Paragraphs::new()
|
||||
.add(TEXT_ERROR_BOLD, label)
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center())
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
|
||||
messages.add(Paragraph::new(&TEXT_ERROR_BOLD, label).centered());
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center())
|
||||
} else {
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
let msg = unwrap!(unsafe { from_c_str(msg) });
|
||||
Paragraphs::new()
|
||||
.add(TEXT_ERROR_BOLD, label)
|
||||
.centered()
|
||||
.add(TEXT_ERROR_NORMAL, msg)
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center())
|
||||
|
||||
messages.add(Paragraph::new(&TEXT_ERROR_BOLD, label).centered());
|
||||
messages.add(Paragraph::new(&TEXT_ERROR_NORMAL, msg).centered());
|
||||
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center())
|
||||
};
|
||||
let mut messages = ParagraphVecShort::new();
|
||||
|
||||
let m_bottom = Paragraphs::new()
|
||||
.add(TEXT_ERROR_BOLD, "PLEASE UNPLUG")
|
||||
.centered()
|
||||
.add(TEXT_ERROR_BOLD, "THE DEVICE")
|
||||
.centered()
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
messages.add(Paragraph::new(&TEXT_ERROR_BOLD, "PLEASE UNPLUG").centered());
|
||||
messages.add(Paragraph::new(&TEXT_ERROR_BOLD, "THE DEVICE").centered());
|
||||
let m_bottom =
|
||||
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let mut frame = ResultScreen::new(WHITE, ERROR_COLOR, ICON_WARN_SMALL, m_top, m_bottom, true);
|
||||
let mut frame = ResultScreen::new(
|
||||
WHITE,
|
||||
FATAL_ERROR_COLOR,
|
||||
ICON_WARN_SMALL,
|
||||
m_top,
|
||||
m_bottom,
|
||||
true,
|
||||
);
|
||||
frame.place(constant::screen());
|
||||
frame.paint();
|
||||
0
|
||||
|
@ -35,7 +35,7 @@ pub const GREY_LIGHT: Color = Color::rgb(0xA8, 0xA8, 0xA8); // greyish
|
||||
pub const GREY_MEDIUM: Color = Color::rgb(0x64, 0x64, 0x64);
|
||||
pub const GREY_DARK: Color = Color::rgb(0x33, 0x33, 0x33); // greyer
|
||||
|
||||
pub const ERROR_COLOR: Color = Color::rgb(0xAD, 0x2B, 0x2B);
|
||||
pub const FATAL_ERROR_COLOR: Color = Color::rgb(0xAD, 0x2B, 0x2B);
|
||||
|
||||
// Commonly used corner radius (i.e. for buttons).
|
||||
pub const RADIUS: u8 = 2;
|
||||
@ -396,9 +396,9 @@ pub const TEXT_DEMIBOLD: TextStyle = TextStyle::new(Font::DEMIBOLD, FG, BG, GREY
|
||||
pub const TEXT_BOLD: TextStyle = TextStyle::new(Font::BOLD, FG, BG, GREY_LIGHT, GREY_LIGHT);
|
||||
pub const TEXT_MONO: TextStyle = TextStyle::new(Font::MONO, FG, BG, GREY_LIGHT, GREY_LIGHT);
|
||||
pub const TEXT_ERROR_NORMAL: TextStyle =
|
||||
TextStyle::new(Font::NORMAL, FG, ERROR_COLOR, GREY_LIGHT, GREY_LIGHT);
|
||||
TextStyle::new(Font::NORMAL, FG, FATAL_ERROR_COLOR, GREY_LIGHT, GREY_LIGHT);
|
||||
pub const TEXT_ERROR_BOLD: TextStyle =
|
||||
TextStyle::new(Font::BOLD, FG, ERROR_COLOR, GREY_LIGHT, GREY_LIGHT);
|
||||
TextStyle::new(Font::BOLD, FG, FATAL_ERROR_COLOR, GREY_LIGHT, GREY_LIGHT);
|
||||
|
||||
pub const TEXT_NORMAL_OFF_WHITE: TextStyle =
|
||||
TextStyle::new(Font::NORMAL, OFF_WHITE, BG, GREY_LIGHT, GREY_LIGHT);
|
||||
|
Loading…
Reference in New Issue
Block a user