This commit is contained in:
2026-07-15 08:03:05 +02:00
parent d0bb988750
commit 8df34ba762
3 changed files with 25 additions and 1 deletions
+20
View File
@@ -0,0 +1,20 @@
use crate::widget::Widget;
pub struct Center(pub String);
impl Widget for Center {
fn render(&self, scope: &mut crate::render::RenderScope) {
let mut width = 0;
let mut height = 0;
for line in self.0.lines() {
height += 1;
width = width.max(line.len() as u16);
}
let x = (scope.rect.width - width) / 2;
let y = (scope.rect.height - height) / 2;
scope.draw_text((x, y), &self.0);
}
}
+1
View File
@@ -1,3 +1,4 @@
pub mod center;
pub mod outline; pub mod outline;
pub mod spaced; pub mod spaced;
+4 -1
View File
@@ -43,7 +43,10 @@ impl App for PulseTradeApp {
(LayoutItem::Widget(Size::Flex(1)), Box::new("one")), (LayoutItem::Widget(Size::Flex(1)), Box::new("one")),
(LayoutItem::Widget(Size::Flex(1)), Box::new("two")), (LayoutItem::Widget(Size::Flex(1)), Box::new("two")),
(LayoutItem::Widget(Size::Flex(1)), Box::new("three")), (LayoutItem::Widget(Size::Flex(1)), Box::new("three")),
(LayoutItem::Widget(Size::Flex(1)), Box::new(self.count.display().await)), (
LayoutItem::Widget(Size::Flex(1)),
Box::new(self.count.display().await),
),
]), ]),
); );
} }