diff --git a/src/views/box_view.rs b/src/views/box_view.rs index c478e5a..9f5f864 100644 --- a/src/views/box_view.rs +++ b/src/views/box_view.rs @@ -25,13 +25,6 @@ pub struct BoxView { /// Constraint on each axis size: XY, - /// `true` if the view can be squished. - /// - /// This means if the required size is less than the computed size, - /// consider returning a smaller size. - /// For instance, try to return the child's desired size. - squishable: bool, // TODO: remove? - /// Set to `true` whenever we change some settings. Means we should re-layout just in case. invalidated: bool, @@ -50,7 +43,6 @@ impl BoxView { ) -> Self { BoxView { size: (width, height).into(), - squishable: false, invalidated: true, view, } @@ -82,24 +74,6 @@ impl BoxView { self.invalidate(); } - /// Sets `self` to be squishable. - /// - /// A squishable `BoxView` will take a smaller size than it should when - /// the available space is too small. In that case, it will allow the - /// child view to contract, if it can. - /// - /// More specifically, if the available space is less than the size we - /// would normally ask for, return the child size. - pub fn squishable(self) -> Self { - self.with(|s| s.set_squishable(true)) - } - - /// Controls the "squishability" of `self`. - pub fn set_squishable(&mut self, squishable: bool) { - self.squishable = squishable; - self.invalidate(); - } - /// Wraps `view` in a new `BoxView` with the given size. pub fn with_fixed_size>(size: S, view: T) -> Self { let size = size.into(); @@ -228,28 +202,14 @@ impl ViewWrapper for BoxView { let child_size = self.view.required_size(req); // Some of this request will be granted, but maybe not all. - let result = self - .size - .zip_map(child_size.zip(req), SizeConstraint::result); - - if self.squishable { - // When we're squishable, special behaviour: - // - - // We respect the request if we're less or equal. - let respect_req = result.zip_map(req, |res, req| res <= req); - - // If we respect the request, keep the result - // Otherwise, take the child as squish attempt. - respect_req.select_or(result, child_size) - } else { - result - } + self.size + .zip_map(child_size.zip(req), SizeConstraint::result) } fn wrap_layout(&mut self, size: Vec2) { self.invalidated = false; - self.view.layout(size); + self.view + .layout(self.size.zip_map(size, |c, s| c.result((s, s)))); } fn wrap_needs_relayout(&self) -> bool {