pub trait LengthUnits {
Show 18 methods
// Required methods
fn dip(self) -> Length;
fn px(self) -> Length;
fn pt(self) -> Length;
fn fct_l(self) -> Length;
fn pct_l(self) -> Length;
fn em(self) -> Length;
fn em_pct(self) -> Length;
fn rem(self) -> Length;
fn rem_pct(self) -> Length;
fn vw(self) -> Length;
fn vw_pct(self) -> Length;
fn vh(self) -> Length;
fn vh_pct(self) -> Length;
fn vmin(self) -> Length;
fn vmin_pct(self) -> Length;
fn vmax(self) -> Length;
fn vmax_pct(self) -> Length;
fn lft(self) -> Length;
}Expand description
Extension methods for initializing Length units.
This trait is implemented for f32 and u32 allowing initialization of length units using the <number>.<unit>() syntax.
§Examples
let font_size = 1.em();
let root_font_size = 1.rem();
let viewport_width = 100.vw();
let viewport_height = 100.vh();
let viewport_min = 100.vmin(); // min(width, height)
let viewport_max = 100.vmax(); // max(width, height)
// other length units not provided by `LengthUnits`:
let exact_size: Length = 500.into();
let relative_size: Length = 100.pct().into(); // FactorUnits
let relative_size: Length = 1.0.fct().into(); // FactorUnitsRequired Methods§
Sourcefn dip(self) -> Length
fn dip(self) -> Length
Exact size in device independent pixels.
Returns Length::Dip.
Sourcefn px(self) -> Length
fn px(self) -> Length
Exact size in device pixels.
Returns Length::Px.
Sourcefn pt(self) -> Length
fn pt(self) -> Length
Exact size in font units.
Returns Length::Pt.
Sourcefn fct_l(self) -> Length
fn fct_l(self) -> Length
Factor of the fill length.
This is the same as FactorUnits::fct, but produces a Length directly. This might be needed
in places that don’t automatically convert Factor to Length.
Returns Length::Factor.
Sourcefn pct_l(self) -> Length
fn pct_l(self) -> Length
Percentage of the fill length.
This is the same as FactorUnits::pct, but produces a Length directly. This might be needed
in places that don’t automatically convert FactorPercent to Length.
Returns Length::Factor.
Sourcefn em(self) -> Length
fn em(self) -> Length
Factor of the font-size of the widget.
Returns Length::Em.
Sourcefn em_pct(self) -> Length
fn em_pct(self) -> Length
Percentage of the font-size of the widget.
Returns Length::Em.
Sourcefn rem(self) -> Length
fn rem(self) -> Length
Factor of the font-size of the root widget.
Returns Length::RootEm.
Sourcefn rem_pct(self) -> Length
fn rem_pct(self) -> Length
Percentage of the font-size of the root widget.
Returns Length::RootEm.
Sourcefn vw(self) -> Length
fn vw(self) -> Length
Factor of the width of the nearest viewport ancestor.
Returns Length::ViewportWidth.
Sourcefn vw_pct(self) -> Length
fn vw_pct(self) -> Length
Percentage of the width of the nearest viewport ancestor.
Returns Length::ViewportWidth.
Sourcefn vh(self) -> Length
fn vh(self) -> Length
Factor of the height of the nearest viewport ancestor.
Returns Length::ViewportHeight.
Sourcefn vh_pct(self) -> Length
fn vh_pct(self) -> Length
Percentage of the height of the nearest viewport ancestor.
Returns Length::ViewportHeight.
Sourcefn vmin(self) -> Length
fn vmin(self) -> Length
Factor of the smallest of the nearest viewport’s dimensions.
Returns Length::ViewportMin.
Sourcefn vmin_pct(self) -> Length
fn vmin_pct(self) -> Length
Percentage of the smallest of the nearest viewport’s dimensions.
Returns Length::ViewportMin.
Sourcefn vmax(self) -> Length
fn vmax(self) -> Length
Factor of the largest of the nearest viewport’s dimensions.
Returns Length::ViewportMax.
Sourcefn vmax_pct(self) -> Length
fn vmax_pct(self) -> Length
Percentage of the largest of the nearest viewport’s dimensions.
Returns Length::ViewportMax.
Sourcefn lft(self) -> Length
fn lft(self) -> Length
Factor of the leftover layout space.
Note that this unit must be supported by the parent panel widget and property, otherwise it evaluates like a single item having all the available fill space as leftover space.
Returns Length::Leftover.