pub enum Scaling {
None,
Proportional,
Stretch,
}Expand description
Whether a form may be drawn at a size other than the one it was designed at.
Scaling is not always right, and the form is the thing that knows. A dial designed against a 1:1 photographic background, a layout whose text must stay a legal minimum size, a panel whose touch targets are already at the smallest a gloved finger can hit — each of those is a form that should be drawn at its design size and centred, not stretched to fit. So it is declared rather than assumed, and the default is the one every form written before this property existed already had.
This is a deployment concern, applied once on the way in.
anchors are a design concern, resolved by the
tree at every reflow. They are different tools and they compose: a form may
use either, both or neither.
let form = Form::parse(r#"form "F" version=1 width=100 height=100 { }"#)?;
assert_eq!(form.scaling(), Scaling::None, "the default is what was always true");Variants§
None
Never scaled. Drawn at its design size, centred in whatever it is given.
Proportional
One factor on both axes — min(target.w / design.w, target.h / design.h)
— so nothing distorts, and the leftover is a margin on one axis.
Stretch
A factor per axis, filling the surface. Distorts, and is occasionally exactly what a signage layout wants.
Implementations§
Source§impl Scaling
impl Scaling
Sourcepub const fn what(self) -> &'static str
pub const fn what(self) -> &'static str
assert!(Scaling::None.what().contains("design size"));
assert_ne!(Scaling::Proportional.what(), Scaling::Stretch.what());One line on what this one does.
Here rather than in the designer for the same reason as
FormKind::what: it is a fact about the format, and two copies of a
sentence drift.