Expand description
A frame that keeps a ratio.
§Which dimension decides
A ratio relates two numbers, so exactly one of them has to be the one that
is given, and the component says which rather than guessing. AspectFit
is that answer:
AspectFit::Widthtakes the width from the parent and computes the height. This is the common case — a thumbnail in a column, a video in an article — and it is the default.AspectFit::Heighttakes the height from the parent and computes the width, which is what a strip of previews along a fixed-height row needs.
When the parent constrains both, the frame still does what fit says:
it pins the one dimension fit names and lets the ratio decide the other,
even where that overflows the parent along the axis it did not take. The
alternative — shrinking to fit inside both — would be a contain box,
which is a different component: it leaves empty space on one axis, and
whoever laid the parent out is the only one who can say whether that space
is acceptable. A frame that silently switched between the two would hold
its ratio while quietly disagreeing with the size the caller asked for, so
this one keeps the promise it was given and lets the overflow be visible.
Structs§
- Aspect
Ratio - A container whose two dimensions stay in a fixed ratio.
Enums§
- Aspect
Fit - Which dimension the parent decides, leaving the other to the ratio.