1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

fix(core): use new rendering in changing_text

[no changelog]
This commit is contained in:
tychovrahe 2024-09-16 12:01:43 +02:00 committed by TychoVrahe
parent 23d68eb0bb
commit 6658c42a95

View File

@ -162,6 +162,25 @@ impl ChangingTextLine {
let baseline = Point::new(self.pad.area.x0 + x_offset, self.y_baseline()); let baseline = Point::new(self.pad.area.x0 + x_offset, self.y_baseline());
common::display_left(baseline, &text_to_display, self.font); common::display_left(baseline, &text_to_display, self.font);
} }
fn render_long_content_with_ellipsis<'s>(&'s self, target: &mut impl Renderer<'s>) {
let text_to_display = long_line_content_with_ellipsis(
self.text.as_ref(),
self.ellipsis,
self.font,
self.pad.area.width(),
);
// Creating the notion of motion by shifting the text left and right with
// each new text character.
// (So that it is apparent for the user that the text is changing.)
let x_offset = if self.text.len() % 2 == 0 { 0 } else { 2 };
let baseline = Point::new(self.pad.area.x0 + x_offset, self.y_baseline());
shape::Text::new(baseline, self.text.as_ref())
.with_font(self.font)
.render(target);
}
} }
impl Component for ChangingTextLine { impl Component for ChangingTextLine {
@ -201,7 +220,7 @@ impl Component for ChangingTextLine {
if self.show_content { if self.show_content {
// In the case text cannot fit, show ellipsis and its right part // In the case text cannot fit, show ellipsis and its right part
if !self.text_fits_completely() { if !self.text_fits_completely() {
self.paint_long_content_with_ellipsis(); self.render_long_content_with_ellipsis(target);
} else { } else {
match self.alignment { match self.alignment {
Alignment::Start => self.render_left(target), Alignment::Start => self.render_left(target),