1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 05:28:40 +00:00
This commit is contained in:
tychovrahe 2022-11-10 22:36:09 +01:00
parent 948190fd40
commit 32e5326cb2
5 changed files with 67 additions and 69 deletions

View File

@ -26,7 +26,7 @@ SOURCE_MOD = []
if TREZOR_MODEL in ('1', 'R'):
FONT_NORMAL='Font_PixelOperator_Regular_8'
FONT_DEMIBOLD=None
FONT_BOLD=None
FONT_BOLD='Font_PixelOperator_Bold_8'
FONT_MONO='Font_PixelOperatorMono_Regular_8'
if TREZOR_MODEL in ('T', ):
FONT_NORMAL='Font_TTHoves_Regular_18'

View File

@ -19,7 +19,7 @@ use crate::ui::{
text::paragraphs::{Paragraph, ParagraphVecShort, Paragraphs, VecExt},
Event, EventCtx,
},
constant::{screen, BACKLIGHT_NORMAL, WIDTH},
constant::{screen, BACKLIGHT_NORMAL, HEIGHT, WIDTH},
display::{fade_backlight_duration, Color, TextOverlay},
event::ButtonEvent,
geometry::{LinearPlacement, Offset, Rect},
@ -31,6 +31,7 @@ use crate::ui::{
theme::{BLD_BG, BLD_FG, LOGO_EMPTY},
},
component::ResultScreen,
theme::{ICON_BIN, ICON_FAIL, ICON_SUCCESS},
},
util::{from_c_array, from_c_str},
};
@ -186,19 +187,23 @@ fn screen_progress(
initialize: bool,
fg_color: Color,
bg_color: Color,
_icon: Option<(&[u8], Color)>,
icon: Option<(&[u8], Color)>,
) -> u32 {
if initialize {
display::rect_fill(constant::screen(), bg_color);
}
let loader_area = Rect::new(Point::new(5, 24), Point::new(WIDTH - 5, 24 + 16));
let loader_area = Rect::new(Point::new(5, HEIGHT - 16), Point::new(WIDTH - 5, HEIGHT));
let mut text = TextOverlay::new(text, Font::NORMAL);
text.place(loader_area.center() + Offset::y(Font::NORMAL.text_height() / 2));
let fill_to = (loader_area.width() as u32 * progress as u32) / 1000;
if let Some(icon) = icon {
display::icon(screen().center(), icon.0, icon.1, BLD_BG);
}
display::bar_with_text_and_fill(
loader_area,
Some(&text),
@ -233,7 +238,7 @@ extern "C" fn screen_install_progress(
initialize,
BLD_FG,
BLD_BG,
None, //Some((theme::RECEIVE, fg_color)),
Some((ICON_BIN.0, BLD_FG)),
)
}
@ -243,9 +248,9 @@ extern "C" fn screen_wipe_progress(progress: u16, initialize: bool) -> u32 {
"WIPING DEVICE",
progress,
initialize,
theme::BLD_FG,
BLD_FG,
BLD_BG,
None, //Some((theme::ERASE_BIG, theme::BLD_FG)),
Some((ICON_BIN.0, BLD_FG)),
)
}
@ -266,8 +271,7 @@ extern "C" fn screen_connect() -> u32 {
#[no_mangle]
extern "C" fn screen_wipe_success() -> u32 {
let mut messages = ParagraphVecShort::new();
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Device wiped").centered());
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "successfully.").centered());
messages.add(Paragraph::new(&theme::TEXT_BOLD, "Device wiped").centered());
let m_top =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
@ -279,7 +283,7 @@ extern "C" fn screen_wipe_success() -> u32 {
let m_bottom =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, m_top, m_bottom, true);
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_SUCCESS.0, m_top, m_bottom, true);
frame.place(SCREEN_ADJ);
frame.paint();
0
@ -288,8 +292,7 @@ extern "C" fn screen_wipe_success() -> u32 {
#[no_mangle]
extern "C" fn screen_wipe_fail() -> u32 {
let mut messages = ParagraphVecShort::new();
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Device wipe was").centered());
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "not successful.").centered());
messages.add(Paragraph::new(&theme::TEXT_BOLD, "Wipe failed").centered());
let m_top =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
@ -301,7 +304,7 @@ extern "C" fn screen_wipe_fail() -> u32 {
let m_bottom =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, m_top, m_bottom, true);
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_FAIL.0, m_top, m_bottom, true);
frame.place(SCREEN_ADJ);
frame.paint();
0
@ -315,8 +318,7 @@ extern "C" fn screen_boot_empty(_firmware_present: bool) {
#[no_mangle]
extern "C" fn screen_install_fail() -> u32 {
let mut messages = ParagraphVecShort::new();
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Firmware installation was").centered());
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "not successful.").centered());
messages.add(Paragraph::new(&theme::TEXT_BOLD, "Install failed").centered());
let m_top =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
@ -327,7 +329,7 @@ extern "C" fn screen_install_fail() -> u32 {
let m_bottom =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, m_top, m_bottom, true);
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_FAIL.0, m_top, m_bottom, true);
frame.place(SCREEN_ADJ);
frame.paint();
0
@ -335,8 +337,7 @@ extern "C" fn screen_install_fail() -> u32 {
fn screen_install_success_bld(msg: &'static str, complete_draw: bool) -> u32 {
let mut messages = ParagraphVecShort::new();
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Firmware installed").centered());
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "successfully.").centered());
messages.add(Paragraph::new(&theme::TEXT_BOLD, "Installed").centered());
let m_top =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
@ -347,7 +348,14 @@ fn screen_install_success_bld(msg: &'static str, complete_draw: bool) -> u32 {
let m_bottom =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, m_top, m_bottom, complete_draw);
let mut frame = ResultScreen::new(
BLD_FG,
BLD_BG,
ICON_SUCCESS.0,
m_top,
m_bottom,
complete_draw,
);
frame.place(SCREEN_ADJ);
frame.paint();
0
@ -355,8 +363,7 @@ 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 mut messages = ParagraphVecShort::new();
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Firmware installed").centered());
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "successfully.").centered());
messages.add(Paragraph::new(&theme::TEXT_BOLD, "Installed").centered());
let m_top =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
@ -367,7 +374,14 @@ fn screen_install_success_initial(msg: &'static str, complete_draw: bool) -> u32
let m_bottom =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, m_top, m_bottom, complete_draw);
let mut frame = ResultScreen::new(
BLD_FG,
BLD_BG,
ICON_SUCCESS.0,
m_top,
m_bottom,
complete_draw,
);
frame.place(SCREEN_ADJ);
frame.paint();
0

View File

@ -16,35 +16,5 @@ pub const ICON_SIZE: i32 = 16;
pub const LOGO_EMPTY: &[u8] = include_res!("model_tr/res/trezor_empty.toif");
// pub fn bld_button_default() -> ButtonStyleSheet {
// ButtonStyleSheet {
// 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 {
// ButtonStyleSheet {
// 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_BOLD: 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);

View File

@ -3,9 +3,10 @@ use crate::ui::{
text::paragraphs::{ParagraphVecShort, Paragraphs},
Child, Component, Event, EventCtx, Never, Pad,
},
constant::{HEIGHT, WIDTH},
constant::{screen, HEIGHT, WIDTH},
display,
display::Color,
geometry::{Point, Rect},
geometry::{Offset, Point, Rect},
};
pub struct ResultScreen {
@ -13,6 +14,7 @@ pub struct ResultScreen {
small_pad: Pad,
fg_color: Color,
bg_color: Color,
icon: &'static [u8],
message_top: Child<Paragraphs<ParagraphVecShort<&'static str>>>,
message_bottom: Child<Paragraphs<ParagraphVecShort<&'static str>>>,
}
@ -21,6 +23,7 @@ impl ResultScreen {
pub fn new(
fg_color: Color,
bg_color: Color,
icon: &'static [u8],
message_top: Paragraphs<ParagraphVecShort<&'static str>>,
message_bottom: Paragraphs<ParagraphVecShort<&'static str>>,
complete_draw: bool,
@ -30,6 +33,7 @@ impl ResultScreen {
small_pad: Pad::with_background(bg_color),
fg_color,
bg_color,
icon,
message_top: Child::new(message_top),
message_bottom: Child::new(message_bottom),
};
@ -51,7 +55,7 @@ impl Component for ResultScreen {
.place(Rect::new(Point::new(0, 0), Point::new(WIDTH, HEIGHT)));
self.message_top
.place(Rect::new(Point::new(0, 0), Point::new(WIDTH, 30)));
.place(Rect::new(Point::new(0, 26), Point::new(WIDTH, 40)));
let bottom_area = Rect::new(Point::new(0, 40), Point::new(WIDTH, HEIGHT));
@ -69,16 +73,12 @@ impl Component for ResultScreen {
self.bg.paint();
self.small_pad.paint();
// display::icon(
// Point::new(screen().center().x, 45),
// self.icon,
// self.fg_color,
// self.bg_color,
// );
// display::rect_fill(
// Rect::from_top_left_and_size(Point::new(12, 149), Offset::new(216, 1)),
// self.fg_color,
// );
display::icon(
screen().center() + Offset::y(-24),
self.icon,
self.fg_color,
self.bg_color,
);
self.message_top.paint();
self.message_bottom.paint();
}

View File

@ -8,7 +8,7 @@ use crate::ui::{
model_tr::{
component::ResultScreen,
constant,
theme::{TEXT_BOLD, TEXT_NORMAL},
theme::{ICON_FAIL, TEXT_BOLD, TEXT_NORMAL},
},
util::from_c_str,
};
@ -41,7 +41,14 @@ extern "C" fn screen_fatal_error(msg: *const cty::c_char, file: *const cty::c_ch
let m_bottom =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
let mut frame = ResultScreen::new(Color::white(), Color::black(), m_top, m_bottom, true);
let mut frame = ResultScreen::new(
Color::white(),
Color::black(),
ICON_FAIL.0,
m_top,
m_bottom,
true,
);
frame.place(constant::screen());
frame.paint();
0
@ -73,7 +80,14 @@ extern "C" fn screen_error_shutdown(label: *const cty::c_char, msg: *const cty::
let m_bottom =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
let mut frame = ResultScreen::new(Color::white(), Color::black(), m_top, m_bottom, true);
let mut frame = ResultScreen::new(
Color::white(),
Color::black(),
ICON_FAIL.0,
m_top,
m_bottom,
true,
);
frame.place(constant::screen());
frame.paint();
0