From 7c11dec7f658214f8b12fdaa4f14b32d875a4853 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Fri, 9 Sep 2022 13:52:46 +0200 Subject: [PATCH] refactor(core/rust/ui): Font as repr(u8) enum [no changelog] --- core/embed/rust/src/ui/display.rs | 34 ++++--- .../rust/src/ui/model_t1/component/dialog.rs | 8 +- .../rust/src/ui/model_t1/component/frame.rs | 6 +- .../rust/src/ui/model_t1/component/page.rs | 4 +- core/embed/rust/src/ui/model_t1/theme.rs | 30 +++---- .../rust/src/ui/model_tr/component/dialog.rs | 8 +- .../rust/src/ui/model_tr/component/frame.rs | 6 +- .../rust/src/ui/model_tr/component/page.rs | 4 +- .../src/ui/model_tr/component/result_popup.rs | 5 +- core/embed/rust/src/ui/model_tr/theme.rs | 32 +++---- .../rust/src/ui/model_tt/component/frame.rs | 6 +- .../src/ui/model_tt/component/keyboard/pin.rs | 11 ++- .../src/ui/model_tt/component/number_input.rs | 4 +- core/embed/rust/src/ui/model_tt/theme.rs | 88 +++++++++---------- 14 files changed, 117 insertions(+), 129 deletions(-) diff --git a/core/embed/rust/src/ui/display.rs b/core/embed/rust/src/ui/display.rs index 8caa3d6821..f8cf364017 100644 --- a/core/embed/rust/src/ui/display.rs +++ b/core/embed/rust/src/ui/display.rs @@ -526,7 +526,7 @@ pub fn text(baseline: Point, text: &str, font: Font, fg_color: Color, bg_color: baseline.x, baseline.y, text, - font.0, + font.into(), fg_color.into(), bg_color.into(), ); @@ -538,7 +538,7 @@ pub fn text_center(baseline: Point, text: &str, font: Font, fg_color: Color, bg_ baseline.x - w / 2, baseline.y, text, - font.0, + font.into(), fg_color.into(), bg_color.into(), ); @@ -550,7 +550,7 @@ pub fn text_right(baseline: Point, text: &str, font: Font, fg_color: Color, bg_c baseline.x - w, baseline.y, text, - font.0, + font.into(), fg_color.into(), bg_color.into(), ); @@ -687,24 +687,34 @@ impl Glyph { } } +/// Font constants. Keep in sync with FONT_ definitions in +/// `extmod/modtrezorui/display.h`. #[derive(Copy, Clone, PartialEq, Eq)] -pub struct Font(i32); +#[repr(u8)] +pub enum Font { + NORMAL = 1, + BOLD = 2, + MONO = 3, + MEDIUM = 5, +} + +impl From for i32 { + fn from(font: Font) -> i32 { + -(font as i32) + } +} impl Font { - pub const fn new(id: i32) -> Self { - Self(id) - } - pub fn text_width(self, text: &str) -> i16 { - display::text_width(text, self.0) as i16 + display::text_width(text, self.into()) as i16 } pub fn char_width(self, ch: char) -> i16 { - display::char_width(ch, self.0) as i16 + display::char_width(ch, self.into()) as i16 } pub fn text_height(self) -> i16 { - display::text_height(self.0) as i16 + display::text_height(self.into()) as i16 } pub fn line_height(self) -> i16 { @@ -712,7 +722,7 @@ impl Font { } pub fn get_glyph(self, char_byte: u8) -> Option { - let gl_data = display::get_char_glyph(char_byte, self.0); + let gl_data = display::get_char_glyph(char_byte, self.into()); if gl_data.is_null() { return None; diff --git a/core/embed/rust/src/ui/model_t1/component/dialog.rs b/core/embed/rust/src/ui/model_t1/component/dialog.rs index 5f1dd5a3c0..39820b3b36 100644 --- a/core/embed/rust/src/ui/model_t1/component/dialog.rs +++ b/core/embed/rust/src/ui/model_t1/component/dialog.rs @@ -1,9 +1,7 @@ -use super::{ - button::{Button, ButtonMsg::Clicked}, - theme, -}; +use super::button::{Button, ButtonMsg::Clicked}; use crate::ui::{ component::{Child, Component, Event, EventCtx}, + display::Font, geometry::Rect, }; @@ -45,7 +43,7 @@ where type Msg = DialogMsg; fn place(&mut self, bounds: Rect) -> Rect { - let button_height = theme::FONT_BOLD.line_height() + 2; + let button_height = Font::BOLD.line_height() + 2; let (content_area, button_area) = bounds.split_bottom(button_height); self.content.place(content_area); self.left_btn.as_mut().map(|b| b.place(button_area)); diff --git a/core/embed/rust/src/ui/model_t1/component/frame.rs b/core/embed/rust/src/ui/model_t1/component/frame.rs index 352946578e..47e7a489cf 100644 --- a/core/embed/rust/src/ui/model_t1/component/frame.rs +++ b/core/embed/rust/src/ui/model_t1/component/frame.rs @@ -1,7 +1,7 @@ use super::theme; use crate::ui::{ component::{Child, Component, Event, EventCtx}, - display, + display::{self, Font}, geometry::{Insets, Offset, Rect}, }; @@ -39,7 +39,7 @@ where fn place(&mut self, bounds: Rect) -> Rect { const TITLE_SPACE: i16 = 4; - let (title_area, content_area) = bounds.split_top(theme::FONT_BOLD.line_height()); + let (title_area, content_area) = bounds.split_top(Font::BOLD.line_height()); let content_area = content_area.inset(Insets::top(TITLE_SPACE)); self.area = title_area; @@ -55,7 +55,7 @@ where display::text( self.area.bottom_left() - Offset::y(2), self.title.as_ref(), - theme::FONT_BOLD, + Font::BOLD, theme::FG, theme::BG, ); diff --git a/core/embed/rust/src/ui/model_t1/component/page.rs b/core/embed/rust/src/ui/model_t1/component/page.rs index 64c3ee0029..dadb410937 100644 --- a/core/embed/rust/src/ui/model_t1/component/page.rs +++ b/core/embed/rust/src/ui/model_t1/component/page.rs @@ -1,6 +1,6 @@ use crate::ui::{ component::{Component, ComponentExt, Event, EventCtx, Never, Pad, PageMsg, Paginate}, - display::{self, Color}, + display::{self, Color, Font}, geometry::{Insets, Offset, Point, Rect}, }; @@ -50,7 +50,7 @@ where type Msg = PageMsg; fn place(&mut self, bounds: Rect) -> Rect { - let button_height = theme::FONT_BOLD.line_height() + 2; + let button_height = Font::BOLD.line_height() + 2; let (content_area, button_area) = bounds.split_bottom(button_height); let (content_area, scrollbar_area) = content_area.split_right(ScrollBar::WIDTH); let content_area = content_area.inset(Insets::top(1)); diff --git a/core/embed/rust/src/ui/model_t1/theme.rs b/core/embed/rust/src/ui/model_t1/theme.rs index 20213e577a..5e89ab674e 100644 --- a/core/embed/rust/src/ui/model_t1/theme.rs +++ b/core/embed/rust/src/ui/model_t1/theme.rs @@ -5,12 +5,6 @@ use crate::ui::{ use super::component::{ButtonStyle, ButtonStyleSheet}; -// Font constants. -pub const FONT_NORMAL: Font = Font::new(-1); -pub const FONT_MEDIUM: Font = Font::new(-5); -pub const FONT_BOLD: Font = Font::new(-2); -pub const FONT_MONO: Font = Font::new(-3); - // Color palette. pub const WHITE: Color = Color::rgb(255, 255, 255); pub const BLACK: Color = Color::rgb(0, 0, 0); @@ -21,12 +15,12 @@ pub const BG: Color = BLACK; // Default background color. pub fn button_default() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: BG, border_horiz: true, }, active: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, border_horiz: true, }, @@ -36,26 +30,26 @@ pub fn button_default() -> ButtonStyleSheet { pub fn button_cancel() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, border_horiz: false, }, active: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: BG, border_horiz: false, }, } } -pub const TEXT_NORMAL: TextStyle = TextStyle::new(FONT_NORMAL, FG, BG, FG, FG); -pub const TEXT_MEDIUM: TextStyle = TextStyle::new(FONT_MEDIUM, FG, BG, FG, FG); -pub const TEXT_BOLD: TextStyle = TextStyle::new(FONT_BOLD, FG, BG, FG, FG); -pub const TEXT_MONO: TextStyle = TextStyle::new(FONT_MONO, FG, BG, FG, FG); +pub const TEXT_NORMAL: TextStyle = TextStyle::new(Font::NORMAL, FG, BG, FG, FG); +pub const TEXT_MEDIUM: TextStyle = TextStyle::new(Font::MEDIUM, FG, BG, FG, FG); +pub const TEXT_BOLD: TextStyle = TextStyle::new(Font::BOLD, FG, BG, FG, FG); +pub const TEXT_MONO: TextStyle = TextStyle::new(Font::MONO, FG, BG, FG, FG); pub const FORMATTED: FormattedFonts = FormattedFonts { - normal: FONT_NORMAL, - medium: FONT_MEDIUM, - bold: FONT_BOLD, - mono: FONT_MONO, + normal: Font::NORMAL, + medium: Font::MEDIUM, + bold: Font::BOLD, + mono: Font::MONO, }; diff --git a/core/embed/rust/src/ui/model_tr/component/dialog.rs b/core/embed/rust/src/ui/model_tr/component/dialog.rs index 5f1dd5a3c0..39820b3b36 100644 --- a/core/embed/rust/src/ui/model_tr/component/dialog.rs +++ b/core/embed/rust/src/ui/model_tr/component/dialog.rs @@ -1,9 +1,7 @@ -use super::{ - button::{Button, ButtonMsg::Clicked}, - theme, -}; +use super::button::{Button, ButtonMsg::Clicked}; use crate::ui::{ component::{Child, Component, Event, EventCtx}, + display::Font, geometry::Rect, }; @@ -45,7 +43,7 @@ where type Msg = DialogMsg; fn place(&mut self, bounds: Rect) -> Rect { - let button_height = theme::FONT_BOLD.line_height() + 2; + let button_height = Font::BOLD.line_height() + 2; let (content_area, button_area) = bounds.split_bottom(button_height); self.content.place(content_area); self.left_btn.as_mut().map(|b| b.place(button_area)); diff --git a/core/embed/rust/src/ui/model_tr/component/frame.rs b/core/embed/rust/src/ui/model_tr/component/frame.rs index 352946578e..47e7a489cf 100644 --- a/core/embed/rust/src/ui/model_tr/component/frame.rs +++ b/core/embed/rust/src/ui/model_tr/component/frame.rs @@ -1,7 +1,7 @@ use super::theme; use crate::ui::{ component::{Child, Component, Event, EventCtx}, - display, + display::{self, Font}, geometry::{Insets, Offset, Rect}, }; @@ -39,7 +39,7 @@ where fn place(&mut self, bounds: Rect) -> Rect { const TITLE_SPACE: i16 = 4; - let (title_area, content_area) = bounds.split_top(theme::FONT_BOLD.line_height()); + let (title_area, content_area) = bounds.split_top(Font::BOLD.line_height()); let content_area = content_area.inset(Insets::top(TITLE_SPACE)); self.area = title_area; @@ -55,7 +55,7 @@ where display::text( self.area.bottom_left() - Offset::y(2), self.title.as_ref(), - theme::FONT_BOLD, + Font::BOLD, theme::FG, theme::BG, ); diff --git a/core/embed/rust/src/ui/model_tr/component/page.rs b/core/embed/rust/src/ui/model_tr/component/page.rs index 64c3ee0029..dadb410937 100644 --- a/core/embed/rust/src/ui/model_tr/component/page.rs +++ b/core/embed/rust/src/ui/model_tr/component/page.rs @@ -1,6 +1,6 @@ use crate::ui::{ component::{Component, ComponentExt, Event, EventCtx, Never, Pad, PageMsg, Paginate}, - display::{self, Color}, + display::{self, Color, Font}, geometry::{Insets, Offset, Point, Rect}, }; @@ -50,7 +50,7 @@ where type Msg = PageMsg; fn place(&mut self, bounds: Rect) -> Rect { - let button_height = theme::FONT_BOLD.line_height() + 2; + let button_height = Font::BOLD.line_height() + 2; let (content_area, button_area) = bounds.split_bottom(button_height); let (content_area, scrollbar_area) = content_area.split_right(ScrollBar::WIDTH); let content_area = content_area.inset(Insets::top(1)); diff --git a/core/embed/rust/src/ui/model_tr/component/result_popup.rs b/core/embed/rust/src/ui/model_tr/component/result_popup.rs index fcbf799ffa..5d6f6a0cdb 100644 --- a/core/embed/rust/src/ui/model_tr/component/result_popup.rs +++ b/core/embed/rust/src/ui/model_tr/component/result_popup.rs @@ -6,10 +6,11 @@ use crate::{ LabelStyle, Pad, }, constant::screen, + display::Font, geometry::{Alignment, Insets, LinearPlacement, Point, Rect}, model_tr::{ component::{Button, ButtonMsg, ButtonPos, ResultAnim, ResultAnimMsg}, - theme::{self, FONT_BOLD}, + theme, }, }, }; @@ -58,7 +59,7 @@ impl ResultPopup { let headline_style = LabelStyle { background_color: theme::BG, text_color: theme::FG, - font: FONT_BOLD, + font: Font::BOLD, }; let mut pad = Pad::with_background(theme::BG); diff --git a/core/embed/rust/src/ui/model_tr/theme.rs b/core/embed/rust/src/ui/model_tr/theme.rs index b04cfc191b..d038c98793 100644 --- a/core/embed/rust/src/ui/model_tr/theme.rs +++ b/core/embed/rust/src/ui/model_tr/theme.rs @@ -6,12 +6,6 @@ use crate::ui::{ use super::component::{ButtonStyle, ButtonStyleSheet}; -// Font constants. -pub const FONT_NORMAL: Font = Font::new(-1); -pub const FONT_MEDIUM: Font = Font::new(-5); -pub const FONT_BOLD: Font = Font::new(-2); -pub const FONT_MONO: Font = Font::new(-3); - // Color palette. pub const WHITE: Color = Color::rgb(255, 255, 255); pub const BLACK: Color = Color::rgb(0, 0, 0); @@ -25,12 +19,12 @@ pub const ICON_FAIL: &[u8] = include_res!("model_tr/res/fail.toif"); pub fn button_default() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: BG, border_horiz: true, }, active: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, border_horiz: true, }, @@ -40,12 +34,12 @@ pub fn button_default() -> ButtonStyleSheet { pub fn button_cancel() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, border_horiz: false, }, active: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: BG, border_horiz: false, }, @@ -55,21 +49,21 @@ pub fn button_cancel() -> ButtonStyleSheet { pub fn loader_default() -> LoaderStyleSheet { LoaderStyleSheet { normal: &LoaderStyle { - font: FONT_NORMAL, + font: Font::NORMAL, fg_color: FG, bg_color: BG, }, } } -pub const TEXT_NORMAL: TextStyle = TextStyle::new(FONT_NORMAL, FG, BG, FG, FG); -pub const TEXT_MEDIUM: TextStyle = TextStyle::new(FONT_MEDIUM, FG, BG, FG, FG); -pub const TEXT_BOLD: TextStyle = TextStyle::new(FONT_BOLD, FG, BG, FG, FG); -pub const TEXT_MONO: TextStyle = TextStyle::new(FONT_MONO, FG, BG, FG, FG); +pub const TEXT_NORMAL: TextStyle = TextStyle::new(Font::NORMAL, FG, BG, FG, FG); +pub const TEXT_MEDIUM: TextStyle = TextStyle::new(Font::MEDIUM, FG, BG, FG, FG); +pub const TEXT_BOLD: TextStyle = TextStyle::new(Font::BOLD, FG, BG, FG, FG); +pub const TEXT_MONO: TextStyle = TextStyle::new(Font::MONO, FG, BG, FG, FG); pub const FORMATTED: FormattedFonts = FormattedFonts { - normal: FONT_NORMAL, - medium: FONT_MEDIUM, - bold: FONT_BOLD, - mono: FONT_MONO, + normal: Font::NORMAL, + medium: Font::MEDIUM, + bold: Font::BOLD, + mono: Font::MONO, }; diff --git a/core/embed/rust/src/ui/model_tt/component/frame.rs b/core/embed/rust/src/ui/model_tt/component/frame.rs index d88092e4b6..ad8889c02d 100644 --- a/core/embed/rust/src/ui/model_tt/component/frame.rs +++ b/core/embed/rust/src/ui/model_tt/component/frame.rs @@ -48,7 +48,7 @@ where let (title_area, content_area) = bounds .inset(self.border) - .split_top(theme::FONT_BOLD.text_height()); + .split_top(Font::BOLD.text_height()); let title_area = title_area.inset(Insets::left(theme::CONTENT_BORDER)); let content_area = content_area.inset(Insets::top(TITLE_SPACE)); @@ -65,7 +65,7 @@ where display::text( self.area.bottom_left(), self.title.as_ref(), - theme::FONT_BOLD, + Font::BOLD, theme::GREY_LIGHT, theme::BG, ); @@ -107,7 +107,7 @@ where { const HEIGHT: i16 = 42; const COLOR: Color = theme::YELLOW; - const FONT: Font = theme::FONT_BOLD; + const FONT: Font = Font::BOLD; const TEXT_OFFSET: Offset = Offset::new(1, -2); const ICON_SPACE: i16 = 8; diff --git a/core/embed/rust/src/ui/model_tt/component/keyboard/pin.rs b/core/embed/rust/src/ui/model_tt/component/keyboard/pin.rs index 180ad2cde2..83a0af4f6c 100644 --- a/core/embed/rust/src/ui/model_tt/component/keyboard/pin.rs +++ b/core/embed/rust/src/ui/model_tt/component/keyboard/pin.rs @@ -9,7 +9,7 @@ use crate::{ base::ComponentExt, Child, Component, Event, EventCtx, Label, LabelStyle, Maybe, Never, Pad, TimerToken, }, - display, + display::{self, Font}, event::TouchEvent, geometry::{Alignment, Grid, Insets, Offset, Rect}, model_tt::component::{ @@ -326,16 +326,15 @@ impl PinDots { } fn paint_digits(&self, area: Rect) { - let center = area.center() + Offset::y(theme::FONT_MONO.text_height() / 2); - let right = - center + Offset::x(theme::FONT_MONO.text_width("0") * (MAX_VISIBLE_DOTS as i16) / 2); + let center = area.center() + Offset::y(Font::MONO.text_height() / 2); + let right = center + Offset::x(Font::MONO.text_width("0") * (MAX_VISIBLE_DOTS as i16) / 2); let digits = self.digits.len(); if digits <= MAX_VISIBLE_DOTS { display::text_center( center, &self.digits, - theme::FONT_MONO, + Font::MONO, self.style.text_color, self.style.background_color, ); @@ -344,7 +343,7 @@ impl PinDots { display::text_right( right, &self.digits[offset..], - theme::FONT_MONO, + Font::MONO, self.style.text_color, self.style.background_color, ); diff --git a/core/embed/rust/src/ui/model_tt/component/number_input.rs b/core/embed/rust/src/ui/model_tt/component/number_input.rs index 7207ea54c0..d0b626f06a 100644 --- a/core/embed/rust/src/ui/model_tt/component/number_input.rs +++ b/core/embed/rust/src/ui/model_tt/component/number_input.rs @@ -2,7 +2,7 @@ use crate::ui::{ component::{ base::ComponentExt, text::paragraphs::Paragraphs, Child, Component, Event, EventCtx, Pad, }, - display, + display::{self, Font}, geometry::{Grid, Insets, Offset, Rect}, util, }; @@ -207,7 +207,7 @@ impl Component for NumberInput { fn paint(&mut self) { let mut buf = [0u8; 10]; if let Some(text) = util::u32_to_str(self.value, &mut buf) { - let digit_font = theme::FONT_MEDIUM; + let digit_font = Font::MEDIUM; let y_offset = digit_font.text_height() / 2 + Button::<&str>::BASELINE_OFFSET; display::rect_fill(self.area, theme::BG); display::text_center( diff --git a/core/embed/rust/src/ui/model_tt/theme.rs b/core/embed/rust/src/ui/model_tt/theme.rs index b80bf0a82b..7c9f3905ef 100644 --- a/core/embed/rust/src/ui/model_tt/theme.rs +++ b/core/embed/rust/src/ui/model_tt/theme.rs @@ -10,12 +10,6 @@ use crate::ui::{ use super::component::{ButtonStyle, ButtonStyleSheet, LoaderStyle, LoaderStyleSheet}; -// Font constants. -pub const FONT_NORMAL: Font = Font::new(-1); -pub const FONT_MEDIUM: Font = Font::new(-5); -pub const FONT_BOLD: Font = Font::new(-2); -pub const FONT_MONO: Font = Font::new(-3); - // Typical backlight values. pub const BACKLIGHT_NORMAL: i32 = 150; pub const BACKLIGHT_LOW: i32 = 45; @@ -74,7 +68,7 @@ pub const DOT_SMALL: &[u8] = include_res!("model_tt/res/scroll-small.toif"); pub fn label_default() -> LabelStyle { LabelStyle { - font: FONT_NORMAL, + font: Font::NORMAL, text_color: FG, background_color: BG, } @@ -82,7 +76,7 @@ pub fn label_default() -> LabelStyle { pub fn label_checklist_default() -> LabelStyle { LabelStyle { - font: FONT_NORMAL, + font: Font::NORMAL, text_color: GREY_LIGHT, background_color: BG, } @@ -90,7 +84,7 @@ pub fn label_checklist_default() -> LabelStyle { pub fn label_checklist_selected() -> LabelStyle { LabelStyle { - font: FONT_NORMAL, + font: Font::NORMAL, text_color: FG, background_color: BG, } @@ -98,7 +92,7 @@ pub fn label_checklist_selected() -> LabelStyle { pub fn label_checklist_done() -> LabelStyle { LabelStyle { - font: FONT_NORMAL, + font: Font::NORMAL, text_color: GREEN_DARK, background_color: BG, } @@ -106,7 +100,7 @@ pub fn label_checklist_done() -> LabelStyle { pub fn label_keyboard() -> LabelStyle { LabelStyle { - font: FONT_MEDIUM, + font: Font::MEDIUM, text_color: OFF_WHITE, background_color: BG, } @@ -114,7 +108,7 @@ pub fn label_keyboard() -> LabelStyle { pub fn label_keyboard_warning() -> LabelStyle { LabelStyle { - font: FONT_MEDIUM, + font: Font::MEDIUM, text_color: RED, background_color: BG, } @@ -122,7 +116,7 @@ pub fn label_keyboard_warning() -> LabelStyle { pub fn label_keyboard_minor() -> LabelStyle { LabelStyle { - font: FONT_NORMAL, + font: Font::NORMAL, text_color: OFF_WHITE, background_color: BG, } @@ -130,7 +124,7 @@ pub fn label_keyboard_minor() -> LabelStyle { pub fn label_page_hint() -> LabelStyle { LabelStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: GREY_LIGHT, background_color: BG, } @@ -138,7 +132,7 @@ pub fn label_page_hint() -> LabelStyle { pub fn label_warning() -> LabelStyle { LabelStyle { - font: FONT_MEDIUM, + font: Font::MEDIUM, text_color: FG, background_color: BG, } @@ -146,7 +140,7 @@ pub fn label_warning() -> LabelStyle { pub fn label_warning_value() -> LabelStyle { LabelStyle { - font: FONT_NORMAL, + font: Font::NORMAL, text_color: OFF_WHITE, background_color: BG, } @@ -154,7 +148,7 @@ pub fn label_warning_value() -> LabelStyle { pub fn label_recovery_title() -> LabelStyle { LabelStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, background_color: BG, } @@ -162,7 +156,7 @@ pub fn label_recovery_title() -> LabelStyle { pub fn label_recovery_description() -> LabelStyle { LabelStyle { - font: FONT_NORMAL, + font: Font::NORMAL, text_color: OFF_WHITE, background_color: BG, } @@ -171,7 +165,7 @@ pub fn label_recovery_description() -> LabelStyle { pub fn button_default() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, button_color: GREY_DARK, background_color: BG, @@ -180,7 +174,7 @@ pub fn button_default() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, button_color: GREY_MEDIUM, background_color: BG, @@ -189,7 +183,7 @@ pub fn button_default() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: GREY_LIGHT, button_color: GREY_DARK, background_color: BG, @@ -203,7 +197,7 @@ pub fn button_default() -> ButtonStyleSheet { pub fn button_confirm() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, button_color: GREEN, background_color: BG, @@ -212,7 +206,7 @@ pub fn button_confirm() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, button_color: GREEN_DARK, background_color: BG, @@ -221,7 +215,7 @@ pub fn button_confirm() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, button_color: GREEN, background_color: BG, @@ -235,7 +229,7 @@ pub fn button_confirm() -> ButtonStyleSheet { pub fn button_cancel() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, button_color: RED, background_color: BG, @@ -244,7 +238,7 @@ pub fn button_cancel() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, button_color: RED_DARK, background_color: BG, @@ -253,7 +247,7 @@ pub fn button_cancel() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: GREY_LIGHT, button_color: RED, background_color: BG, @@ -267,7 +261,7 @@ pub fn button_cancel() -> ButtonStyleSheet { pub fn button_reset() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, button_color: YELLOW, background_color: BG, @@ -276,7 +270,7 @@ pub fn button_reset() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, button_color: YELLOW_DARK, background_color: BG, @@ -285,7 +279,7 @@ pub fn button_reset() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: GREY_LIGHT, button_color: YELLOW, background_color: BG, @@ -299,7 +293,7 @@ pub fn button_reset() -> ButtonStyleSheet { pub fn button_info() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, button_color: BLUE, background_color: BG, @@ -308,7 +302,7 @@ pub fn button_info() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: FG, button_color: BLUE_DARK, background_color: BG, @@ -317,7 +311,7 @@ pub fn button_info() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: FONT_BOLD, + font: Font::BOLD, text_color: GREY_LIGHT, button_color: BLUE, background_color: BG, @@ -331,7 +325,7 @@ pub fn button_info() -> ButtonStyleSheet { pub fn button_pin() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_MONO, + font: Font::MONO, text_color: FG, button_color: GREY_DARK, background_color: BG, @@ -340,7 +334,7 @@ pub fn button_pin() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: FONT_MONO, + font: Font::MONO, text_color: FG, button_color: GREY_MEDIUM, background_color: BG, @@ -349,7 +343,7 @@ pub fn button_pin() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: FONT_MONO, + font: Font::MONO, text_color: GREY_LIGHT, button_color: GREY_DARK, background_color: BG, @@ -363,7 +357,7 @@ pub fn button_pin() -> ButtonStyleSheet { pub fn button_counter() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_MEDIUM, + font: Font::MEDIUM, text_color: FG, button_color: GREY_DARK, background_color: BG, @@ -372,7 +366,7 @@ pub fn button_counter() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: FONT_MEDIUM, + font: Font::MEDIUM, text_color: FG, button_color: GREY_MEDIUM, background_color: BG, @@ -381,7 +375,7 @@ pub fn button_counter() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: FONT_MEDIUM, + font: Font::MEDIUM, text_color: GREY_LIGHT, button_color: GREY_DARK, background_color: BG, @@ -411,16 +405,16 @@ pub fn loader_default() -> LoaderStyleSheet { } } -pub const TEXT_NORMAL: TextStyle = TextStyle::new(FONT_NORMAL, FG, BG, GREY_LIGHT, GREY_LIGHT); -pub const TEXT_MEDIUM: TextStyle = TextStyle::new(FONT_MEDIUM, FG, BG, GREY_LIGHT, GREY_LIGHT); -pub const TEXT_BOLD: TextStyle = TextStyle::new(FONT_BOLD, FG, BG, GREY_LIGHT, GREY_LIGHT); -pub const TEXT_MONO: TextStyle = TextStyle::new(FONT_MONO, FG, BG, GREY_LIGHT, GREY_LIGHT); +pub const TEXT_NORMAL: TextStyle = TextStyle::new(Font::NORMAL, FG, BG, GREY_LIGHT, GREY_LIGHT); +pub const TEXT_MEDIUM: TextStyle = TextStyle::new(Font::MEDIUM, FG, BG, GREY_LIGHT, GREY_LIGHT); +pub const TEXT_BOLD: TextStyle = TextStyle::new(Font::BOLD, FG, BG, GREY_LIGHT, GREY_LIGHT); +pub const TEXT_MONO: TextStyle = TextStyle::new(Font::MONO, FG, BG, GREY_LIGHT, GREY_LIGHT); pub const FORMATTED: FormattedFonts = FormattedFonts { - normal: FONT_NORMAL, - medium: FONT_MEDIUM, - bold: FONT_BOLD, - mono: FONT_MONO, + normal: Font::NORMAL, + medium: Font::MEDIUM, + bold: Font::BOLD, + mono: Font::MONO, }; pub const CONTENT_BORDER: i16 = 5;