#[non_exhaustive]pub enum Fit {
Natural,
Cover,
Contain,
}Expand description
Something the user can do, and what it costs to say so.
Added 0.17.0, out of quasi-tui: the terminal renderer had drawn one of
these for months and every other consumer that wanted a button had written
its own, because this layer named RowPart::Actions as a slot and never
named the thing that goes in it. Beside Meter and Figure for the
reason those are here: a renderer that is handed the parts has to decide how
to say them, and a renderer that is handed a finished string has already had
the decision made for it.
No address. Where a control goes is the app’s business and every host
follows it differently — an hx-get, a protocol URL, a function call — so
the description says what the control is and the caller keeps what it
does. That is the same split Choice makes.
No confirmation flag either, and that one is a finding rather than an omission: a question asked after a control is pressed belongs to whatever is holding the interaction, and a renderer that drew it would be asking before there was anything to answer. How a picture sits in the box it is given.
An intent rather than a value, so a renderer picks the expression it has:
object-fit in a webview, a texture’s UV rect in egui, and in a terminal a
choice about how many cells the blit gets. Named because MNW already makes
the distinction deliberately at 17 sites and makes it three different ways,
which is a policy the app decided rather than one a shared crate would be
picking by accident.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Natural
The picture’s own proportions, and the box takes the height they imply.
The default because it is the only one that shows the whole picture at
its own shape, so a renderer that ignores this enum entirely is still
right about the common case. A screenshot wants this; the shipped MNW
carousel sets no object-fit at all, which is this.
Cover
Fill the box and crop whatever does not fit.
For a picture in a slot whose shape the layout fixed: a thumbnail, an avatar, cover art. 15 of MNW’s 17 sites.
Contain
Fit inside the box whole, leaving space on two sides.
The letterbox. For when the whole picture matters more than filling the space, and the space is not the picture’s shape.