# Effect

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

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

```rust
struct Effect
```

Base class of the mutable effects.

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

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`construct`](#function-construct)
- [`construct_custom`](#function-construct_custom)
- [`construct_interactive`](#function-construct_interactive)
- [`is_custom`](#function-is_custom)
- [`is_interactive`](#function-is_interactive)
- [`input_handler`](#function-input_handler)
- [`custom_snapshot`](#function-custom_snapshot)
- [`affects_render`](#function-affects_render)
- [`raise_invalidated`](#function-raise_invalidated)
- [`invalidated`](#function-invalidated)
- [`parse`](#function-parse)

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

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

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

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

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<Effect>
```

Returns a strong reference to this object.

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

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

### construct

```rust
fn construct() -> Self
```

Creates the class data; see `FerroObject::construct`.

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

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

### construct_custom

```rust
fn construct_custom<T: CustomEffectClass>() -> Self
```

Creates the class data of a custom effect class `T` (#455, not from
upstream): its handle converts to `Rc<dyn IEffect>` as the built-in
effects do, and what crosses to the render thread is its snapshot,
`CustomEffectClass::to_custom_effect`. A property of `T` that
affects the effect is declared with `affects_render`
(or `T` calls `raise_invalidated` when a
value changes), so that a new snapshot is taken.

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

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

### construct_interactive

```rust
fn construct_interactive<T: CustomEffectClass + IEffectInputHandler>() -> Self
```

Creates the class data of an interactive custom effect class `T`
(#455, E7, not from upstream): a custom effect class
(`construct_custom`) that receives the
pointer input of the element it is the effect of, through
`IEffectInputHandler`. When it is set as the `Effect` of an input
element, the element routes its pointer events to it with an
`EffectHostContext`; when
it is replaced or cleared, the routing ends. The state the input
changes lives in `T`, which raises
`invalidated` so that the next snapshot carries it
to the render thread.

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

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

### is_custom

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

Whether the effect is a custom effect class
(`construct_custom`).

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

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

### is_interactive

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

Whether the effect is an interactive custom effect class
(`construct_interactive`).

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

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

### input_handler

```rust
fn input_handler(self: &Self) -> Option<&dyn IEffectInputHandler>
```

The input handler of an interactive custom effect class; `None` for
the other effects.

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

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

### custom_snapshot

```rust
fn custom_snapshot(self: &Self) -> Option<ImmutableCustomEffect>
```

The snapshot of a custom effect class; `None` for the built-in
effect classes.

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

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

### affects_render

```rust
fn affects_render<T: ObjectType + Upcast<Effect>>(properties: &[&'static FerroProperty])
```

Marks a property on a class deriving from `Effect` as affecting the
effect's visual appearance: a change raises
`invalidated`.

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

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

### raise_invalidated

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

Raises the invalidated notification.

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

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

### invalidated

```rust
fn invalidated(self: &Self, handler: impl Fn() -> () + 'static) -> Subscription
```

Subscribes to invalidation of the effect: raised when a change
requires the affected content to be redrawn. Dropping the returned
guard removes the handler; `Subscription::detach` keeps it for the
life of the effect.

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

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

### parse

```rust
fn parse(s: &str) -> Result<Rc<dyn IEffect>, FormatError>
```

Parses an effect: `blur(<radius>)`,
`drop-shadow(<offset-x> <offset-y> [<blur-radius> [<color>]])`, or a
registered custom effect, `<name>(<parameter>=<value>, ...)`
(`CustomEffectRegistry::parse`, #455).

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<Effect>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`IAffectsRender`](/docs/0.5.0/api/ferroui-base/media/trait-iaffectsrender/)

## Availability

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