From 3a15922d2ffc041c3523edb479f008a9034fd400 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 26 Nov 2021 16:32:06 +0100 Subject: X/Y abstractions --- src/layout/constraints.rs | 18 +++--------------- src/layout/regions.rs | 2 +- 2 files changed, 4 insertions(+), 16 deletions(-) (limited to 'src/layout') diff --git a/src/layout/constraints.rs b/src/layout/constraints.rs index b72254d7..0d772cea 100644 --- a/src/layout/constraints.rs +++ b/src/layout/constraints.rs @@ -2,7 +2,7 @@ use std::rc::Rc; use super::Regions; use crate::frame::Frame; -use crate::geom::{Length, Linear, Size, Spec}; +use crate::geom::{Length, Size, Spec}; /// Constrain a frame with constraints. pub trait Constrain { @@ -65,8 +65,8 @@ impl Constraints { Self { min: Spec::default(), max: Spec::default(), - exact: regions.current.to_spec().map(Some), - base: regions.base.to_spec().map(Some), + exact: regions.current.map(Some), + base: regions.base.map(Some), expand: regions.expand, } } @@ -80,18 +80,6 @@ impl Constraints { && verify(self.exact, current, Length::approx_eq) && verify(self.base, base, Length::approx_eq) } - - /// Set the appropriate base constraints for linear width and height sizing. - pub fn set_base_if_linear(&mut self, base: Size, sizing: Spec>) { - // The full sizes need to be equal if there is a relative component in - // the sizes. - if sizing.x.map_or(false, |l| l.is_relative()) { - self.base.x = Some(base.w); - } - if sizing.y.map_or(false, |l| l.is_relative()) { - self.base.y = Some(base.h); - } - } } /// Verify a single constraint. diff --git a/src/layout/regions.rs b/src/layout/regions.rs index 0ef92543..66e6da17 100644 --- a/src/layout/regions.rs +++ b/src/layout/regions.rs @@ -51,7 +51,7 @@ impl Regions { /// Whether the current region is full and a region break is called for. pub fn is_full(&self) -> bool { - Length::zero().fits(self.current.h) && !self.in_last() + Length::zero().fits(self.current.y) && !self.in_last() } /// Whether `current` is the last usable region. -- cgit v1.2.3