lib: Add layout to render properties

This commit is contained in:
Erik Kundt
2024-05-13 11:35:25 +02:00
parent eb80772e8e
commit 1ec158f85b
+14 -2
View File
@@ -37,8 +37,10 @@ pub struct BaseView<S, A> {
/// They can be passed to a widgets' `render` function.
#[derive(Clone, Default)]
pub struct RenderProps {
/// Area of the render props
/// Area of the render props.
pub area: Rect,
/// Layout to be rendered in.
pub layout: Layout,
/// Focus of the render props.
pub focus: bool,
}
@@ -49,11 +51,21 @@ impl RenderProps {
self.focus = focus;
self
}
/// Sets the layout of these render props.
pub fn layout(mut self, layout: Layout) -> Self {
self.layout = layout;
self
}
}
impl From<Rect> for RenderProps {
fn from(area: Rect) -> Self {
Self { area, focus: false }
Self {
area,
layout: Layout::default(),
focus: false,
}
}
}