pub struct Placement {
pub x: f32,
pub y: f32,
pub rect: Rect,
}Expand description
Where a form goes on a surface, and by how much it is multiplied to get there.
What Form::fit works out and Form::build_fitted then applies. Held as
a value rather than done in one call because the application needs the parts
separately: Placement::rect is where to put the panel the form is built into,
and Placement::uniform is what the theme has to be scaled by at Ui::new —
which is not optional, or the widgets are the old size inside the new
rectangles.
Fields§
§x: f32The horizontal factor.
y: f32The vertical factor.
rect: RectWhere the form’s own rectangle lands in the surface it was fitted to, already scaled and already centred.
Implementations§
Source§impl Placement
impl Placement
Sourcepub fn uniform(self) -> f32
pub fn uniform(self) -> f32
The one factor that everything which is not a rectangle scales by: text sizes, border widths, row heights, and the theme’s own metrics.
The smaller of the two, so that a stretched layout never grows text
taller than the axis that had least room to give. Equal to either of them
whenever the fit is uniform, which is every fit except
Scaling::Stretch.
let form = Form::parse(
r#"form "F" version=1 width=100 height=100 scaling=stretch { }"#,
)?;
let fit = form.fit(Size::new(400, 200));
assert_eq!((fit.x, fit.y), (4.0, 2.0));
assert_eq!(fit.uniform(), 2.0, "text follows the tighter axis");