Trait zng_layout::unit::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§

source

fn dip(self) -> Length

Exact size in device independent pixels.

Returns Length::Dip.

source

fn px(self) -> Length

Exact size in device pixels.

Returns Length::Px.

source

fn pt(self) -> Length

Exact size in font units.

Returns Length::Pt.

source

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.

source

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.

source

fn em(self) -> Length

Factor of the font-size of the widget.

Returns Length::Em.

source

fn em_pct(self) -> Length

Percentage of the font-size of the widget.

Returns Length::Em.

source

fn rem(self) -> Length

Factor of the font-size of the root widget.

Returns Length::RootEm.

source

fn rem_pct(self) -> Length

Percentage of the font-size of the root widget.

Returns Length::RootEm.

source

fn vw(self) -> Length

Factor of the width of the nearest viewport ancestor.

Returns Length::ViewportWidth.

source

fn vw_pct(self) -> Length

Percentage of the width of the nearest viewport ancestor.

Returns Length::ViewportWidth.

source

fn vh(self) -> Length

Factor of the height of the nearest viewport ancestor.

Returns Length::ViewportHeight.

source

fn vh_pct(self) -> Length

Percentage of the height of the nearest viewport ancestor.

Returns Length::ViewportHeight.

source

fn vmin(self) -> Length

Factor of the smallest of the nearest viewport’s dimensions.

Returns Length::ViewportMin.

source

fn vmin_pct(self) -> Length

Percentage of the smallest of the nearest viewport’s dimensions.

Returns Length::ViewportMin.

source

fn vmax(self) -> Length

Factor of the largest of the nearest viewport’s dimensions.

Returns Length::ViewportMax.

source

fn vmax_pct(self) -> Length

Percentage of the largest of the nearest viewport’s dimensions.

Returns Length::ViewportMax.

source

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.

Implementations on Foreign Types§

source§

impl LengthUnits for f32

source§

fn dip(self) -> Length

source§

fn px(self) -> Length

source§

fn pt(self) -> Length

source§

fn fct_l(self) -> Length

source§

fn pct_l(self) -> Length

source§

fn em(self) -> Length

source§

fn rem(self) -> Length

source§

fn vw(self) -> Length

source§

fn vh(self) -> Length

source§

fn vmin(self) -> Length

source§

fn vmax(self) -> Length

source§

fn em_pct(self) -> Length

source§

fn rem_pct(self) -> Length

source§

fn vw_pct(self) -> Length

source§

fn vh_pct(self) -> Length

source§

fn vmin_pct(self) -> Length

source§

fn vmax_pct(self) -> Length

source§

fn lft(self) -> Length

source§

impl LengthUnits for i32

source§

fn dip(self) -> Length

source§

fn px(self) -> Length

source§

fn pt(self) -> Length

source§

fn fct_l(self) -> Length

source§

fn pct_l(self) -> Length

source§

fn em(self) -> Length

source§

fn rem(self) -> Length

source§

fn vw(self) -> Length

source§

fn vh(self) -> Length

source§

fn vmin(self) -> Length

source§

fn vmax(self) -> Length

source§

fn em_pct(self) -> Length

source§

fn rem_pct(self) -> Length

source§

fn vw_pct(self) -> Length

source§

fn vh_pct(self) -> Length

source§

fn vmin_pct(self) -> Length

source§

fn vmax_pct(self) -> Length

source§

fn lft(self) -> Length

Implementors§