# LayoutHelper

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/layout/struct-layouthelper/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct LayoutHelper
```

Provides helper methods needed for layout.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L6)

## Members

- [`LAYOUT_EPSILON`](#assoc_const-layout_epsilon)
- [`apply_layout_constraints`](#function-apply_layout_constraints)
- [`measure_hold_with_border`](#function-measure_hold_with_border)
- [`measure_child_with_border`](#function-measure_child_with_border)
- [`measure_child`](#function-measure_child)
- [`arrange_child_with_border`](#function-arrange_child_with_border)
- [`arrange_child`](#function-arrange_child)
- [`invalidate_self_and_children_measure`](#function-invalidate_self_and_children_measure)
- [`get_layout_scale`](#function-get_layout_scale)
- [`round_layout_size_up`](#function-round_layout_size_up)
- [`round_layout_thickness`](#function-round_layout_thickness)
- [`round_layout_point`](#function-round_layout_point)
- [`round_layout_value`](#function-round_layout_value)
- [`round_layout_value_up`](#function-round_layout_value_up)
- [`validate_scaling`](#function-validate_scaling)

<a id="assoc_const-layout_epsilon"></a>

### LAYOUT_EPSILON

```rust
const LAYOUT_EPSILON: f64
```

Epsilon value used for certain layout calculations.
Based on the value in WPF LayoutDoubleUtil.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L11)

<a id="function-apply_layout_constraints"></a>

### apply_layout_constraints

```rust
fn apply_layout_constraints(control: &Layoutable, constraints: Size) -> Size
```

Calculates a control's size based on its width, height, min-width,
min-height, max-width and max-height.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L15)

<a id="function-measure_hold_with_border"></a>

### measure_hold_with_border

```rust
fn measure_hold_with_border(control: Option<&Layoutable>, padding: Thickness, border_thickness: Thickness) -> Option<crate::layout::MeasureHold>
```

Measures a child with padding and a border, returning the desired
size including them.
The measure hold of an element that measures `control` as `Self::measure_child_with_border`
does: the child's hold moved by the padding and the border (desktop-performance.md section
9.15); without a child, every size.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L31)

<a id="function-measure_child_with_border"></a>

### measure_child_with_border

```rust
fn measure_child_with_border(control: Option<&Layoutable>, available_size: Size, padding: Thickness, border_thickness: Thickness) -> Size
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L49)

<a id="function-measure_child"></a>

### measure_child

```rust
fn measure_child(control: Option<&Layoutable>, available_size: Size, padding: Thickness) -> Size
```

Measures a child with padding, returning the desired size including
the padding.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L71)

<a id="function-arrange_child_with_border"></a>

### arrange_child_with_border

```rust
fn arrange_child_with_border(child: Option<&Layoutable>, available_size: Size, padding: Thickness, border_thickness: Thickness) -> Size
```

Arranges a child inside padding and a border.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L86)

<a id="function-arrange_child"></a>

### arrange_child

```rust
fn arrange_child(child: Option<&Layoutable>, available_size: Size, padding: Thickness) -> Size
```

Arranges a child inside padding.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L100)

<a id="function-invalidate_self_and_children_measure"></a>

### invalidate_self_and_children_measure

```rust
fn invalidate_self_and_children_measure(control: &Layoutable)
```

Invalidates measure for the control and all of its visual descendants.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L126)

<a id="function-get_layout_scale"></a>

### get_layout_scale

```rust
fn get_layout_scale(control: &Layoutable) -> f64
```

Obtains the layout scale of the given control, based on its layout
root.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L153)

<a id="function-round_layout_size_up"></a>

### round_layout_size_up

```rust
fn round_layout_size_up(size: Size, dpi_scale: f64) -> Size
```

Rounds a size to an integer number of device pixels, rounding up.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L158)

<a id="function-round_layout_thickness"></a>

### round_layout_thickness

```rust
fn round_layout_thickness(thickness: Thickness, dpi_scale: f64) -> Thickness
```

Rounds a thickness to integer numbers of device pixels.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L171)

<a id="function-round_layout_point"></a>

### round_layout_point

```rust
fn round_layout_point(point: Point, dpi_scale: f64) -> Point
```

Rounds a point to integer device pixels.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L192)

<a id="function-round_layout_value"></a>

### round_layout_value

```rust
fn round_layout_value(value: f64, dpi_scale: f64) -> f64
```

Calculates the value to be used for layout rounding at high DPI by
rounding the value up or down to the nearest pixel.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L206)

<a id="function-round_layout_value_up"></a>

### round_layout_value_up

```rust
fn round_layout_value_up(value: f64, dpi_scale: f64) -> f64
```

Calculates the value to be used for layout rounding at high DPI by
rounding the value up to the nearest pixel.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L217)

<a id="function-validate_scaling"></a>

### validate_scaling

```rust
fn validate_scaling(scaling: f64) -> f64
```

Validates a render/layout scaling value, normalizing values close to
one to exactly one. Panics on invalid values.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/layout/layout_helper.rs#L241)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
