diff --git a/core/embed/rust/src/ui/layout_eckhart/cshape/mod.rs b/core/embed/rust/src/ui/layout_eckhart/cshape/mod.rs index efd1a2503d..b7101f15b5 100644 --- a/core/embed/rust/src/ui/layout_eckhart/cshape/mod.rs +++ b/core/embed/rust/src/ui/layout_eckhart/cshape/mod.rs @@ -1,3 +1,5 @@ mod loader; +mod screen_border; pub use loader::{render_loader, LoaderRange}; +pub use screen_border::ScreenBorder; diff --git a/core/embed/rust/src/ui/layout_eckhart/cshape/screen_border.rs b/core/embed/rust/src/ui/layout_eckhart/cshape/screen_border.rs new file mode 100644 index 0000000000..910d258636 --- /dev/null +++ b/core/embed/rust/src/ui/layout_eckhart/cshape/screen_border.rs @@ -0,0 +1,86 @@ +use crate::ui::{ + display::Color, + geometry::{Alignment2D, Rect}, + shape::{self, Renderer}, +}; + +use super::super::{ + constant, + theme::{ICON_BORDER_BL, ICON_BORDER_BR, ICON_BORDER_TL, ICON_BORDER_TR}, +}; + +/// Custom shape for a full screen border overlay, parameterizable by color. +pub struct ScreenBorder { + color: Color, + side_bars: [Rect; 4], +} + +impl ScreenBorder { + pub fn new(color: Color) -> Self { + let screen = constant::screen(); + + // Top bar: from the right edge of top-left icon to the left edge of top-right icon. + let top_bar_rect = Rect { + x0: screen.x0 + ICON_BORDER_TL.toif.width(), + y0: screen.y0, + x1: screen.x1 - ICON_BORDER_TR.toif.width(), + y1: screen.y0 + 2, + }; + + // Bottom bar: from the right edge of bottom-left icon to the left edge of bottom-right icon. + let bottom_bar_rect = Rect { + x0: screen.x0 + ICON_BORDER_BL.toif.width(), + y0: screen.y1 - 2, + x1: screen.x1 - ICON_BORDER_BR.toif.width(), + y1: screen.y1, + }; + + // Left bar: from the bottom edge of top-left icon to the top edge of bottom-left icon. + let left_bar_rect = Rect { + x0: screen.x0, + y0: screen.y0 + ICON_BORDER_TL.toif.height() - 1, + x1: screen.x0 + 2, + y1: screen.y1 - ICON_BORDER_BL.toif.height(), + }; + // Right bar: from the bottom edge of top-right icon to the top edge of bottom-right icon. + let right_bar_rect = Rect { + x0: screen.x1 - 2, + y0: screen.y0 + ICON_BORDER_TR.toif.height() - 1, + x1: screen.x1, + y1: screen.y1 - ICON_BORDER_BR.toif.height(), + }; + Self { + color, + side_bars: [bottom_bar_rect, left_bar_rect, right_bar_rect, top_bar_rect], + } + } + + pub fn render<'s>(&'s self, target: &mut impl Renderer<'s>) { + let screen = constant::screen(); + + // Draw the four side bars. + for bar in self.side_bars { + shape::Bar::new(bar) + .with_fg(self.color) + .with_thickness(2) + .render(target); + } + // Draw the four corners. + shape::ToifImage::new(screen.bottom_left(), ICON_BORDER_BL.toif) + .with_fg(self.color) + .with_align(Alignment2D::BOTTOM_LEFT) + .render(target); + shape::ToifImage::new(screen.top_right(), ICON_BORDER_TR.toif) + .with_fg(self.color) + .with_align(Alignment2D::TOP_RIGHT) + .render(target); + shape::ToifImage::new(screen.top_left(), ICON_BORDER_TL.toif) + .with_fg(self.color) + .with_align(Alignment2D::TOP_LEFT) + .render(target); + shape::ToifImage::new(screen.bottom_right(), ICON_BORDER_BR.toif) + .with_fg(self.color) + .with_align(Alignment2D::BOTTOM_RIGHT) + .render(target); + } +} diff --git a/core/embed/rust/src/ui/layout_eckhart/res/border/BL.png b/core/embed/rust/src/ui/layout_eckhart/res/border/BL.png new file mode 100644 index 0000000000..fd2a7f2da9 Binary files /dev/null and b/core/embed/rust/src/ui/layout_eckhart/res/border/BL.png differ diff --git a/core/embed/rust/src/ui/layout_eckhart/res/border/BL.toif b/core/embed/rust/src/ui/layout_eckhart/res/border/BL.toif new file mode 100644 index 0000000000..6fdc72a94f Binary files /dev/null and b/core/embed/rust/src/ui/layout_eckhart/res/border/BL.toif differ diff --git a/core/embed/rust/src/ui/layout_eckhart/res/border/BR.png b/core/embed/rust/src/ui/layout_eckhart/res/border/BR.png new file mode 100644 index 0000000000..59d94fbb4b Binary files /dev/null and b/core/embed/rust/src/ui/layout_eckhart/res/border/BR.png differ diff --git a/core/embed/rust/src/ui/layout_eckhart/res/border/BR.toif b/core/embed/rust/src/ui/layout_eckhart/res/border/BR.toif new file mode 100644 index 0000000000..a601627196 Binary files /dev/null and b/core/embed/rust/src/ui/layout_eckhart/res/border/BR.toif differ diff --git a/core/embed/rust/src/ui/layout_eckhart/res/border/TL.png b/core/embed/rust/src/ui/layout_eckhart/res/border/TL.png new file mode 100644 index 0000000000..bba7695132 Binary files /dev/null and b/core/embed/rust/src/ui/layout_eckhart/res/border/TL.png differ diff --git a/core/embed/rust/src/ui/layout_eckhart/res/border/TL.toif b/core/embed/rust/src/ui/layout_eckhart/res/border/TL.toif new file mode 100644 index 0000000000..c3e30c64d0 Binary files /dev/null and b/core/embed/rust/src/ui/layout_eckhart/res/border/TL.toif differ diff --git a/core/embed/rust/src/ui/layout_eckhart/res/border/TR.png b/core/embed/rust/src/ui/layout_eckhart/res/border/TR.png new file mode 100644 index 0000000000..bcaf8f5c59 Binary files /dev/null and b/core/embed/rust/src/ui/layout_eckhart/res/border/TR.png differ diff --git a/core/embed/rust/src/ui/layout_eckhart/res/border/TR.toif b/core/embed/rust/src/ui/layout_eckhart/res/border/TR.toif new file mode 100644 index 0000000000..9fe8c1ec89 Binary files /dev/null and b/core/embed/rust/src/ui/layout_eckhart/res/border/TR.toif differ 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 407a0bda13..4da7dd0716 100644 --- a/core/embed/rust/src/ui/layout_eckhart/theme/mod.rs +++ b/core/embed/rust/src/ui/layout_eckhart/theme/mod.rs @@ -86,6 +86,12 @@ include_icon!(ICON_WARNING40, "layout_eckhart/res/warning40.toif"); include_icon!(ICON_BATTERY_BAR, "layout_eckhart/res/battery_bar.toif"); include_icon!(ICON_BATTERY_ZAP, "layout_eckhart/res/battery_zap.toif"); +// Border overlay icons for bootloader screens and hold to confirm animation +include_icon!(ICON_BORDER_BL, "layout_eckhart/res/border/BL.toif"); +include_icon!(ICON_BORDER_BR, "layout_eckhart/res/border/BR.toif"); +include_icon!(ICON_BORDER_TL, "layout_eckhart/res/border/TL.toif"); +include_icon!(ICON_BORDER_TR, "layout_eckhart/res/border/TR.toif"); + // Text styles /// Alias for use with copied code, might be deleted later pub const TEXT_NORMAL: TextStyle = TEXT_MEDIUM;