Trait zng::layout::LengthUnits
source · 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();// FactorUnits
Required 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
.