# EffectHostContext

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/media/effects/struct-effecthostcontext/

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

```rust
struct EffectHostContext<'a>
```

The element an interactive effect is the effect of, as the effect's input handler sees it
(Effector's `SkiaEffectHostContext`): its bounds, the pointer position in its coordinates,
normalized to its bounds and in the coordinates of the effect's program, the capture of the
pointer, and the invalidation of the effect.

Three coordinate spaces meet here:

- the host's own coordinates (`get_position`), device independent pixels
  from the top left corner of the host, through every render transform up to the root;
- the normalized coordinates (`get_normalized_position`), 0 to
  1 across the input bounds, which is what the interactive effects of the
  library pass as uniforms: independent of the scale, they need no conversion on the render
  thread;
- the coordinates of the program (`get_effect_position`): device
  pixels from the top left corner of the area of the effect, at
  `layer_scale` (section 3.4 of the plan, the `coord` a program is given).

The area of the effect is the rectangle the renderer draws the effect over (#580): the bounds
of the content of the host's subtree, with the padding of the effect, as the compositor last
drew them (`render_bounds`), so that a normalized position of 0.5 is the
middle of what the program draws, also when the content does not fill the host or reaches
beyond it. Before the host was drawn (or without a compositor), the area is the host's own
bounds with the padding.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L118)

## Members

- [`effect`](#function-effect)
- [`host`](#function-host)
- [`visual`](#function-visual)
- [`bounds`](#function-bounds)
- [`size`](#function-size)
- [`input_bounds`](#function-input_bounds)
- [`input_size`](#function-input_size)
- [`render_bounds`](#function-render_bounds)
- [`padding`](#function-padding)
- [`effect_bounds`](#function-effect_bounds)
- [`layer_scale`](#function-layer_scale)
- [`get_position`](#function-get_position)
- [`get_normalized_position`](#function-get_normalized_position)
- [`normalize`](#function-normalize)
- [`get_effect_position`](#function-get_effect_position)
- [`to_effect_space`](#function-to_effect_space)
- [`capture_pointer`](#function-capture_pointer)
- [`release_pointer_capture`](#function-release_pointer_capture)
- [`has_pointer_capture`](#function-has_pointer_capture)
- [`invalidate`](#function-invalidate)
- [`request_animation_frame`](#function-request_animation_frame)

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

### effect

```rust
fn effect(self: &Self) -> &'a Effect
```

The effect.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L129)

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

### host

```rust
fn host(self: &Self) -> &'a InputElement
```

The host: the input element the effect is the effect of.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L134)

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

### visual

```rust
fn visual(self: &Self) -> &'a Visual
```

The host as a visual.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L139)

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

### bounds

```rust
fn bounds(self: &Self) -> Rect
```

The bounds of the host, in the coordinates of its parent.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L144)

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

### size

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

The size of the host.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L149)

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

### input_bounds

```rust
fn input_bounds(self: &Self) -> Rect
```

The bounds the pointer is normalized to, in the host's coordinates: the
area the renderer drew the effect over without the padding of the
effect, so that the input and the program agree (#580; Effector normalizes to the content
of the host within its bounds and draws over the same rectangle); the host's own size, from
its top left corner, before the host was drawn.

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

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

### input_size

```rust
fn input_size(self: &Self) -> Size
```

The input size: the size of the input bounds.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L174)

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

### render_bounds

```rust
fn render_bounds(self: &Self) -> Option<Rect>
```

The rectangle the renderer drew the effect over in the last frame, in the host's
coordinates (#580): the bounds of the subtree of the host, the padding of the effect
included, as the compositor read them back. `None` before the host was drawn, for a host
that is not shown, and without a compositor.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L182)

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

### padding

```rust
fn padding(self: &Self) -> Thickness
```

The padding of the effect: how far its area reaches beyond the host's bounds.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L191)

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

### effect_bounds

```rust
fn effect_bounds(self: &Self) -> Rect
```

The area of the effect in the host's coordinates: the input bounds inflated by the padding
of the effect (the rectangle the renderer drew the effect over, once
the host was drawn).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L198)

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

### layer_scale

```rust
fn layer_scale(self: &Self) -> f64
```

Device pixels per device independent pixel of the host, as the render thread computes the
`layer_scale` of the effect: the render scaling of the host's presentation source times
the mean of the lengths of the axes of the transform from the host to the root. 1 for a
host that is not in a visual tree.

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

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

### get_position

```rust
fn get_position(self: &Self, e: &PointerEventArgs) -> Point
```

The position of the pointer of `e` in the host's coordinates.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L220)

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

### get_normalized_position

```rust
fn get_normalized_position(self: &Self, e: &PointerEventArgs, clamp: bool) -> Point
```

The position of the pointer of `e` normalized to the input bounds: 0 to 1 from the left
to the right and from the top to the bottom of the area the effect is drawn over, clamped
to 0..1 when `clamp` is set (Effector's `GetNormalizedPosition`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L227)

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

### normalize

```rust
fn normalize(self: &Self, position: Point, clamp: bool) -> Point
```

`position`, in the host's coordinates, normalized to the input bounds; an empty side
counts as one pixel.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L233)

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

### get_effect_position

```rust
fn get_effect_position(self: &Self, e: &PointerEventArgs) -> Point
```

The position of the pointer of `e` in the coordinates of the effect's program: device
pixels from the top left corner of the area of the effect.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L248)

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

### to_effect_space

```rust
fn to_effect_space(self: &Self, position: Point) -> Point
```

`position`, in the host's coordinates, in the coordinates of the effect's program.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L253)

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

### capture_pointer

```rust
fn capture_pointer(self: &Self, e: &PointerEventArgs)
```

Captures the pointer of `e` to the host, so that the host and the effect receive its
input wherever it is until it is released.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L261)

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

### release_pointer_capture

```rust
fn release_pointer_capture(self: &Self, e: &PointerEventArgs)
```

Releases the capture of the pointer of `e` when the host has it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L266)

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

### has_pointer_capture

```rust
fn has_pointer_capture(self: &Self, e: &PointerEventArgs) -> bool
```

Whether the host captures the pointer of `e`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L273)

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

### invalidate

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

Asks for a new snapshot of the effect: raises its
`invalidated` notification (Effector's `Invalidate`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L279)

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

### request_animation_frame

```rust
fn request_animation_frame(self: &Self, action: impl FnOnce(&EffectHostContext<'_>, SignedDuration) -> () + 'static)
```

Runs `action` on the next frame of the animation clock with the frame time, while the
effect is still the effect of the host: an effect that animates its uniforms (a ripple
that spreads) asks for one frame at a time. Nothing runs when the effect was detached
before the frame, or the host or the effect is gone.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/effect_input.rs#L287)

## 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/).
