From f091cec86112fb92a31a1d1dac14b5623e958e3a Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Sat, 27 Jan 2018 22:12:29 -0800 Subject: [PATCH] Add BoxView::set_size --- src/views/box_view.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/views/box_view.rs b/src/views/box_view.rs index 6bcb65e..52082a5 100644 --- a/src/views/box_view.rs +++ b/src/views/box_view.rs @@ -48,6 +48,26 @@ impl BoxView { } } + /// Sets the size constraints for this view. + pub fn set_constraints(&mut self, width: SizeConstraint, height: SizeConstraint) { + self.set_width(width); + self.set_height(height); + } + + /// Sets the width constraint for this view. + /// + /// Leaves the height unchanged. + pub fn set_width(&mut self, width: SizeConstraint) { + self.size.x = width; + } + + /// Sets the height constraint for this view. + /// + /// Leaves the width unchanged. + pub fn set_height(&mut self, height: SizeConstraint) { + self.size.y = height; + } + /// Sets `self` to be squishable. /// /// A squishable `BoxView` will take a smaller size than it should when