1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-28 23:32:05 +00:00

chore(eckhart): Add dynamic padding option to vertical menu. Update rendering of separarators in vertical menu.

This commit is contained in:
Lukas Bielesch 2025-02-17 22:44:40 +01:00 committed by obrusvit
parent 38447e0ce1
commit 7109b8c971

View File

@ -1,15 +1,16 @@
use crate::ui::{ use crate::ui::{
component::{Component, Event, EventCtx}, component::{Component, Event, EventCtx},
geometry::{Insets, Offset, Rect}, geometry::{Insets, Offset, Rect},
layout_eckhart::{
component::{Button, ButtonMsg},
theme,
},
shape::{Bar, Renderer}, shape::{Bar, Renderer},
}; };
use heapless::Vec; use heapless::Vec;
use super::super::{
component::{Button, ButtonMsg},
theme,
};
/// Number of buttons. /// Number of buttons.
/// Presently, VerticalMenu holds only fixed number of buttons. /// Presently, VerticalMenu holds only fixed number of buttons.
pub const MENU_MAX_ITEMS: usize = 5; pub const MENU_MAX_ITEMS: usize = 5;
@ -39,7 +40,7 @@ pub enum VerticalMenuMsg {
} }
impl VerticalMenu { impl VerticalMenu {
const SIDE_INSET: i16 = 12; const SIDE_INSETS: Insets = Insets::sides(12);
const DEFAULT_PADDING: i16 = 28; const DEFAULT_PADDING: i16 = 28;
const MIN_PADDING: i16 = 2; const MIN_PADDING: i16 = 2;
@ -138,8 +139,8 @@ impl VerticalMenu {
button button
.area() .area()
.top_left() .top_left()
.ofs(Offset::x(Button::BASELINE_OFFSET.x).into()), .ofs(Offset::x(button.content_offset().x).into()),
Offset::new(button.area().width() - 2 * Button::BASELINE_OFFSET.x, 1), Offset::new(button.area().width() - 2 * button.content_offset().x, 1),
); );
Bar::new(separator) Bar::new(separator)
.with_fg(theme::GREY_EXTRA_DARK) .with_fg(theme::GREY_EXTRA_DARK)
@ -154,7 +155,7 @@ impl Component for VerticalMenu {
fn place(&mut self, bounds: Rect) -> Rect { fn place(&mut self, bounds: Rect) -> Rect {
// Crop the menu area // Crop the menu area
self.bounds = bounds.inset(Insets::sides(Self::SIDE_INSET)); self.bounds = bounds.inset(Self::SIDE_INSETS);
// Determine padding dynamically if `fit_area` is enabled // Determine padding dynamically if `fit_area` is enabled
let padding = if self.fit_area { let padding = if self.fit_area {