1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-19 22:18:13 +00:00

fix(core): make the marquee take always 2 seconds to animate from end to end

[no changelog]
This commit is contained in:
grdddj 2023-09-22 13:35:16 +02:00 committed by Jiří Musil
parent ff4197c50a
commit b07f4d938a

View File

@ -10,7 +10,6 @@ use crate::{
}, },
}; };
const MILLIS_PER_LETTER_M: u32 = 300;
const ANIMATION_DURATION_MS: u32 = 2000; const ANIMATION_DURATION_MS: u32 = 2000;
const PAUSE_DURATION_MS: u32 = 1000; const PAUSE_DURATION_MS: u32 = 1000;
@ -141,22 +140,6 @@ where
type Msg = Never; type Msg = Never;
fn place(&mut self, bounds: Rect) -> Rect { fn place(&mut self, bounds: Rect) -> Rect {
let base_width = self.font.text_width("M");
let text_width = self.font.text_width(self.text.as_ref());
let area_width = bounds.width();
let shift_width = if area_width > text_width {
area_width - text_width
} else {
text_width - area_width
};
let mut duration = (MILLIS_PER_LETTER_M * shift_width as u32) / base_width as u32;
if duration < MILLIS_PER_LETTER_M {
duration = MILLIS_PER_LETTER_M;
}
self.duration = Duration::from_millis(duration);
self.area = bounds; self.area = bounds;
self.area self.area
} }