Skip to content

Commit 8a9f784

Browse files
committed
ui: vertically center messages printed by message()
Previously only the first line was centered and the remaining lines were printed below it. Signed-off-by: Leonard Göhrs <[email protected]>
1 parent 9a4539e commit 8a9f784

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/ui/screens.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ pub fn message(target: &mut DisplayExclusive, text: &str) -> Rectangle {
170170
let ui_text_style: MonoTextStyle<BinaryColor> =
171171
MonoTextStyle::new(&UI_TEXT_FONT, BinaryColor::On);
172172

173-
let text = Text::with_alignment(text, Point::new(120, 120), ui_text_style, Alignment::Center);
173+
let mut text = Text::with_alignment(text, Point::zero(), ui_text_style, Alignment::Center);
174+
175+
let offset = Point::new(120, 120) - text.bounding_box().center();
176+
text.translate_mut(offset);
174177

175178
text.draw(target).unwrap();
176179

0 commit comments

Comments
 (0)