feat(core/caesar): show scrollbar in menu
What changed, and why it matters
This commit is a user-interface polish change for the Trezor hardware wallet's 'Caesar' layout. It adds a small page counter (like '1/3') and a scrollbar-style indicator to on-device menus in both the bootloader and firmware. There is no security-relevant change; it only affects what is drawn on screen.
No security action required. Treat as a normal UI feature commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds visual page counters to two menu components in the Rust UI layer: (1) the bootloader Menu in core/embed/rust/src/ui/layout_caesar/bootloader/menu.rs, which now renders ‘current/total’ text plus a separator icon when there is more than one page, and (2) the firmware SimpleChoice context menu in simple_choice.rs, which now embeds an existing ScrollBar widget. Supporting theme/icon constants and binary image assets are added. No input handling, cryptography, memory management, or trust-boundary logic is modified.
Changed components
core/embed/rust/src/ui/layout_caesar/bootloader/menu.rscore/embed/rust/src/ui/layout_caesar/component/input_methods/simple_choice.rscore/embed/rust/src/ui/layout_caesar/theme/bootloader.rscore/embed/rust/src/ui/layout_caesar/res/bootloader/page_separator.pngcore/embed/rust/src/ui/layout_caesar/res/bootloader/page_separator.toifInspect captured patch +64 / −6
### core/embed/rust/src/ui/layout_caesar/bootloader/menu.rs
@@ -1,9 +1,11 @@
use super::super::theme::bootloader::{
- BLD_BG, BLD_FG, BUTTON_HEIGHT, BUTTON_OUTLINE, FONT_MENU_ITEM,
+ BLD_BG, BLD_FG, BUTTON_HEIGHT, BUTTON_OUTLINE, FONT_MENU_ITEM, FONT_PAGE_COUNTER,
+ ICON_PAGE_SEPARATOR,
};
use super::buttons::{Button, ButtonPos, Buttons};
+use crate::strutil::ShortString;
use crate::ui::component::{Component, Event, EventCtx, Pad};
-use crate::ui::geometry::{Offset, Rect};
+use crate::ui::geometry::{Alignment, Alignment2D, Offset, Point, Rect};
use crate::ui::layout::simplified::ReturnToC;
use crate::ui::shape::{self, Renderer};
@@ -83,6 +85,34 @@ impl<const N: usize> Menu<N> {
self.pad.clear();
ctx.request_paint();
}
+
+ /// "current/total" page counter at the top right, like the firmware
+ /// `ScrollBar`.
+ fn render_page_counter<'s>(&self, target: &mut impl Renderer<'s>) {
+ let font = FONT_PAGE_COUNTER;
+ let current: ShortString = uformat!("{}", self.index + 1);
+ let total: ShortString = uformat!("{}", N);
+ let baseline = self.pad.area.top_right() + Offset::y(font.text_height() - 1);
+ // One pixel gap on both sides of the separator
+ let current_right =
+ baseline.x - font.text_width(&total) - ICON_PAGE_SEPARATOR.toif.width() - 2;
+
+ shape::Text::new(baseline, &total, font)
+ .with_align(Alignment::End)
+ .with_fg(BLD_FG)
+ .render(target);
+ shape::ToifImage::new(
+ Point::new(current_right + 1, baseline.y),
+ ICON_PAGE_SEPARATOR.toif,
+ )
+ .with_align(Alignment2D::BOTTOM_LEFT)
+ .with_fg(BLD_FG)
+ .render(target);
+ shape::Text::new(Point::new(current_right, baseline.y), ¤t, font)
+ .with_align(Alignment::End)
+ .with_fg(BLD_FG)
+ .render(target);
+ }
}
impl<const N: usize> Component for Menu<N> {
@@ -109,6 +139,9 @@ impl<const N: usize> Component for Menu<N> {
fn render<'s>(&'s self, target: &mut impl Renderer<'s>) {
self.pad.render(target);
self.buttons.render(target);
+ if N > 1 {
+ self.render_page_counter(target);
+ }
// The item is outlined, and inverted while the middle button is down
let text = self.items[self.index];
### core/embed/rust/src/ui/layout_caesar/component/input_methods/simple_choice.rs
@@ -2,9 +2,10 @@ use heapless::Vec;
use super::super::{
ButtonDetails, ButtonLayout, ChoiceControls, ChoiceFactory, ChoiceItem, ChoiceMsg, ChoicePage,
+ ScrollBar,
};
use crate::strutil::TString;
-use crate::ui::component::{Component, Event, EventCtx};
+use crate::ui::component::{Component, Event, EventCtx, Paginate};
use crate::ui::geometry::Rect;
use crate::ui::shape::Renderer;
@@ -92,6 +93,8 @@ pub struct SimpleChoice {
ignore_cancelled: bool,
/// Which items are dangerous (e.g. cancelling the whole flow).
danger_items: Vec<bool, MAX_LENGTH>,
+ /// Page counter at the top right, shown in context menus.
+ scrollbar: Option<ScrollBar>,
}
impl SimpleChoice {
@@ -109,6 +112,7 @@ impl SimpleChoice {
return_index: false,
ignore_cancelled: false,
danger_items: Vec::new(),
+ scrollbar: None,
}
}
@@ -142,16 +146,25 @@ impl SimpleChoice {
self
}
- /// Using the context menu buttons - arrow glyph to enter an item.
- /// `danger_items` marks the items that are dangerous.
+ /// Using the context menu buttons - arrow glyph to enter an item - and
+ /// the page counter. `danger_items` marks the items that are dangerous.
pub fn with_menu_buttons(mut self, danger_items: Vec<bool, MAX_LENGTH>) -> Self {
self.choice_page = self.choice_page.with_choice_factory(|choices| {
choices.menu_buttons = true;
});
self.danger_items = danger_items;
+ self.scrollbar = Some(ScrollBar::new(self.page_count));
self
}
+ /// Keeping the page counter in sync with the current item.
+ fn update_scrollbar(&mut self) {
+ let page = self.choice_page.page_index() as u16;
+ if let Some(scrollbar) = &mut self.scrollbar {
+ scrollbar.change_page(page);
+ }
+ }
+
/// Translating the resulting index into actual string choice.
pub fn result_by_index(&self, index: usize) -> TString<'static> {
self.choice_page.choice_factory().get_string(index)
@@ -162,16 +175,22 @@ impl Component for SimpleChoice {
type Msg = ChoiceMsg<usize>;
fn place(&mut self, bounds: Rect) -> Rect {
+ self.update_scrollbar();
+ self.scrollbar.place(bounds);
self.choice_page.place(bounds)
}
fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option<Self::Msg> {
ctx.set_page_count(self.page_count);
- self.choice_page.event(ctx, event)
+ let msg = self.choice_page.event(ctx, event);
+ // The choice page repaints the whole screen when the item changes
+ self.update_scrollbar();
+ msg
}
fn render<'s>(&'s self, target: &mut impl Renderer<'s>) {
self.choice_page.render(target);
+ self.scrollbar.render(target);
}
}
### core/embed/rust/src/ui/layout_caesar/res/bootloader/page_separator.png
[binary or diff unavailable]
### core/embed/rust/src/ui/layout_caesar/res/bootloader/page_separator.toif
[binary or diff unavailable]
### core/embed/rust/src/ui/layout_caesar/theme/bootloader.rs
@@ -15,6 +15,8 @@ pub const TEXT_BOLD: TextStyle = TextStyle::new(fonts::FONT_BOLD, BLD_FG, BLD_BG
pub const FONT_BUTTON: Font = fonts::FONT_NORMAL_UPPER;
pub const FONT_MENU_ITEM: Font = fonts::FONT_NORMAL;
+/// Page counter, the same digits as the firmware header font
+pub const FONT_PAGE_COUNTER: Font = fonts::FONT_BOLD;
pub const TITLE_AREA_HEIGHT: i16 = 12;
@@ -46,6 +48,10 @@ include_icon!(
); // 4*7
include_icon!(ICON_CLOSE, "layout_caesar/res/bootloader/close.toif"); // 8*7
include_icon!(ICON_MENU, "layout_caesar/res/bootloader/menu.toif"); // 6*7
+include_icon!(
+ ICON_PAGE_SEPARATOR,
+ "layout_caesar/res/bootloader/page_separator.toif"
+); // 3*5
include_icon!(
ICON_SELECT,
"layout_caesar/res/bootloader/mid_button_arrow_down.toif"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.