Added Frame layout, and fix outline

This commit is contained in:
2026-07-14 22:17:41 +02:00
parent c758f55fc6
commit 62511d2101
3 changed files with 32 additions and 5 deletions
+16
View File
@@ -4,6 +4,7 @@ use crate::unit::{Rect, Size};
pub enum LayoutItem {
Rows { unit: Size, items: Vec<LayoutItem> },
Columns { unit: Size, items: Vec<LayoutItem> },
Frame { padding: u16, item: Box<LayoutItem> },
Widget(Size),
}
@@ -63,6 +64,20 @@ impl LayoutItem {
}
}
Self::Frame { padding, item } => {
frame.push(*alloc);
let mut item_alloc = alloc.clone();
item_alloc.width -= padding * 2;
item_alloc.height -= padding * 2;
item_alloc.x += padding;
item_alloc.y += padding;
item.allocate(&item_alloc, frame, widgets);
}
Self::Widget(_) => {
widgets.push(*alloc);
}
@@ -74,6 +89,7 @@ impl LayoutItem {
Self::Rows { unit, .. } => unit,
Self::Columns { unit, .. } => unit,
Self::Widget(unit) => unit,
Self::Frame { item, .. } => item.get_size(),
}
}
}
+1 -1
View File
@@ -13,7 +13,7 @@ impl Widget for Outline {
);
scope.draw_text(
(0, scope.rect.height),
(0, scope.rect.height - 1),
"-".repeat(scope.rect.width as usize),
);
}