Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
lib: Add layout to render properties
Erik Kundt committed 2 years ago
commit 1ec158f85bba2192963aa302c19516e41e51d5d4
parent eb80772e8e500efb50a91ad175d49a9497edf262
1 file changed +14 -2
modified src/ui/widget.rs
@@ -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,
+
        }
    }
}