diff --git a/core/embed/rust/src/ui/geometry.rs b/core/embed/rust/src/ui/geometry.rs index f753e02170..46976b9191 100644 --- a/core/embed/rust/src/ui/geometry.rs +++ b/core/embed/rust/src/ui/geometry.rs @@ -679,6 +679,10 @@ impl Grid { let to = self.row_col(cells.to.0, cells.to.1); from.union(to) } + + pub const fn cell_count(&self) -> usize { + self.rows * self.cols + } } #[derive(Copy, Clone)] diff --git a/core/embed/rust/src/ui/layout_eckhart/firmware/homescreen.rs b/core/embed/rust/src/ui/layout_eckhart/firmware/homescreen.rs index 3e361f7b87..5ea4250e16 100644 --- a/core/embed/rust/src/ui/layout_eckhart/firmware/homescreen.rs +++ b/core/embed/rust/src/ui/layout_eckhart/firmware/homescreen.rs @@ -6,7 +6,7 @@ use crate::{ ui::{ component::{text::TextStyle, Component, Event, EventCtx, Label, Never}, display::{image::ImageInfo, Color}, - geometry::{Alignment2D, Grid, Insets, Offset, Point, Rect}, + geometry::{Alignment2D, Insets, Offset, Point, Rect}, layout::util::get_user_custom_image, lerp::Lerp, shape::{self, Renderer}, @@ -20,7 +20,7 @@ use super::{ fonts, }, constant::{HEIGHT, SCREEN, WIDTH}, - theme::{self, firmware::button_homebar_style, BG, BLACK, GREY_EXTRA_DARK}, + theme::{self, firmware::button_homebar_style, TILES_GRID}, ActionBar, ActionBarMsg, Hint, HoldToConfirmAnim, }; @@ -235,10 +235,10 @@ impl HomeLabel { const LABEL_TEXT_STYLE: TextStyle = theme::firmware::TEXT_BIG; const LABEL_SHADOW_TEXT_STYLE: TextStyle = TextStyle::new( fonts::FONT_SATOSHI_EXTRALIGHT_46, - BLACK, - BLACK, - BLACK, - BLACK, + theme::BLACK, + theme::BLACK, + theme::BLACK, + theme::BLACK, ); fn new(label: TString<'static>) -> Self { @@ -282,26 +282,9 @@ pub fn check_homescreen_format(image: BinaryData) -> bool { } fn render_default_hs<'a>(target: &mut impl Renderer<'a>, led_color: Option) { - const DEFAULT_HS_TILE_ROWS: usize = 4; - const DEFAULT_HS_TILE_COLS: usize = 4; - const DEFAULT_HS_AREA: Rect = SCREEN.inset(Insets::bottom(140)); - const DEFAULT_HS_GRID: Grid = - Grid::new(DEFAULT_HS_AREA, DEFAULT_HS_TILE_ROWS, DEFAULT_HS_TILE_COLS); - const DEFAULT_HS_TILES_2: [(usize, usize); 9] = [ - (0, 0), - (1, 0), - (1, 3), - (2, 3), - (3, 2), - (3, 3), - (4, 0), - (4, 2), - (4, 3), - ]; - // Layer 1: Base Solid Colour shape::Bar::new(SCREEN) - .with_bg(GREY_EXTRA_DARK) + .with_bg(theme::GREY_EXTRA_DARK) .render(target); // Layer 2: Base Gradient overlay @@ -309,7 +292,7 @@ fn render_default_hs<'a>(target: &mut impl Renderer<'a>, led_color: Option(target: &mut impl Renderer<'a>, led_color: Option(color: Color, target: &mut impl Renderer<'a>) { // edges) let dist_from_mid = (x - X_MID).abs() as f32 / X_HALF_WIDTH; shape::Bar::new(slice) - .with_bg(BG) + .with_bg(theme::BG) .with_alpha(u8::lerp(u8::MIN, u8::MAX, dist_from_mid)) .render(target); } diff --git a/core/embed/rust/src/ui/layout_eckhart/theme/mod.rs b/core/embed/rust/src/ui/layout_eckhart/theme/mod.rs index fb1cc1ea8a..ef5ca33c83 100644 --- a/core/embed/rust/src/ui/layout_eckhart/theme/mod.rs +++ b/core/embed/rust/src/ui/layout_eckhart/theme/mod.rs @@ -6,7 +6,12 @@ pub mod firmware; #[cfg(feature = "micropython")] pub use firmware::*; -use crate::ui::{component::text::TextStyle, display::Color, geometry::Insets, util::include_icon}; +use crate::ui::{ + component::text::TextStyle, + display::Color, + geometry::{Grid, Insets, Offset, Rect}, + util::include_icon, +}; use super::{ component::{ButtonStyle, ButtonStyleSheet}, @@ -51,6 +56,18 @@ pub const SIDE_INSETS: Insets = Insets::sides(PADDING); pub const ACTION_BAR_HEIGHT: i16 = 90; // [px] pub const TEXT_VERTICAL_SPACING: i16 = 24; // [px] +// Tile pattern grid constants +const TILE_SIZE: i16 = ICON_TILE_STRIPES_BACKSLASH.toif.width(); +const TILES_ROWS: i16 = 6; +const TILES_COLS: i16 = 4; +// Slightly larger than SCREEN because the bottom row is not full +const TILES_AREA: Rect = + Rect::from_size(Offset::new(TILES_COLS * TILE_SIZE, TILES_ROWS * TILE_SIZE)); +/// Grid for the tiles pattern used in default homescreen and progress screen. +pub const TILES_GRID: Grid = Grid::new(TILES_AREA, TILES_ROWS as usize, TILES_COLS as usize); +/// Indices of the tiles that are slashes ("///") in the default pattern. +pub const TILES_SLASH_INDICES: [usize; 12] = [0, 4, 7, 11, 14, 15, 16, 18, 19, 20, 22, 23]; + // UI icons (white color). include_icon!(ICON_CHEVRON_DOWN, "layout_eckhart/res/chevron_down.toif"); include_icon!( @@ -111,13 +128,13 @@ include_icon!(ICON_BORDER_TR, "layout_eckhart/res/border/TR.toif"); include_icon!(ICON_PLUS, "layout_eckhart/res/plus.toif"); include_icon!(ICON_MINUS, "layout_eckhart/res/minus.toif"); -// Icon tiles for default homescreen +// Icon tiles for default pattern include_icon!( - ICON_HS_TILE_1, + ICON_TILE_STRIPES_BACKSLASH, // for "\\\" "layout_eckhart/res/defaut_homescreen/hs_tile1.toif" ); include_icon!( - ICON_HS_TILE_2, + ICON_TILE_STRIPES_SLASH, // for "///" "layout_eckhart/res/defaut_homescreen/hs_tile2.toif" );