pub struct ConstraintsTransform {
pub width: AxisConstraint,
pub height: AxisConstraint,
pub alignment: Alignment,
pub report: bool,
}Expand description
What a ConstraintsTransformBox gives its child, per axis, and what it does about a
child that comes back too big.
It is a small vocabulary rather than an arbitrary function of the space on offer, and that is a decision worth stating. The layout and the paint walk are two passes over the same tree, and only the first is told what the parent offered: by the time the walk lays the child out, the box has been sized to the child and the offer is not recoverable from it. A function of the offer could not be run again there — and a function run again on the wrong input answers plausibly, which is worse than not answering at all. Each of these three can be run again: a fixed number is itself, an unbounded axis is a question with no input, and an axis given as it came produced a child of exactly the box’s own size.
The reference’s transform is a closure, and every transform the reference itself ships is one of these three.
Fields§
§width: AxisConstraintWhat the child is given across.
height: AxisConstraintAnd down.
alignment: AlignmentWhere a child smaller than the box sits in it.
report: boolWhether a child that came out bigger than the box is reported as an overflow — the yellow and black band, in debug builds. On by default: a box that transforms its constraints is asking a question about what fits, and a silent answer is no answer.
Implementations§
Source§impl ConstraintsTransform
impl ConstraintsTransform
Sourcepub fn width(self, width: AxisConstraint) -> Self
pub fn width(self, width: AxisConstraint) -> Self
What the child is given across.
Sourcepub fn height(self, height: AxisConstraint) -> Self
pub fn height(self, height: AxisConstraint) -> Self
What the child is given down.