diff --git a/core/embed/rust/src/ui/component/label.rs b/core/embed/rust/src/ui/component/label.rs index f7cefc7aea..55c8af56b3 100644 --- a/core/embed/rust/src/ui/component/label.rs +++ b/core/embed/rust/src/ui/component/label.rs @@ -36,8 +36,8 @@ where Self::new(text, Alignment::Center, style) } - pub fn vertically_aligned(mut self, align: Alignment) -> Self { - self.vertical = align; + pub fn vertically_centered(mut self) -> Self { + self.vertical = Alignment::Center; self } diff --git a/core/embed/rust/src/ui/component/text/formatted.rs b/core/embed/rust/src/ui/component/text/formatted.rs index f1a2c4d03f..14a1b7f8f9 100644 --- a/core/embed/rust/src/ui/component/text/formatted.rs +++ b/core/embed/rust/src/ui/component/text/formatted.rs @@ -29,8 +29,8 @@ impl FormattedText { } } - pub fn vertically_aligned(mut self, align: Alignment) -> Self { - self.vertical = align; + pub fn vertically_centered(mut self) -> Self { + self.vertical = Alignment::Center; self } diff --git a/core/embed/rust/src/ui/model_tr/bootloader/intro.rs b/core/embed/rust/src/ui/model_tr/bootloader/intro.rs index 367a1ecfd4..b40aee70ae 100644 --- a/core/embed/rust/src/ui/model_tr/bootloader/intro.rs +++ b/core/embed/rust/src/ui/model_tr/bootloader/intro.rs @@ -1,6 +1,6 @@ use crate::ui::{ component::{Child, Component, Event, EventCtx, Label, Pad}, - geometry::{Alignment, Alignment2D, Rect}, + geometry::{Alignment2D, Rect}, }; use super::{ @@ -38,18 +38,12 @@ impl<'a> Intro<'a> { pub fn new(title: &'a str, content: &'a str) -> Self { Self { bg: Pad::with_background(BLD_BG).with_clear(), - title: Child::new( - Label::new(title, Alignment::Center, TEXT_NORMAL) - .vertically_aligned(Alignment::Center), - ), + title: Child::new(Label::centered(title, TEXT_NORMAL).vertically_centered()), buttons: Child::new(ButtonController::new(ButtonLayout::text_none_text( LEFT_BUTTON_TEXT, RIGHT_BUTTON_TEXT, ))), - text: Child::new( - Label::new(content, Alignment::Start, TEXT_NORMAL) - .vertically_aligned(Alignment::Center), - ), + text: Child::new(Label::left_aligned(content, TEXT_NORMAL).vertically_centered()), } } } 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 c8258da870..0e405926e8 100644 --- a/core/embed/rust/src/ui/model_tr/bootloader/mod.rs +++ b/core/embed/rust/src/ui/model_tr/bootloader/mod.rs @@ -7,7 +7,7 @@ use crate::{ constant::SCREEN, display::{self, Color, Font, Icon}, event::ButtonEvent, - geometry::{Alignment, Alignment::Center, Alignment2D, Offset, Rect}, + geometry::{Alignment2D, Offset, Rect}, util::{from_c_array, from_c_str}, }, }; @@ -137,18 +137,16 @@ extern "C" fn screen_install_confirm( "DOWNGRADE FW" }; - let message = Label::new(version_str.as_str(), Alignment::Start, theme::TEXT_NORMAL) - .vertically_aligned(Center); - let fingerprint = Label::new( + let message = + Label::left_aligned(version_str.as_str(), theme::TEXT_NORMAL).vertically_centered(); + let fingerprint = Label::left_aligned( fingerprint_str, - Alignment::Start, theme::TEXT_NORMAL.with_line_breaking(BreakWordsNoHyphen), ) - .vertically_aligned(Center); + .vertically_centered(); - let alert = (!should_keep_seed).then_some(Label::new( + let alert = (!should_keep_seed).then_some(Label::left_aligned( "Seed will be erased!", - Alignment::Start, theme::TEXT_NORMAL, )); @@ -159,12 +157,8 @@ extern "C" fn screen_install_confirm( #[no_mangle] extern "C" fn screen_wipe_confirm() -> u32 { - let message = Label::new( - "Seed and firmware will be erased!", - Alignment::Start, - theme::TEXT_NORMAL, - ) - .vertically_aligned(Center); + let message = Label::left_aligned("Seed and firmware will be erased!", theme::TEXT_NORMAL) + .vertically_centered(); let mut frame = Confirm::new(BLD_BG, "FACTORY RESET", message, None, "RESET"); @@ -278,15 +272,10 @@ extern "C" fn screen_connect() { #[no_mangle] extern "C" fn screen_wipe_success() { - let title = Label::new("Trezor Reset", Alignment::Center, theme::TEXT_BOLD) - .vertically_aligned(Alignment::Center); + let title = Label::centered("Trezor Reset", theme::TEXT_BOLD).vertically_centered(); - let content = Label::new( - "Reconnect\nthe device", - Alignment::Center, - theme::TEXT_NORMAL, - ) - .vertically_aligned(Alignment::Center); + let content = + Label::centered("Reconnect\nthe device", theme::TEXT_NORMAL).vertically_centered(); let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_SPINNER, title, content, true); show(&mut frame); @@ -294,15 +283,10 @@ extern "C" fn screen_wipe_success() { #[no_mangle] extern "C" fn screen_wipe_fail() { - let title = Label::new("Reset failed", Alignment::Center, theme::TEXT_BOLD) - .vertically_aligned(Alignment::Center); + let title = Label::centered("Reset failed", theme::TEXT_BOLD).vertically_centered(); - let content = Label::new( - "Please reconnect\nthe device", - Alignment::Center, - theme::TEXT_NORMAL, - ) - .vertically_aligned(Alignment::Center); + let content = + Label::centered("Please reconnect\nthe device", theme::TEXT_NORMAL).vertically_centered(); let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_ALERT, title, content, true); show(&mut frame); @@ -325,15 +309,10 @@ extern "C" fn screen_boot_empty(_firmware_present: bool) { #[no_mangle] extern "C" fn screen_install_fail() { - let title = Label::new("Install failed", Alignment::Center, theme::TEXT_BOLD) - .vertically_aligned(Alignment::Center); + let title = Label::centered("Install failed", theme::TEXT_BOLD).vertically_centered(); - let content = Label::new( - "Please reconnect\nthe device", - Alignment::Center, - theme::TEXT_NORMAL, - ) - .vertically_aligned(Alignment::Center); + let content = + Label::centered("Please reconnect\nthe device", theme::TEXT_NORMAL).vertically_centered(); let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_ALERT, title, content, true); show(&mut frame); @@ -347,11 +326,9 @@ extern "C" fn screen_install_success( ) { let msg = unwrap!(unsafe { from_c_str(reboot_msg) }); - let title = Label::new("Firmware installed", Alignment::Center, theme::TEXT_BOLD) - .vertically_aligned(Alignment::Center); + let title = Label::centered("Firmware installed", theme::TEXT_BOLD).vertically_centered(); - let content = Label::new(msg, Alignment::Center, theme::TEXT_NORMAL) - .vertically_aligned(Alignment::Center); + let content = Label::centered(msg, theme::TEXT_NORMAL).vertically_centered(); let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_SPINNER, title, content, complete_draw); show(&mut frame); diff --git a/core/embed/rust/src/ui/model_tr/component/error.rs b/core/embed/rust/src/ui/model_tr/component/error.rs index e3cfe08700..43cc3857bb 100644 --- a/core/embed/rust/src/ui/model_tr/component/error.rs +++ b/core/embed/rust/src/ui/model_tr/component/error.rs @@ -2,7 +2,7 @@ use crate::ui::{ component::{Child, Component, Event, EventCtx, Label, Never, Pad}, constant::screen, display, - geometry::{Alignment::Center, Alignment2D, Offset, Point, Rect}, + geometry::{Alignment2D, Offset, Point, Rect}, }; use super::super::{ @@ -25,9 +25,9 @@ pub struct ErrorScreen { impl> ErrorScreen { pub fn new(title: T, message: T, footer: T) -> Self { - let title = Label::new(title, Center, theme::TEXT_BOLD); - let message = Label::new(message, Center, theme::TEXT_NORMAL).vertically_aligned(Center); - let footer = Label::new(footer, Center, theme::TEXT_NORMAL).vertically_aligned(Center); + let title = Label::centered(title, theme::TEXT_BOLD); + let message = Label::centered(message, theme::TEXT_NORMAL).vertically_centered(); + let footer = Label::centered(footer, theme::TEXT_NORMAL).vertically_centered(); Self { bg: Pad::with_background(BG).with_clear(), 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 1b571e8742..fdd2bfea7f 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 @@ -8,7 +8,7 @@ use crate::{ }, constant::screen, display::toif::Icon, - geometry::{Alignment, Insets, LinearPlacement, Rect}, + geometry::{Insets, LinearPlacement, Rect}, }, }; @@ -65,7 +65,7 @@ where area: Rect::zero(), pad, result_anim: Child::new(ResultAnim::new(icon)), - headline: headline.map(|a| Label::new(a, Alignment::Center, theme::TEXT_BOLD)), + headline: headline.map(|a| Label::centered(a, theme::TEXT_BOLD)), text: Child::new(p1), buttons, autoclose: false, diff --git a/core/embed/rust/src/ui/model_tr/layout.rs b/core/embed/rust/src/ui/model_tr/layout.rs index e5f61a4e43..646c1c8c98 100644 --- a/core/embed/rust/src/ui/model_tr/layout.rs +++ b/core/embed/rust/src/ui/model_tr/layout.rs @@ -549,8 +549,7 @@ extern "C" fn new_confirm_output(n_args: usize, args: *const Obj, kwargs: *mut M ops = ops.text_normal(address_label.clone()).newline(); } ops = ops.text_mono(address.clone()); - let formatted = - FormattedText::new(ops).vertically_aligned(geometry::Alignment::Center); + let formatted = FormattedText::new(ops).vertically_centered(); Page::new(btn_layout, btn_actions, formatted).with_title(address_title.clone()) } 1 => { @@ -558,8 +557,7 @@ extern "C" fn new_confirm_output(n_args: usize, args: *const Obj, kwargs: *mut M let btn_layout = ButtonLayout::up_arrow_none_text("CONFIRM".into()); let btn_actions = ButtonActions::prev_none_confirm(); let ops = OpTextLayout::new(theme::TEXT_MONO).text_mono(amount.clone()); - let formatted = - FormattedText::new(ops).vertically_aligned(geometry::Alignment::Center); + let formatted = FormattedText::new(ops).vertically_centered(); Page::new(btn_layout, btn_actions, formatted).with_title(amount_title.clone()) } _ => unreachable!(), diff --git a/core/embed/rust/src/ui/model_tt/bootloader/confirm.rs b/core/embed/rust/src/ui/model_tt/bootloader/confirm.rs index 37a1805b9c..0f935dff11 100644 --- a/core/embed/rust/src/ui/model_tt/bootloader/confirm.rs +++ b/core/embed/rust/src/ui/model_tt/bootloader/confirm.rs @@ -3,7 +3,7 @@ use crate::ui::{ constant, constant::screen, display::{Color, Icon}, - geometry::{Alignment, Alignment2D, Insets, Offset, Point, Rect}, + geometry::{Alignment2D, Insets, Offset, Point, Rect}, model_tt::{ bootloader::theme::{ button_bld_menu, BUTTON_AREA_START, BUTTON_HEIGHT, CONTENT_PADDING, CORNER_BUTTON_AREA, @@ -69,19 +69,13 @@ impl<'a> Confirm<'a> { content_pad: Pad::with_background(bg_color), bg_color, title, - message: Child::new(message.vertically_aligned(Alignment::Center)), - alert: alert.map(|alert| Child::new(alert.vertically_aligned(Alignment::Center))), + message: Child::new(message.vertically_centered()), + alert: alert.map(|alert| Child::new(alert.vertically_centered())), left_button: Child::new(left_button), right_button: Child::new(right_button), info: info.map(|(title, text)| ConfirmInfo { - title: Child::new( - Label::new(title, Alignment::Start, TEXT_TITLE) - .vertically_aligned(Alignment::Center), - ), - text: Child::new( - Label::new(text, Alignment::Start, TEXT_FINGERPRINT) - .vertically_aligned(Alignment::Center), - ), + title: Child::new(Label::left_aligned(title, TEXT_TITLE).vertically_centered()), + text: Child::new(Label::left_aligned(text, TEXT_FINGERPRINT).vertically_centered()), info_button: Child::new( Button::with_icon(Icon::new(INFO32)) .styled(button_bld_menu()) diff --git a/core/embed/rust/src/ui/model_tt/bootloader/intro.rs b/core/embed/rust/src/ui/model_tt/bootloader/intro.rs index 04dc36c4c6..851a3bfde4 100644 --- a/core/embed/rust/src/ui/model_tt/bootloader/intro.rs +++ b/core/embed/rust/src/ui/model_tt/bootloader/intro.rs @@ -2,7 +2,7 @@ use crate::ui::{ component::{Child, Component, Event, EventCtx, Label, Pad}, constant::screen, display::Icon, - geometry::{Alignment, Insets, Point, Rect}, + geometry::{Insets, Point, Rect}, model_tt::{ bootloader::theme::{ button_bld, button_bld_menu, BLD_BG, BUTTON_AREA_START, BUTTON_HEIGHT, CONTENT_PADDING, @@ -32,20 +32,14 @@ impl<'a> Intro<'a> { pub fn new(title: &'a str, content: &'a str) -> Self { Self { bg: Pad::with_background(BLD_BG).with_clear(), - title: Child::new( - Label::new(title, Alignment::Start, TEXT_TITLE) - .vertically_aligned(Alignment::Center), - ), + title: Child::new(Label::left_aligned(title, TEXT_TITLE).vertically_centered()), menu: Child::new( Button::with_icon(Icon::new(MENU32)) .styled(button_bld_menu()) .with_expanded_touch_area(Insets::uniform(13)), ), host: Child::new(Button::with_text("INSTALL FIRMWARE").styled(button_bld())), - text: Child::new( - Label::new(content, Alignment::Start, TEXT_NORMAL) - .vertically_aligned(Alignment::Center), - ), + text: Child::new(Label::left_aligned(content, TEXT_NORMAL).vertically_centered()), } } } diff --git a/core/embed/rust/src/ui/model_tt/bootloader/menu.rs b/core/embed/rust/src/ui/model_tt/bootloader/menu.rs index 495d50dbe3..4b0ca8e337 100644 --- a/core/embed/rust/src/ui/model_tt/bootloader/menu.rs +++ b/core/embed/rust/src/ui/model_tt/bootloader/menu.rs @@ -2,7 +2,7 @@ use crate::ui::{ component::{Child, Component, Event, EventCtx, Label, Pad}, constant::{screen, WIDTH}, display::Icon, - geometry::{Alignment, Insets, Point, Rect}, + geometry::{Insets, Point, Rect}, model_tt::{ bootloader::theme::{ button_bld, button_bld_menu, BLD_BG, BUTTON_HEIGHT, CONTENT_PADDING, @@ -39,10 +39,7 @@ impl Menu { let mut instance = Self { bg: Pad::with_background(BLD_BG), - title: Child::new( - Label::new("BOOTLOADER", Alignment::Start, TEXT_TITLE) - .vertically_aligned(Alignment::Center), - ), + title: Child::new(Label::left_aligned("BOOTLOADER", TEXT_TITLE).vertically_centered()), close: Child::new( Button::with_icon(Icon::new(X32)) .styled(button_bld_menu()) 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 a5bef7d697..11721ac29f 100644 --- a/core/embed/rust/src/ui/model_tt/bootloader/mod.rs +++ b/core/embed/rust/src/ui/model_tt/bootloader/mod.rs @@ -6,7 +6,7 @@ use crate::{ constant::{screen, HEIGHT}, display::{self, Color, Font, Icon}, event::TouchEvent, - geometry::{Alignment, Alignment2D, Point}, + geometry::{Alignment2D, Point}, model_tt::{ bootloader::{ confirm::ConfirmTitle, @@ -162,12 +162,10 @@ extern "C" fn screen_install_confirm( } else { "DOWNGRADE FW" }; - let title = Label::new(title_str, Alignment::Start, theme::TEXT_BOLD) - .vertically_aligned(Alignment::Center); - let msg = Label::new(version_str.as_ref(), Alignment::Start, theme::TEXT_NORMAL); - let alert = (!should_keep_seed).then_some(Label::new( + let title = Label::left_aligned(title_str, theme::TEXT_BOLD).vertically_centered(); + let msg = Label::left_aligned(version_str.as_ref(), theme::TEXT_NORMAL); + let alert = (!should_keep_seed).then_some(Label::left_aligned( "SEED WILL BE ERASED!", - Alignment::Start, theme::TEXT_BOLD, )); @@ -198,16 +196,11 @@ extern "C" fn screen_install_confirm( extern "C" fn screen_wipe_confirm() -> u32 { let icon = Icon::new(FIRE40); - let msg = Label::new( + let msg = Label::centered( "Are you sure you want to factory reset the device?", - Alignment::Center, TEXT_WIPE_NORMAL, ); - let alert = Label::new( - "SEED AND FIRMWARE\nWILL BE ERASED!", - Alignment::Center, - TEXT_WIPE_BOLD, - ); + let alert = Label::centered("SEED AND FIRMWARE\nWILL BE ERASED!", TEXT_WIPE_BOLD); let right = Button::with_text("RESET").styled(button_wipe_confirm()); let left = Button::with_text("CANCEL").styled(button_wipe_cancel()); diff --git a/core/embed/rust/src/ui/model_tt/component/coinjoin_progress.rs b/core/embed/rust/src/ui/model_tt/component/coinjoin_progress.rs index 7e3e973e69..1bde6d975e 100644 --- a/core/embed/rust/src/ui/model_tt/component/coinjoin_progress.rs +++ b/core/embed/rust/src/ui/model_tt/component/coinjoin_progress.rs @@ -8,7 +8,7 @@ use crate::{ Split, }, display::loader::{loader_circular_uncompress, LoaderDimensions}, - geometry::{Alignment, Insets, Rect}, + geometry::{Insets, Rect}, util::animation_disabled, }, }; @@ -43,8 +43,7 @@ where T: AsRef, { let style = theme::label_coinjoin_progress(); - let label = Label::centered("DO NOT DISCONNECT YOUR TREZOR!", style) - .vertically_aligned(Alignment::Center); + let label = Label::centered("DO NOT DISCONNECT YOUR TREZOR!", style).vertically_centered(); let bg = painter::rect_painter(style.background_color, theme::BG); let inner = (bg, label); CoinJoinProgress::with_background(text, inner, indeterminate) diff --git a/core/embed/rust/src/ui/model_tt/component/error.rs b/core/embed/rust/src/ui/model_tt/component/error.rs index 47d350ab55..7867c831e8 100644 --- a/core/embed/rust/src/ui/model_tt/component/error.rs +++ b/core/embed/rust/src/ui/model_tt/component/error.rs @@ -1,7 +1,7 @@ use crate::ui::{ component::{Child, Component, Event, EventCtx, Label, Never, Pad}, constant::screen, - geometry::{Alignment::Center, Alignment2D, Point, Rect}, + geometry::{Alignment2D, Point, Rect}, }; use crate::ui::model_tt::{ @@ -28,8 +28,8 @@ pub struct ErrorScreen<'a, T> { impl> ErrorScreen<'_, T> { pub fn new(title: T, message: T, footer: T) -> Self { - let title = Label::new(title, Center, STYLE.title_style()); - let message = Label::new(message, Center, STYLE.message_style()); + let title = Label::centered(title, STYLE.title_style()); + let message = Label::centered(message, STYLE.message_style()); let footer = ResultFooter::new(footer, STYLE); Self { diff --git a/core/embed/rust/src/ui/model_tt/component/fido.rs b/core/embed/rust/src/ui/model_tt/component/fido.rs index c7abce4cf9..50ce240c01 100644 --- a/core/embed/rust/src/ui/model_tt/component/fido.rs +++ b/core/embed/rust/src/ui/model_tt/component/fido.rs @@ -1,7 +1,7 @@ use crate::ui::{ component::{image::Image, Child, Component, Event, EventCtx, Label}, display, - geometry::{Alignment, Insets, Rect}, + geometry::{Insets, Rect}, model_tt::component::{ fido_icons::get_fido_icon_data, swipe::{Swipe, SwipeDirection}, @@ -60,8 +60,8 @@ where page_swipe.allow_left = scrollbar.has_next_page(); Self { - app_name: Label::new(app_name, Alignment::Center, theme::TEXT_DEMIBOLD), - account_name: Label::new("".into(), Alignment::Center, theme::TEXT_DEMIBOLD), + app_name: Label::centered(app_name, theme::TEXT_DEMIBOLD), + account_name: Label::centered("".into(), theme::TEXT_DEMIBOLD), page_swipe, icon: Child::new(Image::new(icon_data)), get_account, diff --git a/core/embed/rust/src/ui/model_tt/component/result.rs b/core/embed/rust/src/ui/model_tt/component/result.rs index 18ec4c7b97..abab957901 100644 --- a/core/embed/rust/src/ui/model_tt/component/result.rs +++ b/core/embed/rust/src/ui/model_tt/component/result.rs @@ -4,7 +4,7 @@ use crate::{ component::{text::TextStyle, Child, Component, Event, EventCtx, Label, Never, Pad}, constant::screen, display::{self, Color, Font, Icon}, - geometry::{Alignment::Center, Alignment2D, Insets, Offset, Point, Rect}, + geometry::{Alignment2D, Insets, Offset, Point, Rect}, model_tt::theme::FG, }, }; @@ -51,7 +51,7 @@ impl<'a, T: AsRef> ResultFooter<'a, T> { pub fn new(text: T, style: &'a ResultStyle) -> Self { Self { style, - text: Label::new(text, Center, style.title_style()).vertically_aligned(Center), + text: Label::centered(text, style.title_style()).vertically_centered(), area: Rect::zero(), } } @@ -117,7 +117,7 @@ impl<'a, T: StringType> ResultScreen<'a, T> { footer_pad: Pad::with_background(style.bg_color), style, icon, - message: Child::new(Label::new(message, Center, style.message_style())), + message: Child::new(Label::centered(message, style.message_style())), footer: Child::new(ResultFooter::new(footer, style)), }; diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index 98ee4b2da8..009401d6e2 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -486,7 +486,7 @@ extern "C" fn new_confirm_emphasized(n_args: usize, args: *const Obj, kwargs: *m theme::label_title(), title, SwipePage::new( - FormattedText::new(ops).vertically_aligned(geometry::Alignment::Center), + FormattedText::new(ops).vertically_centered(), buttons, theme::BG, ),