# MaterialPolicy

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

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

```rust
struct MaterialPolicy
```

The material policy (WinUI's `MaterialHelper`): materials are disabled,
and acrylic draws its fallback colour, while the energy saver is on, the
user turned transparency effects off, the effects are not fast enough,
or a test simulates it.

The settings come from the platform
(`IPlatformSettings::transparency_enabled` and
`IPlatformSettings::energy_saver_enabled`), read when the policy is
first asked and whenever the platform reports a change of either
(`IPlatformSettings::accessibility_settings_changed`,
`IPlatformSettings::energy_saver_changed`). The policy is
per thread, as the objects it serves.

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

## Members

- [`is_disabled_by_policy`](#function-is_disabled_by_policy)
- [`policy_changed`](#function-policy_changed)
- [`update_policy_status`](#function-update_policy_status)
- [`simulate_disabled_by_policy`](#function-simulate_disabled_by_policy)
- [`set_simulate_disabled_by_policy`](#function-set_simulate_disabled_by_policy)
- [`ignore_are_effects_fast`](#function-ignore_are_effects_fast)
- [`set_ignore_are_effects_fast`](#function-set_ignore_are_effects_fast)
- [`are_effects_fast`](#function-are_effects_fast)
- [`set_are_effects_fast`](#function-set_are_effects_fast)
- [`transparency_enabled`](#function-transparency_enabled)
- [`energy_saver_enabled`](#function-energy_saver_enabled)
- [`is_window_active`](#function-is_window_active)
- [`set_window_active`](#function-set_window_active)
- [`window_activation_changed`](#function-window_activation_changed)
- [`noise_brush`](#function-noise_brush)

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

### is_disabled_by_policy

```rust
fn is_disabled_by_policy() -> bool
```

Whether materials are disabled by the policy.

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

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

### policy_changed

```rust
fn policy_changed(handler: impl Fn(bool) -> () + 'static) -> Subscription
```

`PolicyChanged`: `handler` is called now with the current state, and
whenever the state changes. Dropping the returned guard removes the
handler; `Subscription::detach` keeps it for the life of the
thread.

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

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

### update_policy_status

```rust
fn update_policy_status()
```

Reads the settings of the platform again and tells the listeners
when the state changes.

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

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

### simulate_disabled_by_policy

```rust
fn simulate_disabled_by_policy() -> bool
```

`SimulateDisabledByPolicy`: whether a test makes the policy disable
materials.

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

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

### set_simulate_disabled_by_policy

```rust
fn set_simulate_disabled_by_policy(value: bool)
```



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

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

### ignore_are_effects_fast

```rust
fn ignore_are_effects_fast() -> bool
```

`IgnoreAreEffectsFast`: whether slow effects are ignored.

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

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

### set_ignore_are_effects_fast

```rust
fn set_ignore_are_effects_fast(value: bool)
```



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

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

### are_effects_fast

```rust
fn are_effects_fast() -> bool
```

Whether the effects of the renderer are fast enough for materials
(WinUI's `CompositionCapabilities.AreEffectsFast`); `true` unless a
platform or the application says otherwise.

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

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

### set_are_effects_fast

```rust
fn set_are_effects_fast(value: bool)
```



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

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

### transparency_enabled

```rust
fn transparency_enabled() -> bool
```

Whether the platform permits transparency effects, as the policy last
read it (`IPlatformSettings::transparency_enabled`; `true` without
platform settings).

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

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

### energy_saver_enabled

```rust
fn energy_saver_enabled() -> bool
```

Whether the energy saver is on, as the policy last read it
(`IPlatformSettings::energy_saver_enabled`; `false` without platform
settings).

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

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

### is_window_active

```rust
fn is_window_active() -> bool
```

Whether a window of the application is active: the acrylic of the
host backdrop falls back to its colour while none is (WinUI's
`AcrylicBrush` follows the activation of its window). `true` until a
window says otherwise.

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

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

### set_window_active

```rust
fn set_window_active(active: bool)
```

Records whether a window of the application is active, and tells the
listeners when it changed (the windows of `ferroui-controls` call it).

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

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

### window_activation_changed

```rust
fn window_activation_changed(handler: impl Fn(bool) -> () + 'static) -> Subscription
```

`handler` is called whenever `is_window_active`
changes. Dropping the returned guard removes the handler;
`Subscription::detach` keeps it for the life of the thread.

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

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

### noise_brush

```rust
fn noise_brush(compositor: &Rc<Compositor>) -> CompositionSurfaceBrush
```

The noise brush the materials share on `compositor` (WinUI's
`MaterialHelper.GetNoiseBrush`): a surface brush of the noise texture
that does not stretch and sits at the top left corner, which a border
effect tiles.

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

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