diff --git a/core/embed/rust/src/ui/api/bootloader_c.rs b/core/embed/rust/src/ui/api/bootloader_c.rs index 9783f9c427e..30590d6ec8b 100644 --- a/core/embed/rust/src/ui/api/bootloader_c.rs +++ b/core/embed/rust/src/ui/api/bootloader_c.rs @@ -2,8 +2,9 @@ use crate::{ strutil::hexlify, trezorhal::secbool::secbool, ui::{ - ui_features::{ModelUI, UIFeaturesBootloader}, + ui_bootloader::BootloaderUI, util::{from_c_array, from_c_str}, + ModelUI, }, }; diff --git a/core/embed/rust/src/ui/api/common_c.rs b/core/embed/rust/src/ui/api/common_c.rs index 1050e1b45bc..16c81443ce5 100644 --- a/core/embed/rust/src/ui/api/common_c.rs +++ b/core/embed/rust/src/ui/api/common_c.rs @@ -1,7 +1,7 @@ //! Reexporting the `screens` module according to the //! current feature (Trezor model) -use crate::ui::ui_features::{ModelUI, UIFeaturesCommon}; +use crate::ui::{CommonUI, ModelUI}; use crate::ui::shape; diff --git a/core/embed/rust/src/ui/api/firmware_upy.rs b/core/embed/rust/src/ui/api/firmware_micropython.rs similarity index 99% rename from core/embed/rust/src/ui/api/firmware_upy.rs rename to core/embed/rust/src/ui/api/firmware_micropython.rs index 1677d84f906..ed4d6244bd3 100644 --- a/core/embed/rust/src/ui/api/firmware_upy.rs +++ b/core/embed/rust/src/ui/api/firmware_micropython.rs @@ -21,10 +21,10 @@ use crate::{ result::{CANCELLED, CONFIRMED, INFO}, util::{upy_disable_animation, RecoveryType}, }, - ui_features::ModelUI, - ui_features_fw::{ - UIFeaturesFirmware, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS, + ui_firmware::{ + FirmwareUI, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS, }, + ModelUI, }, }; use heapless::Vec; diff --git a/core/embed/rust/src/ui/api/mod.rs b/core/embed/rust/src/ui/api/mod.rs index 8569a55b7e6..4b91b6315aa 100644 --- a/core/embed/rust/src/ui/api/mod.rs +++ b/core/embed/rust/src/ui/api/mod.rs @@ -4,4 +4,4 @@ pub mod common_c; pub mod bootloader_c; #[cfg(feature = "micropython")] -pub mod firmware_upy; +pub mod firmware_micropython; diff --git a/core/embed/rust/src/ui/backlight.rs b/core/embed/rust/src/ui/backlight.rs index 98f6aff2695..14bfa68b9c0 100644 --- a/core/embed/rust/src/ui/backlight.rs +++ b/core/embed/rust/src/ui/backlight.rs @@ -3,7 +3,7 @@ use crate::{ micropython::{ ffi, macros::obj_type, obj::Obj, qstr::Qstr, simple_type::SimpleTypeObj, typ::Type, util, }, - ui::{ui_features::ModelUI, UIFeaturesCommon}, + ui::{CommonUI, ModelUI}, }; /* diff --git a/core/embed/rust/src/ui/flow/swipe.rs b/core/embed/rust/src/ui/flow/swipe.rs index 2268cb8ebd6..a4039072b45 100644 --- a/core/embed/rust/src/ui/flow/swipe.rs +++ b/core/embed/rust/src/ui/flow/swipe.rs @@ -16,9 +16,8 @@ use crate::{ geometry::{Direction, Rect}, layout::base::{Layout, LayoutState}, shape::{render_on_display, ConcreteRenderer, Renderer, ScopedRenderer}, - ui_features::ModelUI, util::animation_disabled, - UIFeaturesCommon, + CommonUI, ModelUI, }, }; diff --git a/core/embed/rust/src/ui/layout/obj.rs b/core/embed/rust/src/ui/layout/obj.rs index 2c74c378d56..51ae2231405 100644 --- a/core/embed/rust/src/ui/layout/obj.rs +++ b/core/embed/rust/src/ui/layout/obj.rs @@ -37,8 +37,7 @@ use crate::{ }, display, event::USBEvent, - ui_features::ModelUI, - UIFeaturesCommon, + CommonUI, ModelUI, }, }; @@ -97,7 +96,7 @@ impl ComponentMaybeTrace for T where T: Component + ComponentMsgObj + MaybeTr pub struct RootComponent where T: Component, - M: UIFeaturesCommon, + M: CommonUI, { inner: T, returned_value: Option>, @@ -107,7 +106,7 @@ where impl RootComponent where T: ComponentMaybeTrace, - M: UIFeaturesCommon, + M: CommonUI, { pub fn new(component: T) -> Self { Self { diff --git a/core/embed/rust/src/ui/layout/simplified.rs b/core/embed/rust/src/ui/layout/simplified.rs index 6ecc692a4d4..3ed54b99c76 100644 --- a/core/embed/rust/src/ui/layout/simplified.rs +++ b/core/embed/rust/src/ui/layout/simplified.rs @@ -8,9 +8,7 @@ use crate::ui::event::ButtonEvent; use crate::ui::event::TouchEvent; use crate::ui::{ component::{Component, Event, EventCtx, Never}, - display, - ui_features::ModelUI, - UIFeaturesCommon, + display, CommonUI, ModelUI, }; use num_traits::ToPrimitive; diff --git a/core/embed/rust/src/ui/mod.rs b/core/embed/rust/src/ui/mod.rs index 7636c026a3e..6ed81d9f915 100644 --- a/core/embed/rust/src/ui/mod.rs +++ b/core/embed/rust/src/ui/mod.rs @@ -24,8 +24,23 @@ pub mod model_tr; #[cfg(feature = "model_tt")] pub mod model_tt; -pub mod ui_features; +#[cfg(feature = "bootloader")] +pub mod ui_bootloader; +pub mod ui_common; #[cfg(feature = "micropython")] -pub mod ui_features_fw; +pub mod ui_firmware; -pub use ui_features::UIFeaturesCommon; +pub use ui_common::CommonUI; + +#[cfg(all( + feature = "model_mercury", + not(feature = "model_tr"), + not(feature = "model_tt") +))] +pub type ModelUI = crate::ui::model_mercury::UIMercury; + +#[cfg(all(feature = "model_tr", not(feature = "model_tt")))] +pub type ModelUI = crate::ui::model_tr::UIModelTR; + +#[cfg(feature = "model_tt")] +pub type ModelUI = crate::ui::model_tt::UIModelTT; diff --git a/core/embed/rust/src/ui/model_mercury/bootloader/mod.rs b/core/embed/rust/src/ui/model_mercury/bootloader/mod.rs index e36169ed2ac..bc0cf1825b0 100644 --- a/core/embed/rust/src/ui/model_mercury/bootloader/mod.rs +++ b/core/embed/rust/src/ui/model_mercury/bootloader/mod.rs @@ -26,10 +26,10 @@ use super::{ }, GREEN_LIGHT, GREY, }, - ModelMercuryFeatures, + UIMercury, }; -use crate::ui::{ui_features::UIFeaturesBootloader, UIFeaturesCommon}; +use crate::ui::{ui_features::BootloaderUI, CommonUI}; use crate::ui::{ display::{toif::Toif, LOADER_MAX}, @@ -53,10 +53,10 @@ pub type BootloaderString = String<128>; const RECONNECT_MESSAGE: &str = "PLEASE RECONNECT\nTHE DEVICE"; -const SCREEN: Rect = ModelMercuryFeatures::SCREEN; +const SCREEN: Rect = UIMercury::SCREEN; const PROGRESS_TEXT_ORIGIN: Point = Point::new(2, 28); -impl ModelMercuryFeatures { +impl UIMercury { fn screen_progress( text: &str, progress: u16, @@ -122,7 +122,7 @@ impl ModelMercuryFeatures { } } -impl UIFeaturesBootloader for ModelMercuryFeatures { +impl BootloaderUI for UIMercury { fn screen_welcome() { let mut frame = Welcome::new(); show(&mut frame, true); diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/component_msg_obj.rs similarity index 100% rename from core/embed/rust/src/ui/model_mercury/layout.rs rename to core/embed/rust/src/ui/model_mercury/component_msg_obj.rs diff --git a/core/embed/rust/src/ui/model_mercury/mod.rs b/core/embed/rust/src/ui/model_mercury/mod.rs index 79ee10cc908..fcbf33ee4b1 100644 --- a/core/embed/rust/src/ui/model_mercury/mod.rs +++ b/core/embed/rust/src/ui/model_mercury/mod.rs @@ -1,4 +1,4 @@ -use super::{geometry::Rect, UIFeaturesCommon}; +use super::{geometry::Rect, CommonUI}; use crate::ui::model_mercury::theme::backlight; #[cfg(feature = "bootloader")] @@ -7,18 +7,18 @@ pub mod component; pub mod constant; pub mod theme; +#[cfg(feature = "micropython")] +pub mod component_msg_obj; pub mod cshape; #[cfg(feature = "micropython")] pub mod flow; -#[cfg(feature = "micropython")] -pub mod layout; pub mod screens; #[cfg(feature = "micropython")] -pub mod ui_features_fw; +pub mod ui_firmware; -pub struct ModelMercuryFeatures; +pub struct UIMercury; -impl UIFeaturesCommon for ModelMercuryFeatures { +impl CommonUI for UIMercury { #[cfg(feature = "backlight")] fn fadein() { crate::ui::display::fade_backlight_duration(backlight::get_backlight_normal(), 150); diff --git a/core/embed/rust/src/ui/model_mercury/ui_features_fw.rs b/core/embed/rust/src/ui/model_mercury/ui_firmware.rs similarity index 99% rename from core/embed/rust/src/ui/model_mercury/ui_features_fw.rs rename to core/embed/rust/src/ui/model_mercury/ui_firmware.rs index 3cfdd4566a6..ba22ac4e2c5 100644 --- a/core/embed/rust/src/ui/model_mercury/ui_features_fw.rs +++ b/core/embed/rust/src/ui/model_mercury/ui_firmware.rs @@ -25,10 +25,10 @@ use crate::{ obj::{LayoutMaybeTrace, LayoutObj, RootComponent}, util::{PropsList, RecoveryType}, }, - ui_features::ModelUI, - ui_features_fw::{ - UIFeaturesFirmware, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS, + ui_firmware::{ + FirmwareUI, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS, }, + ModelUI, }, }; @@ -42,10 +42,10 @@ use super::{ self, new_confirm_action_simple, ConfirmActionExtra, ConfirmActionMenuStrings, ConfirmActionStrings, ConfirmBlobParams, ShowInfoParams, }, - theme, ModelMercuryFeatures, + theme, UIMercury, }; -impl UIFeaturesFirmware for ModelMercuryFeatures { +impl FirmwareUI for UIMercury { fn confirm_action( title: TString<'static>, action: Option>, diff --git a/core/embed/rust/src/ui/model_tr/bootloader/mod.rs b/core/embed/rust/src/ui/model_tr/bootloader/mod.rs index f23e7bb13a0..2e8d5142011 100644 --- a/core/embed/rust/src/ui/model_tr/bootloader/mod.rs +++ b/core/embed/rust/src/ui/model_tr/bootloader/mod.rs @@ -21,7 +21,7 @@ use super::{ bootloader::{BLD_BG, BLD_FG, ICON_ALERT, ICON_SPINNER, ICON_SUCCESS}, ICON_ARM_LEFT, ICON_ARM_RIGHT, TEXT_BOLD, TEXT_NORMAL, }, - ModelTRFeatures, + UIModelTR, }; use crate::ui::{ @@ -34,7 +34,7 @@ mod intro; mod menu; mod welcome; -use crate::ui::ui_features::UIFeaturesBootloader; +use crate::ui::ui_features::BootloaderUI; use intro::Intro; use menu::Menu; use welcome::Welcome; @@ -47,7 +47,7 @@ impl ReturnToC for ConfirmMsg { } } -impl ModelTRFeatures { +impl UIModelTR { fn screen_progress( text: &str, text2: &str, @@ -92,7 +92,7 @@ impl ModelTRFeatures { } } -impl UIFeaturesBootloader for ModelTRFeatures { +impl BootloaderUI for UIModelTR { fn screen_welcome() { let mut frame = Welcome::new(); show(&mut frame, true); diff --git a/core/embed/rust/src/ui/model_tr/layout.rs b/core/embed/rust/src/ui/model_tr/component_msg_obj.rs similarity index 100% rename from core/embed/rust/src/ui/model_tr/layout.rs rename to core/embed/rust/src/ui/model_tr/component_msg_obj.rs diff --git a/core/embed/rust/src/ui/model_tr/mod.rs b/core/embed/rust/src/ui/model_tr/mod.rs index d7369d81d39..cce8bdaf422 100644 --- a/core/embed/rust/src/ui/model_tr/mod.rs +++ b/core/embed/rust/src/ui/model_tr/mod.rs @@ -1,22 +1,22 @@ -use super::{geometry::Rect, UIFeaturesCommon}; +use super::{geometry::Rect, CommonUI}; #[cfg(feature = "bootloader")] pub mod bootloader; pub mod common_messages; pub mod component; +#[cfg(feature = "micropython")] +pub mod component_msg_obj; pub mod constant; pub mod cshape; -#[cfg(feature = "micropython")] -pub mod layout; mod screens; pub mod theme; -pub struct ModelTRFeatures {} +pub struct UIModelTR {} #[cfg(feature = "micropython")] -pub mod ui_features_fw; +pub mod ui_firmware; -impl UIFeaturesCommon for ModelTRFeatures { +impl CommonUI for UIModelTR { const SCREEN: Rect = constant::SCREEN; fn screen_fatal_error(title: &str, msg: &str, footer: &str) { diff --git a/core/embed/rust/src/ui/model_tr/ui_features_fw.rs b/core/embed/rust/src/ui/model_tr/ui_firmware.rs similarity index 99% rename from core/embed/rust/src/ui/model_tr/ui_features_fw.rs rename to core/embed/rust/src/ui/model_tr/ui_firmware.rs index e58df99040d..ef3b4e18f86 100644 --- a/core/embed/rust/src/ui/model_tr/ui_features_fw.rs +++ b/core/embed/rust/src/ui/model_tr/ui_firmware.rs @@ -30,10 +30,10 @@ use crate::{ component::{ButtonActions, ButtonLayout, Page}, constant, }, - ui_features::ModelUI, - ui_features_fw::{ - UIFeaturesFirmware, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS, + ui_firmware::{ + FirmwareUI, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS, }, + ModelUI, }, }; @@ -43,12 +43,12 @@ use super::{ FlowPages, Frame, Homescreen, Lockscreen, NumberInput, PassphraseEntry, PinEntry, Progress, ScrollableFrame, ShareWords, ShowMore, SimpleChoice, WordlistEntry, WordlistType, }, - theme, ModelTRFeatures, + theme, UIModelTR, }; use heapless::Vec; -impl UIFeaturesFirmware for ModelTRFeatures { +impl FirmwareUI for UIModelTR { fn confirm_action( title: TString<'static>, action: Option>, diff --git a/core/embed/rust/src/ui/model_tt/bootloader/mod.rs b/core/embed/rust/src/ui/model_tt/bootloader/mod.rs index 939d05b7bbb..b55bea3355d 100644 --- a/core/embed/rust/src/ui/model_tt/bootloader/mod.rs +++ b/core/embed/rust/src/ui/model_tt/bootloader/mod.rs @@ -26,10 +26,10 @@ use super::{ }, FG, }, - ModelTTFeatures, + UIModelTT, }; -use crate::ui::{ui_features::UIFeaturesBootloader, UIFeaturesCommon}; +use crate::ui::{ui_bootloader::BootloaderUI, CommonUI}; use crate::ui::{ display::toif::Toif, @@ -56,9 +56,9 @@ pub type BootloaderString = String<128>; const RECONNECT_MESSAGE: &str = "PLEASE RECONNECT\nTHE DEVICE"; -const SCREEN: Rect = ModelTTFeatures::SCREEN; +const SCREEN: Rect = UIModelTT::SCREEN; -impl ModelTTFeatures { +impl UIModelTT { fn screen_progress( text: &str, progress: u16, @@ -133,7 +133,7 @@ impl ModelTTFeatures { } } -impl UIFeaturesBootloader for ModelTTFeatures { +impl BootloaderUI for UIModelTT { fn screen_welcome() { let mut frame = Welcome::new(); show(&mut frame, true); diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/component_msg_obj.rs similarity index 100% rename from core/embed/rust/src/ui/model_tt/layout.rs rename to core/embed/rust/src/ui/model_tt/component_msg_obj.rs diff --git a/core/embed/rust/src/ui/model_tt/mod.rs b/core/embed/rust/src/ui/model_tt/mod.rs index 4554c422dc1..370c9bc695c 100644 --- a/core/embed/rust/src/ui/model_tt/mod.rs +++ b/core/embed/rust/src/ui/model_tt/mod.rs @@ -1,4 +1,4 @@ -use super::{geometry::Rect, UIFeaturesCommon}; +use super::{geometry::Rect, CommonUI}; #[cfg(feature = "bootloader")] pub mod bootloader; @@ -9,21 +9,21 @@ pub mod theme; #[cfg(feature = "backlight")] use crate::ui::model_tt::theme::backlight; -pub mod cshape; #[cfg(feature = "micropython")] -pub mod layout; +pub mod component_msg_obj; +pub mod cshape; use crate::ui::{ layout::simplified::show, model_tt::component::{ErrorScreen, WelcomeScreen}, }; -pub struct ModelTTFeatures; +pub struct UIModelTT; #[cfg(feature = "micropython")] -pub mod ui_features_fw; +pub mod ui_firmware; -impl UIFeaturesCommon for ModelTTFeatures { +impl CommonUI for UIModelTT { #[cfg(feature = "backlight")] fn fadein() { crate::ui::display::fade_backlight_duration(backlight::get_backlight_normal(), 150); diff --git a/core/embed/rust/src/ui/model_tt/ui_features_fw.rs b/core/embed/rust/src/ui/model_tt/ui_firmware.rs similarity index 99% rename from core/embed/rust/src/ui/model_tt/ui_features_fw.rs rename to core/embed/rust/src/ui/model_tt/ui_firmware.rs index bd20da0ce49..d2790d3c167 100644 --- a/core/embed/rust/src/ui/model_tt/ui_features_fw.rs +++ b/core/embed/rust/src/ui/model_tt/ui_firmware.rs @@ -25,10 +25,10 @@ use crate::{ obj::{LayoutMaybeTrace, LayoutObj, RootComponent}, util::{ConfirmBlob, PropsList, RecoveryType}, }, - ui_features::ModelUI, - ui_features_fw::{ - UIFeaturesFirmware, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS, + ui_firmware::{ + FirmwareUI, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS, }, + ModelUI, }, }; @@ -40,10 +40,10 @@ use super::{ PassphraseKeyboard, PinKeyboard, Progress, SelectWordCount, SetBrightnessDialog, ShareWords, SimplePage, Slip39Input, }, - theme, ModelTTFeatures, + theme, UIModelTT, }; -impl UIFeaturesFirmware for ModelTTFeatures { +impl FirmwareUI for UIModelTT { fn confirm_action( title: TString<'static>, action: Option>, diff --git a/core/embed/rust/src/ui/ui_features.rs b/core/embed/rust/src/ui/ui_bootloader.rs similarity index 57% rename from core/embed/rust/src/ui/ui_features.rs rename to core/embed/rust/src/ui/ui_bootloader.rs index 2aca8f45dfa..1a76428c956 100644 --- a/core/embed/rust/src/ui/ui_features.rs +++ b/core/embed/rust/src/ui/ui_bootloader.rs @@ -1,38 +1,8 @@ -use crate::ui::geometry::Rect; - #[cfg(feature = "bootloader")] use crate::trezorhal::secbool::secbool; -pub trait UIFeaturesCommon { - fn fadein() {} - fn fadeout() {} - fn backlight_on() {} - - fn get_backlight_none() -> u8 { - 0 - } - fn get_backlight_normal() -> u8 { - 0 - } - fn get_backlight_low() -> u8 { - 0 - } - fn get_backlight_dim() -> u8 { - 0 - } - fn get_backlight_max() -> u8 { - 0 - } - - const SCREEN: Rect; - - fn screen_fatal_error(title: &str, msg: &str, footer: &str); - - fn screen_boot_stage_2(); -} - #[cfg(feature = "bootloader")] -pub trait UIFeaturesBootloader { +pub trait BootloaderUI { fn screen_welcome(); fn screen_install_success(restart_seconds: u8, initial_setup: bool, complete_draw: bool); @@ -79,16 +49,3 @@ pub trait UIFeaturesBootloader { wait: i32, ); } - -#[cfg(all( - feature = "model_mercury", - not(feature = "model_tr"), - not(feature = "model_tt") -))] -pub type ModelUI = crate::ui::model_mercury::ModelMercuryFeatures; - -#[cfg(all(feature = "model_tr", not(feature = "model_tt")))] -pub type ModelUI = crate::ui::model_tr::ModelTRFeatures; - -#[cfg(feature = "model_tt")] -pub type ModelUI = crate::ui::model_tt::ModelTTFeatures; diff --git a/core/embed/rust/src/ui/ui_common.rs b/core/embed/rust/src/ui/ui_common.rs new file mode 100644 index 00000000000..8bf6cf54806 --- /dev/null +++ b/core/embed/rust/src/ui/ui_common.rs @@ -0,0 +1,29 @@ +use crate::ui::geometry::Rect; + +pub trait CommonUI { + fn fadein() {} + fn fadeout() {} + fn backlight_on() {} + + fn get_backlight_none() -> u8 { + 0 + } + fn get_backlight_normal() -> u8 { + 0 + } + fn get_backlight_low() -> u8 { + 0 + } + fn get_backlight_dim() -> u8 { + 0 + } + fn get_backlight_max() -> u8 { + 0 + } + + const SCREEN: Rect; + + fn screen_fatal_error(title: &str, msg: &str, footer: &str); + + fn screen_boot_stage_2(); +} diff --git a/core/embed/rust/src/ui/ui_features_fw.rs b/core/embed/rust/src/ui/ui_firmware.rs similarity index 99% rename from core/embed/rust/src/ui/ui_features_fw.rs rename to core/embed/rust/src/ui/ui_firmware.rs index 817b2b80fdf..3c29d736a15 100644 --- a/core/embed/rust/src/ui/ui_features_fw.rs +++ b/core/embed/rust/src/ui/ui_firmware.rs @@ -15,7 +15,7 @@ pub const MAX_CHECKLIST_ITEMS: usize = 3; pub const MAX_WORD_QUIZ_ITEMS: usize = 3; pub const MAX_GROUP_SHARE_LINES: usize = 4; -pub trait UIFeaturesFirmware { +pub trait FirmwareUI { #[allow(clippy::too_many_arguments)] fn confirm_action( title: TString<'static>,