1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-23 06:58:13 +00:00

WIP - fix header in Flow pages

This commit is contained in:
grdddj 2022-11-05 19:00:09 +01:00
parent 83bbb230a5
commit d679ce0a2b

View File

@ -25,6 +25,7 @@ pub struct Flow<F, const M: usize> {
current_page: Page<M>, current_page: Page<M>,
common_title: Option<StrBuffer>, common_title: Option<StrBuffer>,
content_area: Rect, content_area: Rect,
title_area: Rect,
pad: Pad, pad: Pad,
buttons: Child<ButtonController<&'static str>>, buttons: Child<ButtonController<&'static str>>,
page_counter: u8, page_counter: u8,
@ -41,6 +42,7 @@ where
current_page, current_page,
common_title: None, common_title: None,
content_area: Rect::zero(), content_area: Rect::zero(),
title_area: Rect::zero(),
pad: Pad::with_background(theme::BG), pad: Pad::with_background(theme::BG),
// Setting empty layout for now, we do not yet know how many sub-pages the first page // Setting empty layout for now, we do not yet know how many sub-pages the first page
// has. Initial button layout will be set in `place()` after we can call // has. Initial button layout will be set in `place()` after we can call
@ -142,13 +144,12 @@ where
fn place(&mut self, bounds: Rect) -> Rect { fn place(&mut self, bounds: Rect) -> Rect {
let (title_content_area, button_area) = bounds.split_bottom(theme::BUTTON_HEIGHT); let (title_content_area, button_area) = bounds.split_bottom(theme::BUTTON_HEIGHT);
// Accounting for possible title // Accounting for possible title
let content_area = if self.common_title.is_some() { let (title_area, content_area) = if self.common_title.is_some() {
title_content_area title_content_area.split_top(theme::FONT_HEADER.line_height())
.split_top(theme::FONT_HEADER.line_height())
.1
} else { } else {
title_content_area (Rect::zero(), title_content_area)
}; };
self.title_area = title_area;
self.content_area = content_area; self.content_area = content_area;
// We finally found how long is the first page, and can set its button layout. // We finally found how long is the first page, and can set its button layout.
@ -207,7 +208,7 @@ where
// (not compatible with longer/centered titles) // (not compatible with longer/centered titles)
self.pad.paint(); self.pad.paint();
if let Some(title) = &self.common_title { if let Some(title) = &self.common_title {
common::paint_header_centered(title, self.content_area); common::paint_header_centered(title, self.title_area);
} }
self.current_page.paint(); self.current_page.paint();
self.buttons.paint(); self.buttons.paint();