From 1ec158f85bba2192963aa302c19516e41e51d5d4 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Wed, 8 May 2024 17:12:30 +0200 Subject: [PATCH] lib: Add layout to render properties --- src/ui/widget.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ui/widget.rs b/src/ui/widget.rs index c0dbc354..06fab98f 100644 --- a/src/ui/widget.rs +++ b/src/ui/widget.rs @@ -37,8 +37,10 @@ pub struct BaseView { /// 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 for RenderProps { fn from(area: Rect) -> Self { - Self { area, focus: false } + Self { + area, + layout: Layout::default(), + focus: false, + } } }