From bed8ceaa02398b5a3b7d24160405af181789c7db Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Tue, 25 Oct 2022 15:45:37 +0200 Subject: [PATCH] fixup! feat(core/rust): bootloader implementation in rust --- .../rust/src/ui/component/text/paragraphs.rs | 20 +++++++++++++++++-- .../rust/src/ui/model_tt/bootloader/mod.rs | 10 +++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/core/embed/rust/src/ui/component/text/paragraphs.rs b/core/embed/rust/src/ui/component/text/paragraphs.rs index e8f1cd243d..e7c98e688e 100644 --- a/core/embed/rust/src/ui/component/text/paragraphs.rs +++ b/core/embed/rust/src/ui/component/text/paragraphs.rs @@ -264,6 +264,8 @@ pub struct Paragraph { /// Try to keep this and the next paragraph on the same page. NOTE: doesn't /// work if two or more subsequent paragraphs have this flag. no_break: bool, + padding_top: i16, + padding_bottom: i16, } impl Paragraph { @@ -274,6 +276,8 @@ impl Paragraph { align: Alignment::Start, break_after: false, no_break: false, + padding_top: PARAGRAPH_TOP_SPACE, + padding_bottom: PARAGRAPH_BOTTOM_SPACE, } } @@ -292,6 +296,16 @@ impl Paragraph { self } + pub const fn with_top_padding(mut self, padding: i16) -> Self { + self.padding_top = padding; + self + } + + pub const fn with_bottom_padding(mut self, padding: i16) -> Self { + self.padding_bottom = padding; + self + } + pub fn update(&mut self, content: T) { self.content = content } @@ -306,13 +320,15 @@ impl Paragraph { align: self.align, break_after: self.break_after, no_break: self.no_break, + padding_top: self.padding_top, + padding_bottom: self.padding_bottom, } } fn layout(&self, area: Rect) -> TextLayout { TextLayout { - padding_top: PARAGRAPH_TOP_SPACE, - padding_bottom: PARAGRAPH_BOTTOM_SPACE, + padding_top: self.padding_top, + padding_bottom: self.padding_bottom, ..TextLayout::new(*self.style) .with_align(self.align) .with_bounds(area) diff --git a/core/embed/rust/src/ui/model_tt/bootloader/mod.rs b/core/embed/rust/src/ui/model_tt/bootloader/mod.rs index 0e68a00fc3..872f6bd8b0 100644 --- a/core/embed/rust/src/ui/model_tt/bootloader/mod.rs +++ b/core/embed/rust/src/ui/model_tt/bootloader/mod.rs @@ -427,14 +427,18 @@ extern "C" fn screen_install_success( #[no_mangle] extern "C" fn screen_welcome() -> u32 { - let mut messages = ParagraphVecShort::new(); display::rect_fill(screen(), WELCOME_COLOR); + + let mut messages = ParagraphVecShort::new(); 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()); + messages.add( + Paragraph::new(&theme::TEXT_WELCOME_BOLD, "trezor.io/start") + .centered() + .with_top_padding(2), + ); let mut frame = Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); - frame.place(constant::screen()); frame.paint(); 0