Skip to content

Commit

Permalink
refactor(core): consistent naming of UI layouts
Browse files Browse the repository at this point in the history
- UI layouts name changes:
  - model_tt -> layout_bolt
  - model_tr -> layout_samson
  - model_mercury -> layout_quicksilver
- rust features `model_xyz` freed for different use, now it's
`layout_xyz`
- input_flow function names are based on UI layout and not internal
model name (i.e. quicksilver instead of t3t1)
- directory names and commentary changed accordingly

[no changelog]
  • Loading branch information
obrusvit committed Jan 9, 2025
1 parent 367ba7c commit 7a1305f
Show file tree
Hide file tree
Showing 492 changed files with 1,193 additions and 1,171 deletions.
2 changes: 1 addition & 1 deletion common/protob/messages-debug.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ message DebugLinkDecision {
}

/**
* Structure representing model R button presses
* Structure representing button presses of UI samson
*/
// TODO: probably delete the middle_btn as it is not a physical one
enum DebugPhysicalButton {
Expand Down
12 changes: 6 additions & 6 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@ OPENOCD_TRANSPORT ?= hla_swd
ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),T))
MCU = STM32F4
OPENOCD_TARGET = target/stm32f4x.cfg
MODEL_FEATURE = model_tt
LAYOUT_FEATURE = layout_bolt
else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),R))
MCU = STM32F4
OPENOCD_TARGET = target/stm32f4x.cfg
MODEL_FEATURE = model_tr
LAYOUT_FEATURE = layout_samson
else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),T3T1))
MCU = STM32U5
OPENOCD_TARGET = target/stm32u5x.cfg
MODEL_FEATURE = model_mercury
LAYOUT_FEATURE = layout_quicksilver
else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),T3B1))
MCU = STM32U5
OPENOCD_TARGET = target/stm32u5x.cfg
MODEL_FEATURE = model_tr
LAYOUT_FEATURE = layout_samson
else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),T3W1))
MCU = STM32U5
OPENOCD_TARGET = target/stm32u5x.cfg
MODEL_FEATURE = model_tt
LAYOUT_FEATURE = layout_bolt
else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),DISC1))
MCU = STM32F4
OPENOCD_TARGET = target/stm32f4x.cfg
Expand Down Expand Up @@ -188,7 +188,7 @@ test: ## run unit tests
test_rust: ## run rs unit tests
export BUILD_DIR=$(abspath $(UNIX_BUILD_DIR)) ; \
cd embed/rust ; cargo test $(TESTOPTS) --target=$(RUST_TARGET) \
--no-default-features --features $(MODEL_FEATURE),test \
--no-default-features --features $(LAYOUT_FEATURE),test \
-- --test-threads=1 --nocapture

test_emu: ## run selected device tests from python-trezor
Expand Down
8 changes: 4 additions & 4 deletions core/embed/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ edition = "2021"
build = "build.rs"

[features]
default = ["model_tt"]
default = ["layout_bolt"]
crypto = ["zeroize"]
model_tt = ["jpeg"]
model_tr = []
model_mercury = ["jpeg", "dma2d"]
layout_bolt = ["jpeg"]
layout_samson = []
layout_quicksilver = ["jpeg", "dma2d"]
micropython = []
protobuf = ["micropython"]
ui = []
Expand Down
12 changes: 6 additions & 6 deletions core/embed/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const DEFAULT_BINDGEN_MACROS_COMMON: &[&str] = &[
"-DUSE_RGB_LED",
];

#[cfg(feature = "model_tt")]
#[cfg(feature = "layout_bolt")]
const DEFAULT_BINDGEN_MACROS_T2T1: &[&str] = &[
"-DSTM32F427",
"-DTREZOR_MODEL_T",
Expand All @@ -63,10 +63,10 @@ const DEFAULT_BINDGEN_MACROS_T2T1: &[&str] = &[
"-DDISPLAY_RESY=240",
"-DTREZOR_BOARD=\"T2T1/boards/t2t1-unix.h\"",
];
#[cfg(not(feature = "model_tt"))]
#[cfg(not(feature = "layout_bolt"))]
const DEFAULT_BINDGEN_MACROS_T2T1: &[&str] = &[];

#[cfg(feature = "model_tr")]
#[cfg(feature = "layout_samson")]
const DEFAULT_BINDGEN_MACROS_T2B1: &[&str] = &[
"-DSTM32F427",
"-DTREZOR_MODEL_R",
Expand All @@ -76,10 +76,10 @@ const DEFAULT_BINDGEN_MACROS_T2B1: &[&str] = &[
"-DDISPLAY_RESY=64",
"-DTREZOR_BOARD=\"T2B1/boards/t2b1-unix.h\"",
];
#[cfg(not(feature = "model_tr"))]
#[cfg(not(feature = "layout_samson"))]
const DEFAULT_BINDGEN_MACROS_T2B1: &[&str] = &[];

#[cfg(feature = "model_mercury")]
#[cfg(feature = "layout_quicksilver")]
const DEFAULT_BINDGEN_MACROS_T3T1: &[&str] = &[
"-DSTM32U5",
"-DTREZOR_MODEL_T3T1",
Expand All @@ -89,7 +89,7 @@ const DEFAULT_BINDGEN_MACROS_T3T1: &[&str] = &[
"-DDISPLAY_RESY=240",
"-DTREZOR_BOARD=\"T3T1/boards/t3t1-unix.h\"",
];
#[cfg(not(feature = "model_mercury"))]
#[cfg(not(feature = "layout_quicksilver"))]
const DEFAULT_BINDGEN_MACROS_T3T1: &[&str] = &[];

fn add_bindgen_macros<'a>(clang_args: &mut Vec<&'a str>, envvar: Option<&'a str>) {
Expand Down
2 changes: 1 addition & 1 deletion core/embed/rust/librust_qstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ static void _librust_qstrs(void) {
MP_QSTR_show_progress_coinjoin;
MP_QSTR_show_remaining_shares;
MP_QSTR_show_share_words;
MP_QSTR_show_share_words_mercury;
MP_QSTR_show_share_words_quicksilver;
MP_QSTR_show_simple;
MP_QSTR_show_success;
MP_QSTR_show_wait_text;
Expand Down
20 changes: 10 additions & 10 deletions core/embed/rust/src/ui/api/firmware_micropython.rs
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ extern "C" fn new_show_share_words(n_args: usize, args: *const Obj, kwargs: *mut
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}

extern "C" fn new_show_share_words_mercury(
extern "C" fn new_show_share_words_quicksilver(
n_args: usize,
args: *const Obj,
kwargs: *mut Map,
Expand All @@ -947,7 +947,7 @@ extern "C" fn new_show_share_words_mercury(

let words: Vec<TString, 33> = util::iter_into_vec(words)?;

let layout = ModelUI::show_share_words_mercury(
let layout = ModelUI::show_share_words_quicksilver(
words,
subtitle,
instructions,
Expand Down Expand Up @@ -1280,7 +1280,7 @@ pub static mp_module_trezorui_api: Module = obj_module! {
/// items: Iterable[tuple[int, str | bytes]],
/// ) -> LayoutObj[UiResult]:
/// """Confirm long content with the possibility to go back from any page.
/// Meant to be used with confirm_with_info on model TT and TR."""
/// Meant to be used with confirm_with_info on UI bolt and samson."""
Qstr::MP_QSTR_confirm_more => obj_fn_kw!(0, new_confirm_more).as_obj(),

/// def confirm_properties(
Expand Down Expand Up @@ -1338,7 +1338,7 @@ pub static mp_module_trezorui_api: Module = obj_module! {
/// items: Iterable[tuple[int, str | bytes]],
/// ) -> LayoutObj[UiResult]:
/// """Confirm given items but with third button. Always single page
/// without scrolling. In mercury, the button is placed in
/// without scrolling. In Quicksilver, the button is placed in
/// context menu."""
Qstr::MP_QSTR_confirm_with_info => obj_fn_kw!(0, new_confirm_with_info).as_obj(),

Expand All @@ -1348,7 +1348,7 @@ pub static mp_module_trezorui_api: Module = obj_module! {
/// subtext: str | None,
/// button: str | None,
/// recovery_type: RecoveryType,
/// show_instructions: bool = False, # unused on TT
/// show_instructions: bool = False, # unused on bolt
/// remaining_shares: Iterable[tuple[str, str]] | None = None,
/// ) -> LayoutObj[UiResult]:
/// """Device recovery homescreen."""
Expand Down Expand Up @@ -1378,7 +1378,7 @@ pub static mp_module_trezorui_api: Module = obj_module! {
/// """Confirm the recipient, (optionally) confirm the amount and (optionally) confirm the summary and present a Hold to Sign page."""
Qstr::MP_QSTR_flow_confirm_output => obj_fn_kw!(0, new_flow_confirm_output).as_obj(),

// TODO: supply more arguments for Wipe code setting (mercury)
// TODO: supply more arguments for Wipe code setting (quicksilver)
///
/// def flow_confirm_set_new_pin(
/// *,
Expand Down Expand Up @@ -1625,7 +1625,7 @@ pub static mp_module_trezorui_api: Module = obj_module! {
/// """Show mnemonic for backup."""
Qstr::MP_QSTR_show_share_words => obj_fn_kw!(0, new_show_share_words).as_obj(),

/// def show_share_words_mercury(
/// def show_share_words_quicksilver(
/// *,
/// words: Iterable[str],
/// subtitle: str | None,
Expand All @@ -1635,7 +1635,7 @@ pub static mp_module_trezorui_api: Module = obj_module! {
/// ) -> LayoutObj[UiResult]:
/// """Show mnemonic for wallet backup preceded by an instruction screen and followed by a
/// confirmation screen."""
Qstr::MP_QSTR_show_share_words_mercury => obj_fn_kw!(0, new_show_share_words_mercury).as_obj(),
Qstr::MP_QSTR_show_share_words_quicksilver => obj_fn_kw!(0, new_show_share_words_quicksilver).as_obj(),

/// def show_simple(
/// *,
Expand Down Expand Up @@ -1668,9 +1668,9 @@ pub static mp_module_trezorui_api: Module = obj_module! {
/// value: str = "",
/// description: str = "",
/// allow_cancel: bool = True,
/// danger: bool = False, # unused on TT
/// danger: bool = False, # unused on bolt
/// ) -> LayoutObj[UiResult]:
/// """Warning modal. TT: No buttons shown when `button` is empty string. TR: middle button and centered text."""
/// """Warning modal. bolt: No buttons shown when `button` is empty string. samson: middle button and centered text."""
Qstr::MP_QSTR_show_warning => obj_fn_kw!(0, new_show_warning).as_obj(),

/// def tutorial() -> LayoutObj[UiResult]:
Expand Down
16 changes: 8 additions & 8 deletions core/embed/rust/src/ui/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
//! current feature (Trezor model)
#[cfg(all(
feature = "model_mercury",
not(feature = "model_tr"),
not(feature = "model_tt")
feature = "layout_bolt",
not(feature = "layout_quicksilver"),
not(feature = "layout_samson")
))]
pub use super::model_mercury::constant::*;
#[cfg(all(feature = "model_tr", not(feature = "model_tt")))]
pub use super::model_tr::constant::*;
#[cfg(feature = "model_tt")]
pub use super::model_tt::constant::*;
pub use super::layout_bolt::constant::*;
#[cfg(all(feature = "layout_quicksilver", not(feature = "layout_bolt")))]
pub use super::layout_quicksilver::constant::*;
#[cfg(feature = "layout_samson")]
pub use super::layout_samson::constant::*;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
constant::screen,
display::Icon,
geometry::{Alignment, Insets, Point, Rect},
model_tt::{
layout_bolt::{
component::{Button, ButtonMsg::Clicked},
constant::WIDTH,
theme::bootloader::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
constant::{screen, WIDTH},
display::Icon,
geometry::{Insets, Point, Rect},
model_tt::{
layout_bolt::{
component::{Button, ButtonMsg::Clicked, IconText},
theme::bootloader::{
button_bld, button_bld_menu, text_title, BLD_BG, BUTTON_HEIGHT, CONTENT_PADDING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use super::{
},
FG,
},
UIModelTT,
UIBolt,
};

use crate::ui::{ui_bootloader::BootloaderUI, CommonUI};
Expand Down Expand Up @@ -56,9 +56,9 @@ pub type BootloaderString = String<128>;

const RECONNECT_MESSAGE: &str = "PLEASE RECONNECT\nTHE DEVICE";

const SCREEN: Rect = UIModelTT::SCREEN;
const SCREEN: Rect = UIBolt::SCREEN;

impl UIModelTT {
impl UIBolt {
fn screen_progress(
text: &str,
progress: u16,
Expand Down Expand Up @@ -133,7 +133,7 @@ impl UIModelTT {
}
}

impl BootloaderUI for UIModelTT {
impl BootloaderUI for UIBolt {
fn screen_welcome() {
let mut frame = Welcome::new();
show(&mut frame, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::ui::{
constant::screen,
display::{toif::Toif, Font},
geometry::{Alignment, Alignment2D, Offset, Rect},
model_tt::theme::{
layout_bolt::theme::{
bootloader::{START_URL, WELCOME_COLOR},
GREY_MEDIUM, WHITE,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
constant::screen,
display::{Color, Icon},
geometry::{Alignment2D, Insets, Offset, Point, Rect},
model_tt::{
layout_bolt::{
component::{Button, ButtonMsg::Clicked, ButtonStyleSheet},
constant::WIDTH,
theme::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
},
};

use crate::ui::model_tt::{
use crate::ui::layout_bolt::{
component::{ResultFooter, ResultStyle},
constant::WIDTH,
theme::{FATAL_ERROR_COLOR, ICON_WARNING40, RESULT_FOOTER_START, RESULT_PADDING, WHITE},
Expand All @@ -20,7 +20,7 @@ const TITLE_AREA_START: i16 = 70;
const MESSAGE_AREA_START: i16 = 116;

#[cfg(feature = "bootloader")]
const STYLE: &ResultStyle = &crate::ui::model_tt::theme::bootloader::RESULT_WIPE;
const STYLE: &ResultStyle = &crate::ui::layout_bolt::theme::bootloader::RESULT_WIPE;
#[cfg(not(feature = "bootloader"))]
const STYLE: &ResultStyle = &super::theme::RESULT_ERROR;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
component::{image::Image, Child, Component, Event, EventCtx, Label},
display,
geometry::{Insets, Rect},
model_tt::component::{
layout_bolt::component::{
fido_icons::get_fido_icon_data,
swipe::{Swipe, SwipeDirection},
theme, ScrollBar,
Expand Down
84 changes: 84 additions & 0 deletions core/embed/rust/src/ui/layout_bolt/component/fido_icons.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//! generated from webauthn_icons.rs.mako
//! (by running `make templates` in `core`)
//! do not edit manually!

use crate::strutil::TString;
use crate::ui::util::include_res;


const ICON_APPLE: &[u8] = include_res!("layout_bolt/res/fido/icon_apple.toif");
const ICON_AWS: &[u8] = include_res!("layout_bolt/res/fido/icon_aws.toif");
const ICON_BINANCE: &[u8] = include_res!("layout_bolt/res/fido/icon_binance.toif");
const ICON_BITBUCKET: &[u8] = include_res!("layout_bolt/res/fido/icon_bitbucket.toif");
const ICON_BITFINEX: &[u8] = include_res!("layout_bolt/res/fido/icon_bitfinex.toif");
const ICON_BITWARDEN: &[u8] = include_res!("layout_bolt/res/fido/icon_bitwarden.toif");
const ICON_CLOUDFLARE: &[u8] = include_res!("layout_bolt/res/fido/icon_cloudflare.toif");
const ICON_COINBASE: &[u8] = include_res!("layout_bolt/res/fido/icon_coinbase.toif");
const ICON_DASHLANE: &[u8] = include_res!("layout_bolt/res/fido/icon_dashlane.toif");
const ICON_DROPBOX: &[u8] = include_res!("layout_bolt/res/fido/icon_dropbox.toif");
const ICON_DUO: &[u8] = include_res!("layout_bolt/res/fido/icon_duo.toif");
const ICON_FACEBOOK: &[u8] = include_res!("layout_bolt/res/fido/icon_facebook.toif");
const ICON_FASTMAIL: &[u8] = include_res!("layout_bolt/res/fido/icon_fastmail.toif");
const ICON_FEDORA: &[u8] = include_res!("layout_bolt/res/fido/icon_fedora.toif");
const ICON_GANDI: &[u8] = include_res!("layout_bolt/res/fido/icon_gandi.toif");
const ICON_GEMINI: &[u8] = include_res!("layout_bolt/res/fido/icon_gemini.toif");
const ICON_GITHUB: &[u8] = include_res!("layout_bolt/res/fido/icon_github.toif");
const ICON_GITLAB: &[u8] = include_res!("layout_bolt/res/fido/icon_gitlab.toif");
const ICON_GOOGLE: &[u8] = include_res!("layout_bolt/res/fido/icon_google.toif");
const ICON_INVITY: &[u8] = include_res!("layout_bolt/res/fido/icon_invity.toif");
const ICON_KEEPER: &[u8] = include_res!("layout_bolt/res/fido/icon_keeper.toif");
const ICON_KRAKEN: &[u8] = include_res!("layout_bolt/res/fido/icon_kraken.toif");
const ICON_LOGIN_GOV: &[u8] = include_res!("layout_bolt/res/fido/icon_login.gov.toif");
const ICON_MICROSOFT: &[u8] = include_res!("layout_bolt/res/fido/icon_microsoft.toif");
const ICON_MOJEID: &[u8] = include_res!("layout_bolt/res/fido/icon_mojeid.toif");
const ICON_NAMECHEAP: &[u8] = include_res!("layout_bolt/res/fido/icon_namecheap.toif");
const ICON_PROTON: &[u8] = include_res!("layout_bolt/res/fido/icon_proton.toif");
const ICON_SLUSHPOOL: &[u8] = include_res!("layout_bolt/res/fido/icon_slushpool.toif");
const ICON_STRIPE: &[u8] = include_res!("layout_bolt/res/fido/icon_stripe.toif");
const ICON_TUTANOTA: &[u8] = include_res!("layout_bolt/res/fido/icon_tutanota.toif");
/// Default icon when app does not have its own
const ICON_WEBAUTHN: &[u8] = include_res!("layout_bolt/res/fido/icon_webauthn.toif");

/// Translates icon name into its data.
/// Returns default `ICON_WEBAUTHN` when the icon is not found or name not
/// supplied.
pub fn get_fido_icon_data(icon_name: Option<TString<'static>>) -> &'static [u8] {
if let Some(icon_name) = icon_name {
icon_name.map(|c| match c {
"apple" => ICON_APPLE,
"aws" => ICON_AWS,
"binance" => ICON_BINANCE,
"bitbucket" => ICON_BITBUCKET,
"bitfinex" => ICON_BITFINEX,
"bitwarden" => ICON_BITWARDEN,
"cloudflare" => ICON_CLOUDFLARE,
"coinbase" => ICON_COINBASE,
"dashlane" => ICON_DASHLANE,
"dropbox" => ICON_DROPBOX,
"duo" => ICON_DUO,
"facebook" => ICON_FACEBOOK,
"fastmail" => ICON_FASTMAIL,
"fedora" => ICON_FEDORA,
"gandi" => ICON_GANDI,
"gemini" => ICON_GEMINI,
"github" => ICON_GITHUB,
"gitlab" => ICON_GITLAB,
"google" => ICON_GOOGLE,
"invity" => ICON_INVITY,
"keeper" => ICON_KEEPER,
"kraken" => ICON_KRAKEN,
"login.gov" => ICON_LOGIN_GOV,
"microsoft" => ICON_MICROSOFT,
"mojeid" => ICON_MOJEID,
"namecheap" => ICON_NAMECHEAP,
"proton" => ICON_PROTON,
"slushpool" => ICON_SLUSHPOOL,
"stripe" => ICON_STRIPE,
"tutanota" => ICON_TUTANOTA,
_ => ICON_WEBAUTHN,
})
} else {
ICON_WEBAUTHN
}
}
Loading

0 comments on commit 7a1305f

Please sign in to comment.