1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-26 00:18:15 +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'): if TREZOR_MODEL in ('1', 'R'):
FONT_NORMAL='Font_PixelOperator_Regular_8' FONT_NORMAL='Font_PixelOperator_Regular_8'
FONT_DEMIBOLD=None FONT_DEMIBOLD=None
FONT_BOLD=None FONT_BOLD='Font_PixelOperator_Bold_8'
FONT_MONO='Font_PixelOperatorMono_Regular_8' FONT_MONO='Font_PixelOperatorMono_Regular_8'
if TREZOR_MODEL in ('T', ): if TREZOR_MODEL in ('T', ):
FONT_NORMAL='Font_TTHoves_Regular_18' FONT_NORMAL='Font_TTHoves_Regular_18'

View File

@ -19,7 +19,7 @@ use crate::ui::{
text::paragraphs::{Paragraph, ParagraphVecShort, Paragraphs, VecExt}, text::paragraphs::{Paragraph, ParagraphVecShort, Paragraphs, VecExt},
Event, EventCtx, Event, EventCtx,
}, },
constant::{screen, BACKLIGHT_NORMAL, WIDTH}, constant::{screen, BACKLIGHT_NORMAL, HEIGHT, WIDTH},
display::{fade_backlight_duration, Color, TextOverlay}, display::{fade_backlight_duration, Color, TextOverlay},
event::ButtonEvent, event::ButtonEvent,
geometry::{LinearPlacement, Offset, Rect}, geometry::{LinearPlacement, Offset, Rect},
@ -31,6 +31,7 @@ use crate::ui::{
theme::{BLD_BG, BLD_FG, LOGO_EMPTY}, theme::{BLD_BG, BLD_FG, LOGO_EMPTY},
}, },
component::ResultScreen, component::ResultScreen,
theme::{ICON_BIN, ICON_FAIL, ICON_SUCCESS},
}, },
util::{from_c_array, from_c_str}, util::{from_c_array, from_c_str},
}; };
@ -186,19 +187,23 @@ fn screen_progress(
initialize: bool, initialize: bool,
fg_color: Color, fg_color: Color,
bg_color: Color, bg_color: Color,
_icon: Option<(&[u8], Color)>, icon: Option<(&[u8], Color)>,
) -> u32 { ) -> u32 {
if initialize { if initialize {
display::rect_fill(constant::screen(), bg_color); 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); let mut text = TextOverlay::new(text, Font::NORMAL);
text.place(loader_area.center() + Offset::y(Font::NORMAL.text_height() / 2)); text.place(loader_area.center() + Offset::y(Font::NORMAL.text_height() / 2));
let fill_to = (loader_area.width() as u32 * progress as u32) / 1000; 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( display::bar_with_text_and_fill(
loader_area, loader_area,
Some(&text), Some(&text),
@ -233,7 +238,7 @@ extern "C" fn screen_install_progress(
initialize, initialize,
BLD_FG, BLD_FG,
BLD_BG, 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", "WIPING DEVICE",
progress, progress,
initialize, initialize,
theme::BLD_FG, BLD_FG,
BLD_BG, 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] #[no_mangle]
extern "C" fn screen_wipe_success() -> u32 { extern "C" fn screen_wipe_success() -> u32 {
let mut messages = ParagraphVecShort::new(); let mut messages = ParagraphVecShort::new();
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Device wiped").centered()); messages.add(Paragraph::new(&theme::TEXT_BOLD, "Device wiped").centered());
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "successfully.").centered());
let m_top = let m_top =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
@ -279,7 +283,7 @@ extern "C" fn screen_wipe_success() -> u32 {
let m_bottom = let m_bottom =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); 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.place(SCREEN_ADJ);
frame.paint(); frame.paint();
0 0
@ -288,8 +292,7 @@ extern "C" fn screen_wipe_success() -> u32 {
#[no_mangle] #[no_mangle]
extern "C" fn screen_wipe_fail() -> u32 { extern "C" fn screen_wipe_fail() -> u32 {
let mut messages = ParagraphVecShort::new(); let mut messages = ParagraphVecShort::new();
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Device wipe was").centered()); messages.add(Paragraph::new(&theme::TEXT_BOLD, "Wipe failed").centered());
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "not successful.").centered());
let m_top = let m_top =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
@ -301,7 +304,7 @@ extern "C" fn screen_wipe_fail() -> u32 {
let m_bottom = let m_bottom =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); 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.place(SCREEN_ADJ);
frame.paint(); frame.paint();
0 0
@ -315,8 +318,7 @@ extern "C" fn screen_boot_empty(_firmware_present: bool) {
#[no_mangle] #[no_mangle]
extern "C" fn screen_install_fail() -> u32 { extern "C" fn screen_install_fail() -> u32 {
let mut messages = ParagraphVecShort::new(); let mut messages = ParagraphVecShort::new();
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Firmware installation was").centered()); messages.add(Paragraph::new(&theme::TEXT_BOLD, "Install failed").centered());
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "not successful.").centered());
let m_top = let m_top =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center());
@ -327,7 +329,7 @@ extern "C" fn screen_install_fail() -> u32 {
let m_bottom = let m_bottom =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); 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.place(SCREEN_ADJ);
frame.paint(); frame.paint();
0 0
@ -335,8 +337,7 @@ extern "C" fn screen_install_fail() -> u32 {
fn screen_install_success_bld(msg: &'static str, complete_draw: bool) -> u32 { fn screen_install_success_bld(msg: &'static str, complete_draw: bool) -> u32 {
let mut messages = ParagraphVecShort::new(); let mut messages = ParagraphVecShort::new();
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Firmware installed").centered()); messages.add(Paragraph::new(&theme::TEXT_BOLD, "Installed").centered());
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "successfully.").centered());
let m_top = let m_top =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); 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 = let m_bottom =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); 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.place(SCREEN_ADJ);
frame.paint(); frame.paint();
0 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 { fn screen_install_success_initial(msg: &'static str, complete_draw: bool) -> u32 {
let mut messages = ParagraphVecShort::new(); let mut messages = ParagraphVecShort::new();
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Firmware installed").centered()); messages.add(Paragraph::new(&theme::TEXT_BOLD, "Installed").centered());
messages.add(Paragraph::new(&theme::TEXT_NORMAL, "successfully.").centered());
let m_top = let m_top =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); 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 = let m_bottom =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); 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.place(SCREEN_ADJ);
frame.paint(); frame.paint();
0 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 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_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}, text::paragraphs::{ParagraphVecShort, Paragraphs},
Child, Component, Event, EventCtx, Never, Pad, Child, Component, Event, EventCtx, Never, Pad,
}, },
constant::{HEIGHT, WIDTH}, constant::{screen, HEIGHT, WIDTH},
display,
display::Color, display::Color,
geometry::{Point, Rect}, geometry::{Offset, Point, Rect},
}; };
pub struct ResultScreen { pub struct ResultScreen {
@ -13,6 +14,7 @@ pub struct ResultScreen {
small_pad: Pad, small_pad: Pad,
fg_color: Color, fg_color: Color,
bg_color: Color, bg_color: Color,
icon: &'static [u8],
message_top: Child<Paragraphs<ParagraphVecShort<&'static str>>>, message_top: Child<Paragraphs<ParagraphVecShort<&'static str>>>,
message_bottom: Child<Paragraphs<ParagraphVecShort<&'static str>>>, message_bottom: Child<Paragraphs<ParagraphVecShort<&'static str>>>,
} }
@ -21,6 +23,7 @@ impl ResultScreen {
pub fn new( pub fn new(
fg_color: Color, fg_color: Color,
bg_color: Color, bg_color: Color,
icon: &'static [u8],
message_top: Paragraphs<ParagraphVecShort<&'static str>>, message_top: Paragraphs<ParagraphVecShort<&'static str>>,
message_bottom: Paragraphs<ParagraphVecShort<&'static str>>, message_bottom: Paragraphs<ParagraphVecShort<&'static str>>,
complete_draw: bool, complete_draw: bool,
@ -30,6 +33,7 @@ impl ResultScreen {
small_pad: Pad::with_background(bg_color), small_pad: Pad::with_background(bg_color),
fg_color, fg_color,
bg_color, bg_color,
icon,
message_top: Child::new(message_top), message_top: Child::new(message_top),
message_bottom: Child::new(message_bottom), 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))); .place(Rect::new(Point::new(0, 0), Point::new(WIDTH, HEIGHT)));
self.message_top 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)); 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.bg.paint();
self.small_pad.paint(); self.small_pad.paint();
// display::icon( display::icon(
// Point::new(screen().center().x, 45), screen().center() + Offset::y(-24),
// self.icon, self.icon,
// self.fg_color, self.fg_color,
// self.bg_color, self.bg_color,
// ); );
// display::rect_fill(
// Rect::from_top_left_and_size(Point::new(12, 149), Offset::new(216, 1)),
// self.fg_color,
// );
self.message_top.paint(); self.message_top.paint();
self.message_bottom.paint(); self.message_bottom.paint();
} }

View File

@ -8,7 +8,7 @@ use crate::ui::{
model_tr::{ model_tr::{
component::ResultScreen, component::ResultScreen,
constant, constant,
theme::{TEXT_BOLD, TEXT_NORMAL}, theme::{ICON_FAIL, TEXT_BOLD, TEXT_NORMAL},
}, },
util::from_c_str, 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 = let m_bottom =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); 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.place(constant::screen());
frame.paint(); frame.paint();
0 0
@ -73,7 +80,14 @@ extern "C" fn screen_error_shutdown(label: *const cty::c_char, msg: *const cty::
let m_bottom = let m_bottom =
Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); 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.place(constant::screen());
frame.paint(); frame.paint();
0 0