# CompositionViewBox

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/rendering/composition/struct-compositionviewbox/

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

```rust
struct CompositionViewBox
```

The area of the shape coordinates a shape visual or a geometric clip
shows (WinUI `Microsoft.UI.Composition.CompositionViewBox`): the
rectangle `(offset, size)` of the shapes is mapped onto the visual by
`stretch` and placed by the alignment ratios, as a surface brush lays
out its surface. `Offset`, `Size` and the ratios are animatable.

Deviation (winui-composition.md): what is outside the mapped view box is
clipped (the port's reading of WinUI); a view box whose size is zero maps
nothing (the shapes are drawn as if there were no view box).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/composition_view_box.rs#L17)

## Members

- [`compositor`](#function-compositor)
- [`object`](#function-object)
- [`is_disposed`](#function-is_disposed)
- [`dispose`](#function-dispose)
- [`horizontal_alignment_ratio`](#function-horizontal_alignment_ratio)
- [`set_horizontal_alignment_ratio`](#function-set_horizontal_alignment_ratio)
- [`offset`](#function-offset)
- [`set_offset`](#function-set_offset)
- [`size`](#function-size)
- [`set_size`](#function-set_size)
- [`stretch`](#function-stretch)
- [`set_stretch`](#function-set_stretch)
- [`vertical_alignment_ratio`](#function-vertical_alignment_ratio)
- [`set_vertical_alignment_ratio`](#function-set_vertical_alignment_ratio)

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

### compositor

```rust
fn compositor(self: &Self) -> &Rc<Compositor>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/composition_view_box.rs#L35)

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

### object

```rust
fn object(self: &Self) -> &CompositionObject
```

The embedded `CompositionObject`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/composition_view_box.rs#L40)

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

### is_disposed

```rust
fn is_disposed(self: &Self) -> bool
```



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

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

### dispose

```rust
fn dispose(self: &Self)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/composition_view_box.rs#L53)

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

### horizontal_alignment_ratio

```rust
fn horizontal_alignment_ratio(self: &Self) -> f32
```

The part of the free horizontal space left of the mapped view box
(0 left, 0.5 centre, 1 right; default 0.5).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/composition_view_box.rs#L64)

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

### set_horizontal_alignment_ratio

```rust
fn set_horizontal_alignment_ratio(self: &Self, value: f32)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/composition_view_box.rs#L68)

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

### offset

```rust
fn offset(self: &Self) -> Vector
```

The top left corner of the view box, in shape coordinates.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/composition_view_box.rs#L73)

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

### set_offset

```rust
fn set_offset(self: &Self, value: Vector)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/composition_view_box.rs#L77)

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

### size

```rust
fn size(self: &Self) -> Vector
```

The size of the view box, in shape coordinates.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/composition_view_box.rs#L82)

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

### set_size

```rust
fn set_size(self: &Self, value: Vector)
```



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

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

### stretch

```rust
fn stretch(self: &Self) -> CompositionStretch
```

How the view box is scaled onto the visual (default `Fill`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/composition_view_box.rs#L91)

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

### set_stretch

```rust
fn set_stretch(self: &Self, value: CompositionStretch)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/composition_view_box.rs#L95)

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

### vertical_alignment_ratio

```rust
fn vertical_alignment_ratio(self: &Self) -> f32
```

The part of the free vertical space above the mapped view box
(0 top, 0.5 centre, 1 bottom; default 0.5).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/composition_view_box.rs#L101)

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

### set_vertical_alignment_ratio

```rust
fn set_vertical_alignment_ratio(self: &Self, value: f32)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/composition_view_box.rs#L105)

## 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`
- `CompositionViewBoxHooks`
- `IRegisterForSerialization`
- `ICompositionObjectHost`
- [`ICompositionObjectAnimations`](/docs/0.5.0/api/ferroui-base/rendering/composition/trait-icompositionobjectanimations/)
- [`AsCompositionObject`](/docs/0.5.0/api/ferroui-base/rendering/composition/trait-ascompositionobject/)
- `ICompositionObject`
- `ICompositorSerializable`

## Availability

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