feat(core/caesar): new menu nav in bootloader
What changed, and why it matters
This commit is a routine user-interface redesign for the bootloader on certain Trezor hardware wallets. It changes how buttons are labeled and how users navigate confirmation menus (for example, moving the fingerprint info screen into a context menu and requiring both buttons for factory reset). There is no indication of a security bug being fixed or introduced.
No security action required; treat as normal UI/UX refactor. Standard functional review is sufficient.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors the Caesar-layout bootloader UI: it deletes the old bl_confirm component, adds a new bootloader/confirm.rs with a context-menu-based info screen, swaps button positions/labels in intro.rs and connect.rs, replaces the icon-based menu carousel with a text-based Menu<N> using ChoicePage, and updates ButtonLayout helpers accordingly. The changelog fragment describes this as a navigation change for T2B1/T3B1 devices. No cryptographic, parsing, or trust-boundary changes are present.
Changed components
core/embed/rust/src/ui/layout_caesar/bootloader/confirm.rscore/embed/rust/src/ui/layout_caesar/bootloader/connect.rscore/embed/rust/src/ui/layout_caesar/bootloader/intro.rscore/embed/rust/src/ui/layout_caesar/bootloader/menu.rscore/embed/rust/src/ui/layout_caesar/bootloader/mod.rscore/embed/rust/src/ui/layout_caesar/component/bl_confirm.rscore/embed/rust/src/ui/layout_caesar/component/button.rscore/embed/rust/src/ui/layout_caesar/component/input_methods/simple_choice.rscore/embed/rust/src/ui/layout_caesar/component/mod.rscore/embed/rust/src/ui/layout_caesar/theme/bootloader.rsInspect captured patch +298 / −370
### core/embed/projects/bootloader/.changelog.d/7694.changed
@@ -0,0 +1 @@
+[T2B1,T3B1] New navigation: the left button opens the menu (or cancels when there is none), the firmware fingerprint is shown from the installation menu, and factory reset is confirmed with both buttons.
### core/embed/rust/src/ui/layout_caesar/bootloader/confirm.rs
@@ -0,0 +1,208 @@
+use super::super::component::{ButtonController, ButtonControllerMsg, ButtonLayout, ButtonPos};
+use super::super::theme::{BUTTON_HEIGHT, TEXT_BOLD, TITLE_AREA_HEIGHT};
+use super::menu::{Menu, MenuSelection};
+use crate::strutil::TString;
+use crate::ui::component::{Component, ComponentExt, Event, EventCtx, Label, Pad};
+use crate::ui::display::Color;
+use crate::ui::geometry::Rect;
+use crate::ui::shape::Renderer;
+
+const ALERT_AREA_START: i16 = 39;
+
+#[derive(Copy, Clone)]
+pub enum ConfirmMsg {
+ Cancel = 1,
+ Confirm = 2,
+}
+
+/// Context menu with the info item and cancel.
+type ConfirmMenu = Menu<2>;
+const MENU_INFO: usize = 0;
+
+#[derive(Copy, Clone, PartialEq)]
+enum ConfirmState {
+ Main,
+ /// Context menu opened by the left button
+ Menu,
+ /// Info screen opened from the context menu
+ Info,
+}
+
+pub struct Confirm<'a> {
+ bg: Pad,
+ title: Label<'a>,
+ message: Label<'a>,
+ alert: Option<Label<'a>>,
+ /// Name of the context menu item opening the info screen
+ info_name: Option<&'static str>,
+ info_title: Option<Label<'a>>,
+ info_text: Option<Label<'a>>,
+ menu: Option<ConfirmMenu>,
+ button_text: TString<'static>,
+ buttons: ButtonController,
+ state: ConfirmState,
+}
+
+impl<'a> Confirm<'a> {
+ /// Confirmation with a cancel cross on the left and both buttons
+ /// confirming.
+ pub fn new(
+ bg_color: Color,
+ title: TString<'a>,
+ message: Label<'a>,
+ alert: Option<Label<'a>>,
+ button_text: TString<'static>,
+ ) -> Self {
+ Self {
+ bg: Pad::with_background(bg_color).with_clear(),
+ title: Label::left_aligned(title, TEXT_BOLD),
+ message,
+ alert,
+ info_name: None,
+ info_title: None,
+ info_text: None,
+ menu: None,
+ button_text,
+ buttons: ButtonController::new(ButtonLayout::cancel_armed_none(button_text)),
+ state: ConfirmState::Main,
+ }
+ }
+
+ /// Adding a context menu on the left with an info screen and cancel. The
+ /// right button confirms.
+ pub fn with_menu(
+ mut self,
+ info_name: &'static str,
+ info_title: TString<'a>,
+ info_text: Label<'a>,
+ ) -> Self {
+ self.info_name = Some(info_name);
+ self.info_title = Some(Label::left_aligned(info_title, TEXT_BOLD));
+ self.info_text = Some(info_text);
+ self.buttons = ButtonController::new(self.get_button_layout());
+ self
+ }
+
+ fn new_menu(info_name: &'static str) -> ConfirmMenu {
+ Menu::new([info_name, "Cancel"])
+ }
+
+ fn get_button_layout(&self) -> ButtonLayout {
+ match self.state {
+ ConfirmState::Main if self.info_name.is_some() => {
+ ButtonLayout::menu_none_text(self.button_text)
+ }
+ ConfirmState::Main => ButtonLayout::cancel_armed_none(self.button_text),
+ // The menu has its own buttons
+ ConfirmState::Menu | ConfirmState::Info => ButtonLayout::cancel_none_none(),
+ }
+ }
+
+ fn set_state(&mut self, ctx: &mut EventCtx, state: ConfirmState) {
+ self.state = state;
+ self.bg.clear();
+ self.buttons.set(self.get_button_layout());
+ self.request_complete_repaint(ctx);
+ }
+
+ fn event_main(&mut self, ctx: &mut EventCtx, event: Event) -> Option<ConfirmMsg> {
+ match self.buttons.event(ctx, event) {
+ Some(ButtonControllerMsg::Triggered(ButtonPos::Left, _)) => {
+ let Some(info_name) = self.info_name else {
+ return Some(ConfirmMsg::Cancel);
+ };
+ // The menu always opens on its first item
+ let mut menu = Self::new_menu(info_name);
+ menu.place(self.bg.area);
+ self.menu = Some(menu);
+ self.set_state(ctx, ConfirmState::Menu);
+ None
+ }
+ Some(ButtonControllerMsg::Triggered(ButtonPos::Middle | ButtonPos::Right, _)) => {
+ Some(ConfirmMsg::Confirm)
+ }
+ _ => None,
+ }
+ }
+}
+
+impl Component for Confirm<'_> {
+ type Msg = ConfirmMsg;
+
+ fn place(&mut self, bounds: Rect) -> Rect {
+ self.bg.place(bounds);
+
+ // Divide the screen into areas
+ let (title_area, minus_title) = bounds.split_top(TITLE_AREA_HEIGHT);
+ let (between_title_and_buttons, button_area) = minus_title.split_bottom(BUTTON_HEIGHT);
+
+ // Texts for the main screen
+ let (message_area, alert_area) = if self.alert.is_some() {
+ between_title_and_buttons.split_top(ALERT_AREA_START - TITLE_AREA_HEIGHT)
+ } else {
+ (between_title_and_buttons, Rect::zero())
+ };
+ self.title.place(title_area);
+ self.message.place(message_area);
+ self.alert.place(alert_area);
+
+ // Text for the info screen
+ self.info_title.place(title_area);
+ self.info_text.place(between_title_and_buttons);
+
+ self.menu.place(bounds);
+ self.buttons.place(button_area);
+
+ bounds
+ }
+
+ fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option<Self::Msg> {
+ match self.state {
+ ConfirmState::Main => self.event_main(ctx, event),
+ ConfirmState::Menu => {
+ match self.menu.event(ctx, event) {
+ Some(MenuSelection::Close) => self.set_state(ctx, ConfirmState::Main),
+ Some(MenuSelection::Item(MENU_INFO)) => self.set_state(ctx, ConfirmState::Info),
+ Some(MenuSelection::Item(_)) => return Some(ConfirmMsg::Cancel),
+ None => {}
+ }
+ None
+ }
+ ConfirmState::Info => {
+ // Going back to the menu with the cross
+ if let Some(ButtonControllerMsg::Triggered(ButtonPos::Left, _)) =
+ self.buttons.event(ctx, event)
+ {
+ self.set_state(ctx, ConfirmState::Menu);
+ }
+ None
+ }
+ }
+ }
+
+ fn render<'s>(&'s self, target: &mut impl Renderer<'s>) {
+ self.bg.render(target);
+
+ match self.state {
+ ConfirmState::Main => {
+ self.title.render(target);
+ self.message.render(target);
+ self.alert.render(target);
+ self.buttons.render(target);
+ }
+ ConfirmState::Menu => self.menu.render(target),
+ ConfirmState::Info => {
+ self.info_title.render(target);
+ self.info_text.render(target);
+ self.buttons.render(target);
+ }
+ }
+ }
+}
+
+#[cfg(feature = "ui_debug")]
+impl crate::trace::Trace for Confirm<'_> {
+ fn trace(&self, t: &mut dyn crate::trace::Tracer) {
+ t.component("BlConfirm");
+ }
+}
### core/embed/rust/src/ui/layout_caesar/bootloader/connect.rs
@@ -31,7 +31,7 @@ impl Connect {
bg: Pad::with_background(bg),
message: message.into(),
font,
- buttons: ButtonController::new(ButtonLayout::none_none_text("Cancel".into())),
+ buttons: ButtonController::new(ButtonLayout::cancel_none_none()),
};
instance.bg.clear();
@@ -55,7 +55,7 @@ impl Component for Connect {
}
fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option<Self::Msg> {
- if let Some(ButtonControllerMsg::Triggered(ButtonPos::Right, false)) =
+ if let Some(ButtonControllerMsg::Triggered(ButtonPos::Left, _)) =
self.buttons.event(ctx, event)
{
return Some(ConnectMsg::Cancel);
### core/embed/rust/src/ui/layout_caesar/bootloader/intro.rs
@@ -9,8 +9,7 @@ use crate::ui::layout::simplified::ReturnToC;
use crate::ui::shape;
use crate::ui::shape::Renderer;
-const LEFT_BUTTON_TEXT: &str = "Init connection";
-const RIGHT_BUTTON_TEXT: &str = "MENU";
+const RIGHT_BUTTON_TEXT: &str = "CONNECT";
#[repr(u32)]
#[derive(Copy, Clone)]
@@ -37,8 +36,7 @@ impl<'a> Intro<'a> {
Self {
bg: Pad::with_background(BLD_BG).with_clear(),
title: Child::new(Label::centered(title, TEXT_NORMAL).vertically_centered()),
- buttons: Child::new(ButtonController::new(ButtonLayout::text_none_text(
- LEFT_BUTTON_TEXT.into(),
+ buttons: Child::new(ButtonController::new(ButtonLayout::menu_none_text(
RIGHT_BUTTON_TEXT.into(),
))),
text: Child::new(Label::left_aligned(content, TEXT_NORMAL).vertically_centered()),
@@ -79,10 +77,10 @@ impl<'a> Component for Intro<'a> {
let msg = self.buttons.event(ctx, event);
if let Some(Triggered(ButtonPos::Left, _)) = msg {
- return Some(Self::Msg::InstallFirmware);
+ return Some(Self::Msg::GoToMenu);
};
if let Some(Triggered(ButtonPos::Right, _)) = msg {
- return Some(Self::Msg::GoToMenu);
+ return Some(Self::Msg::InstallFirmware);
};
None
}
### core/embed/rust/src/ui/layout_caesar/bootloader/menu.rs
@@ -1,14 +1,8 @@
-use super::super::component::{ButtonLayout, Choice, ChoiceFactory, ChoiceMsg, ChoicePage};
-use super::super::fonts;
-use super::super::theme::bootloader::{BLD_BG, BLD_FG, ICON_EXIT, ICON_REDO, ICON_TRASH};
-#[cfg(feature = "ui_debug")]
-use crate::trace::{Trace, Tracer};
-use crate::ui::component::{Child, Component, Event, EventCtx, Pad};
-use crate::ui::constant::screen;
-use crate::ui::display::Icon;
-use crate::ui::geometry::{Alignment, Alignment2D, Offset, Point, Rect};
+use super::super::component::{ButtonLayout, ChoiceFactory, ChoiceItem, ChoiceMsg, ChoicePage};
+use super::super::theme::bootloader::BLD_BG;
+use crate::ui::component::{Component, Event, EventCtx, Pad};
+use crate::ui::geometry::Rect;
use crate::ui::layout::simplified::ReturnToC;
-use crate::ui::shape;
use crate::ui::shape::Renderer;
#[repr(u32)]
@@ -24,115 +18,69 @@ impl ReturnToC for MenuMsg {
}
}
-const CHOICE_LENGTH: usize = 3;
-const SCREEN_CENTER: Point = screen().center();
-
-pub struct MenuChoice {
- first_line: &'static str,
- second_line: &'static str,
- icon: Icon,
-}
-
-impl MenuChoice {
- pub fn new(first_line: &'static str, second_line: &'static str, icon: Icon) -> Self {
- Self {
- first_line,
- second_line,
- icon,
- }
+/// Items of the bootloader menu, see `MenuMsg::from_selection`.
+pub const MENU_ITEMS: [&str; 2] = ["Reboot", "Factory reset"];
+
+impl MenuMsg {
+ pub fn from_selection(selection: MenuSelection) -> Option<Self> {
+ Some(match selection {
+ MenuSelection::Close => Self::Close,
+ MenuSelection::Item(0) => Self::Reboot,
+ MenuSelection::Item(1) => Self::FactoryReset,
+ // Unknown items do nothing irreversible
+ MenuSelection::Item(_) => Self::Close,
+ })
}
}
-impl Choice for MenuChoice {
- fn render_center<'s>(&self, target: &mut impl Renderer<'s>, _area: Rect, _inverse: bool) {
- // Icon on top and two lines of text below
- shape::ToifImage::new(SCREEN_CENTER + Offset::y(-20), self.icon.toif)
- .with_align(Alignment2D::CENTER)
- .with_fg(BLD_FG)
- .render(target);
-
- shape::Text::new(SCREEN_CENTER, self.first_line, fonts::FONT_NORMAL)
- .with_align(Alignment::Center)
- .with_fg(BLD_FG)
- .render(target);
-
- shape::Text::new(
- SCREEN_CENTER + Offset::y(10),
- self.second_line,
- fonts::FONT_NORMAL,
- )
- .with_align(Alignment::Center)
- .with_fg(BLD_FG)
- .render(target);
- }
-
- fn btn_layout(&self) -> ButtonLayout {
- ButtonLayout::arrow_armed_arrow("SELECT".into())
- }
+#[derive(Copy, Clone)]
+pub enum MenuSelection {
+ /// The menu was closed by the cross on its first item
+ Close,
+ /// Index of the selected item
+ Item(usize),
}
-#[cfg(feature = "ui_debug")]
-impl Trace for MenuChoice {
- fn trace(&self, t: &mut dyn Tracer) {
- t.component("MenuChoice");
- }
+pub struct MenuChoiceFactory<const N: usize> {
+ items: [&'static str; N],
}
-pub struct MenuChoiceFactory {}
-
-impl MenuChoiceFactory {
- const CHOICES: [(&'static str, &'static str, Icon); CHOICE_LENGTH] = [
- ("Factory", "reset", ICON_TRASH),
- ("Exit", "menu", ICON_EXIT),
- ("Reboot", "Trezor", ICON_REDO),
- ];
-
- pub fn new() -> Self {
- Self {}
- }
-}
-
-impl ChoiceFactory for MenuChoiceFactory {
- type Action = MenuMsg;
- type Item = MenuChoice;
+impl<const N: usize> ChoiceFactory for MenuChoiceFactory<N> {
+ type Action = usize;
+ type Item = ChoiceItem;
fn count(&self) -> usize {
- CHOICE_LENGTH
+ N
}
fn get(&self, choice_index: usize) -> (Self::Item, Self::Action) {
- let choice_item = MenuChoice::new(
- Self::CHOICES[choice_index].0,
- Self::CHOICES[choice_index].1,
- Self::CHOICES[choice_index].2,
- );
- let action = match choice_index {
- 0 => MenuMsg::FactoryReset,
- 1 => MenuMsg::Close,
- 2 => MenuMsg::Reboot,
- _ => unreachable!(),
- };
- (choice_item, action)
+ let btn_layout = ButtonLayout::menu_item(choice_index == 0, choice_index == N - 1);
+ (
+ ChoiceItem::new(self.items[choice_index], btn_layout),
+ choice_index,
+ )
}
}
-pub struct Menu {
+/// Context menu carousel, the same as the firmware `select_menu`. The cross on
+/// the first item closes the menu.
+pub struct Menu<const N: usize> {
pad: Pad,
- choice_page: Child<ChoicePage<MenuChoiceFactory, MenuMsg>>,
+ choice_page: ChoicePage<MenuChoiceFactory<N>, usize>,
}
-impl Menu {
- pub fn new() -> Self {
- let choices = MenuChoiceFactory::new();
+impl<const N: usize> Menu<N> {
+ pub fn new(items: [&'static str; N]) -> Self {
+ let choices = MenuChoiceFactory { items };
Self {
pad: Pad::with_background(BLD_BG).with_clear(),
- choice_page: Child::new(ChoicePage::new(choices).with_only_one_item(true)),
+ choice_page: ChoicePage::new(choices).with_incomplete(true),
}
}
}
-impl Component for Menu {
- type Msg = MenuMsg;
+impl<const N: usize> Component for Menu<N> {
+ type Msg = MenuSelection;
fn place(&mut self, bounds: Rect) -> Rect {
self.pad.place(bounds);
@@ -142,8 +90,9 @@ impl Component for Menu {
fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option<Self::Msg> {
match self.choice_page.event(ctx, event) {
- Some(ChoiceMsg::Choice { item, .. }) => Some(item),
- _ => None,
+ Some(ChoiceMsg::Choice { item, .. }) => Some(MenuSelection::Item(item)),
+ Some(ChoiceMsg::Cancel) => Some(MenuSelection::Close),
+ None => None,
}
}
### core/embed/rust/src/ui/layout_caesar/bootloader/mod.rs
@@ -1,6 +1,7 @@
use heapless::String;
use ufmt::uwrite;
+mod confirm;
mod intro;
mod menu;
mod welcome;
@@ -9,18 +10,18 @@ mod connect;
use sys::time;
+use self::confirm::{Confirm, ConfirmMsg};
use self::connect::Connect;
use self::intro::Intro;
-use self::menu::Menu;
+use self::menu::{Menu, MenuMsg, MENU_ITEMS};
use self::welcome::Welcome;
-use super::component::bl_confirm::{Confirm, ConfirmMsg};
use super::component::{ResultScreen, WelcomeScreen};
use super::theme::bootloader::{BLD_BG, BLD_FG, ICON_ALERT, ICON_SPINNER, ICON_SUCCESS};
use super::theme::{ICON_ARM_LEFT, ICON_ARM_RIGHT, TEXT_BOLD, TEXT_NORMAL};
use super::{cshape, fonts, UICaesar};
use crate::bootloader::run;
-use crate::ui::component::Label;
use crate::ui::component::LineBreaking::BreakWordsNoHyphen;
+use crate::ui::component::{ComponentExt, Label};
use crate::ui::constant::{self, HEIGHT, SCREEN};
use crate::ui::display::toif::Toif;
use crate::ui::display::{self, Color, Icon};
@@ -92,7 +93,7 @@ impl BootloaderUI for UICaesar {
}
fn screen_menu(_initial_setup: bool, communication: bool) -> (u32, u32) {
- let mut frame = Menu::new();
+ let mut frame = Menu::new(MENU_ITEMS).map(MenuMsg::from_selection);
run(&mut frame, true, communication)
}
@@ -174,15 +175,8 @@ impl BootloaderUI for UICaesar {
TEXT_NORMAL,
));
- let mut frame = Confirm::new(
- BLD_BG,
- title_str.into(),
- message,
- alert,
- "INSTALL".into(),
- false,
- )
- .with_info_screen("FW FINGERPRINT".into(), fingerprint);
+ let mut frame = Confirm::new(BLD_BG, title_str.into(), message, alert, "INSTALL".into())
+ .with_menu("Fingerprint", "FW FINGERPRINT".into(), fingerprint);
let (_, res) = run(&mut frame, true, false);
res
@@ -198,7 +192,6 @@ impl BootloaderUI for UICaesar {
message,
None,
"RESET".into(),
- false,
);
let (_, res) = run(&mut frame, true, false);
@@ -218,7 +211,6 @@ impl BootloaderUI for UICaesar {
message,
None,
"UNLOCK".into(),
- true,
);
let (_, res) = run(&mut frame, true, false);
### core/embed/rust/src/ui/layout_caesar/component/bl_confirm.rs
@@ -1,213 +0,0 @@
-use super::theme::{BUTTON_HEIGHT, TEXT_BOLD, TITLE_AREA_HEIGHT};
-use super::{ButtonController, ButtonControllerMsg, ButtonLayout, ButtonPos};
-use crate::strutil::TString;
-use crate::ui::component::{Component, ComponentExt, Event, EventCtx, Label, Pad};
-use crate::ui::display::Color;
-use crate::ui::geometry::Rect;
-use crate::ui::shape::Renderer;
-
-const ALERT_AREA_START: i16 = 39;
-
-#[derive(Copy, Clone)]
-pub enum ConfirmMsg {
- Cancel = 1,
- Confirm = 2,
-}
-
-pub struct Confirm<'a> {
- bg: Pad,
- bg_color: Color,
- title: Label<'a>,
- message: Label<'a>,
- alert: Option<Label<'a>>,
- info_title: Option<Label<'a>>,
- info_text: Option<Label<'a>>,
- button_text: TString<'static>,
- buttons: ButtonController,
- /// Whether we are on the info screen (optional extra screen)
- showing_info_screen: bool,
- two_btn_confirm: bool,
-}
-
-impl<'a> Confirm<'a> {
- pub fn new(
- bg_color: Color,
- title: TString<'a>,
- message: Label<'a>,
- alert: Option<Label<'a>>,
- button_text: TString<'static>,
- two_btn_confirm: bool,
- ) -> Self {
- let btn_layout =
- Self::get_button_layout_general(false, button_text, false, two_btn_confirm);
- Self {
- bg: Pad::with_background(bg_color).with_clear(),
- bg_color,
- title: Label::left_aligned(title, TEXT_BOLD),
- message,
- alert,
- info_title: None,
- info_text: None,
- button_text,
- buttons: ButtonController::new(btn_layout),
- showing_info_screen: false,
- two_btn_confirm,
- }
- }
-
- /// Adding optional info screen
- pub fn with_info_screen(mut self, info_title: TString<'a>, info_text: Label<'a>) -> Self {
- self.info_title = Some(Label::left_aligned(info_title, TEXT_BOLD));
- self.info_text = Some(info_text);
- self.buttons = ButtonController::new(self.get_button_layout());
- self
- }
-
- fn has_info_screen(&self) -> bool {
- self.info_title.is_some()
- }
-
- fn get_button_layout(&self) -> ButtonLayout {
- Self::get_button_layout_general(
- self.showing_info_screen,
- self.button_text,
- self.has_info_screen(),
- self.two_btn_confirm,
- )
- }
-
- /// Not relying on self here, to call it in constructor.
- fn get_button_layout_general(
- showing_info_screen: bool,
- button_text: TString<'static>,
- has_info_screen: bool,
- two_btn_confirm: bool,
- ) -> ButtonLayout {
- if showing_info_screen {
- ButtonLayout::arrow_none_none()
- } else if has_info_screen {
- ButtonLayout::cancel_armed_info(button_text)
- } else if two_btn_confirm {
- ButtonLayout::cancel_armed_none(button_text)
- } else {
- ButtonLayout::cancel_none_text(button_text)
- }
- }
-
- /// Reflecting the current page in the buttons.
- fn update_buttons(&mut self) {
- let btn_layout = self.get_button_layout();
- self.buttons.set(btn_layout);
- }
-
- fn update_everything(&mut self, ctx: &mut EventCtx) {
- self.bg.clear();
- self.update_buttons();
- self.info_text.request_complete_repaint(ctx);
- self.message.request_complete_repaint(ctx);
- self.alert.request_complete_repaint(ctx);
- self.buttons.request_complete_repaint(ctx);
- self.request_complete_repaint(ctx);
- }
-}
-
-impl Component for Confirm<'_> {
- type Msg = ConfirmMsg;
-
- fn place(&mut self, bounds: Rect) -> Rect {
- self.bg.place(bounds);
-
- // Divide the screen into areas
- let (title_area, minus_title) = bounds.split_top(TITLE_AREA_HEIGHT);
- let (between_title_and_buttons, button_area) = minus_title.split_bottom(BUTTON_HEIGHT);
-
- // Texts for the main screen
- let (message_area, alert_area) = if self.alert.is_some() {
- between_title_and_buttons.split_top(ALERT_AREA_START - TITLE_AREA_HEIGHT)
- } else {
- (between_title_and_buttons, Rect::zero())
- };
- self.title.place(title_area);
- self.message.place(message_area);
- self.alert.place(alert_area);
-
- // Text for the info screen
- self.info_title.place(title_area);
- self.info_text.place(between_title_and_buttons);
-
- self.buttons.place(button_area);
-
- bounds
- }
-
- fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option<Self::Msg> {
- let msg = self.buttons.event(ctx, event);
- if self.showing_info_screen {
- // Showing the info screen currently - going back with the left button
- if let Some(ButtonControllerMsg::Triggered(ButtonPos::Left, _)) = msg {
- self.showing_info_screen = false;
- self.update_everything(ctx);
- };
- None
- } else if self.has_info_screen() {
- // Being on the "main" screen but with an info screen available on the right
- match msg {
- Some(ButtonControllerMsg::Triggered(ButtonPos::Left, _)) => {
- Some(ConfirmMsg::Cancel)
- }
- Some(ButtonControllerMsg::Triggered(ButtonPos::Middle, _)) => {
- Some(ConfirmMsg::Confirm)
- }
- Some(ButtonControllerMsg::Triggered(ButtonPos::Right, _)) => {
- self.showing_info_screen = true;
- self.update_everything(ctx);
- None
- }
- _ => None,
- }
- } else if self.two_btn_confirm {
- match msg {
- Some(ButtonControllerMsg::Triggered(ButtonPos::Left, _)) => {
- Some(ConfirmMsg::Cancel)
- }
- Some(ButtonControllerMsg::Triggered(ButtonPos::Middle, _)) => {
- Some(ConfirmMsg::Confirm)
- }
- _ => None,
- }
- } else {
- // There is just one main screen without info screen
- match msg {
- Some(ButtonControllerMsg::Triggered(ButtonPos::Left, _)) => {
- Some(ConfirmMsg::Cancel)
- }
- Some(ButtonControllerMsg::Triggered(ButtonPos::Right, _)) => {
- Some(ConfirmMsg::Confirm)
- }
- _ => None,
- }
- }
- }
-
- fn render<'s>(&'s self, target: &mut impl Renderer<'s>) {
- self.bg.render(target);
-
- // We are either on the info screen or on the "main" screen
- if self.showing_info_screen {
- self.info_title.render(target);
- self.info_text.render(target);
- } else {
- self.title.render(target);
- self.message.render(target);
- self.alert.render(target);
- }
- self.buttons.render(target);
- }
-}
-
-#[cfg(feature = "ui_debug")]
-impl crate::trace::Trace for Confirm<'_> {
- fn trace(&self, t: &mut dyn crate::trace::Tracer) {
- t.component("BlConfirm");
- }
-}
### core/embed/rust/src/ui/layout_caesar/component/button.rs
@@ -369,13 +369,6 @@ impl ButtonDetails {
.with_fixed_width(theme::ARMED_ICON_WIDTH)
}
- /// Info icon with an outline.
- pub fn info_icon() -> Self {
- Self::text("i".into())
- .with_fixed_width(theme::BUTTON_ICON_WIDTH)
- .with_font(fonts::FONT_NORMAL)
- }
-
/// Left arrow to signal going back. No outline.
pub fn left_arrow_icon() -> Self {
Self::icon(theme::ICON_ARROW_LEFT).with_offset(Offset::new(4, -3))
@@ -534,15 +527,6 @@ impl ButtonLayout {
)
}
- /// Left cancel, armed text and right info icon.
- pub fn cancel_armed_info(middle: TString<'static>) -> Self {
- Self::new(
- Some(ButtonDetails::cancel_icon()),
- Some(ButtonDetails::armed_text(middle)),
- Some(ButtonDetails::info_icon()),
- )
- }
-
/// Left cancel, armed text and blank on right.
pub fn cancel_armed_none(middle: TString<'static>) -> Self {
Self::new(
@@ -579,15 +563,6 @@ impl ButtonLayout {
)
}
- /// Only right text.
- pub fn none_none_text(text: TString<'static>) -> Self {
- Self::new(
- None,
- None,
- Some(ButtonDetails::from_text_possible_icon(text)),
- )
- }
-
/// Left and right arrow icons for navigation.
pub fn arrow_none_arrow() -> Self {
Self::new(
@@ -656,9 +631,34 @@ impl ButtonLayout {
Self::new(None, Some(ButtonDetails::armed_text(text)), None)
}
- /// Only left arrow.
- pub fn arrow_none_none() -> Self {
- Self::new(Some(ButtonDetails::left_arrow_icon()), None, None)
+ /// Only cancel cross on the left.
+ pub fn cancel_none_none() -> Self {
+ Self::new(Some(ButtonDetails::cancel_icon()), None, None)
+ }
+
+ /// Context menu on the left and text on the right.
+ pub fn menu_none_text(text: TString<'static>) -> Self {
+ Self::new(
+ Some(ButtonDetails::menu_icon()),
+ None,
+ Some(ButtonDetails::text(text)),
+ )
+ }
+
+ /// Item of a context menu carousel: arrows to move and an arrow glyph to
+ /// enter the item. The first item has a cross closing the menu instead of
+ /// the left arrow, the last one has no right arrow.
+ pub fn menu_item(is_first: bool, is_last: bool) -> Self {
+ let btn_left = if is_first {
+ ButtonDetails::cancel_icon()
+ } else {
+ ButtonDetails::left_arrow_icon()
+ };
+ Self::new(
+ Some(btn_left),
+ Some(ButtonDetails::menu_select_icon()),
+ (!is_last).then(ButtonDetails::right_arrow_icon),
+ )
}
/// Only right arrow facing down.
### core/embed/rust/src/ui/layout_caesar/component/input_methods/simple_choice.rs
@@ -57,11 +57,8 @@ impl ChoiceFactory for ChoiceFactorySimple {
fn get(&self, choice_index: usize) -> (Self::Item, Self::Action) {
let text = &self.choices[choice_index];
let btn_layout = if self.menu_buttons {
- ButtonLayout::new(
- Some(ButtonDetails::left_arrow_icon()),
- Some(ButtonDetails::menu_select_icon()),
- Some(ButtonDetails::right_arrow_icon()),
- )
+ // The first/last item buttons are adjusted below.
+ ButtonLayout::menu_item(false, false)
} else {
ButtonLayout::arrow_armed_arrow(self.select_text)
};
### core/embed/rust/src/ui/layout_caesar/component/mod.rs
@@ -1,4 +1,3 @@
-pub mod bl_confirm;
mod button;
mod button_controller;
mod error;
### core/embed/rust/src/ui/layout_caesar/res/exit.toif
[binary or diff unavailable]
### core/embed/rust/src/ui/layout_caesar/res/redo.toif
[binary or diff unavailable]
### core/embed/rust/src/ui/layout_caesar/res/trash.toif
[binary or diff unavailable]
### core/embed/rust/src/ui/layout_caesar/theme/bootloader.rs
@@ -7,12 +7,9 @@ use crate::ui::util::include_icon;
pub const BLD_BG: Color = BLACK;
pub const BLD_FG: Color = WHITE;
-include_icon!(ICON_TRASH, "layout_caesar/res/trash.toif");
include_icon!(ICON_ALERT, "layout_caesar/res/alert.toif");
include_icon!(ICON_SPINNER, "layout_caesar/res/spinner.toif");
include_icon!(ICON_SUCCESS, "layout_caesar/res/success.toif");
-include_icon!(ICON_REDO, "layout_caesar/res/redo.toif");
-include_icon!(ICON_EXIT, "layout_caesar/res/exit.toif");
pub const TEXT_NORMAL: TextStyle =
TextStyle::new(fonts::FONT_NORMAL, BLD_FG, BLD_BG, BLD_FG, BLD_FG);Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.