diff --git a/src/view/linear_layout.rs b/src/view/linear_layout.rs index b259d99..61ee218 100644 --- a/src/view/linear_layout.rs +++ b/src/view/linear_layout.rs @@ -1,4 +1,5 @@ use XY; +use With; use direction; use view::View; use view::{Selector, SizeCache}; @@ -56,15 +57,20 @@ impl LinearLayout { } /// Adds a child to the layout. - pub fn child(mut self, view: V) -> Self { + /// + /// Chainable variant. + pub fn child(self, view: V) -> Self { + self.with(|s| s.add_child(view)) + } + + /// Adds a child to the layout. + pub fn add_child(&mut self, view: V) { self.children.push(Child { view: Box::new(view), size: Vec2::zero(), weight: 0, }); self.invalidate(); - - self } // Invalidate the view, to request a layout next time