# XamlLight

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

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

```rust
struct XamlLight
```

A light of the object model (WinUI `Microsoft.UI.Xaml.Media.XamlLight`).

A subclass gives the light an id (`get_id`) and
creates its composition light when the light is connected to the element
that holds it (`on_connected`), setting it
with `set_composition_light`. The light
then lights, in the subtree of that element:

- the elements that target its id (`add_target_element`):
  their composition visuals are targets of the composition light, which
  lights their content;
- the XAML brushes that target its id (`add_target_brush`):
  the scene lighting effects of those brushes receive the light.

The composition light is in the coordinates of the element that holds
it (its `CoordinateSpace` is the composition visual of that element).

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

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`get_id`](#function-get_id)
- [`on_connected`](#function-on_connected)
- [`on_disconnected`](#function-on_disconnected)
- [`construct`](#function-construct)
- [`id`](#function-id)
- [`composition_light`](#function-composition_light)
- [`set_composition_light`](#function-set_composition_light)
- [`host`](#function-host)
- [`is_connected`](#function-is_connected)
- [`add_target_element`](#function-add_target_element)
- [`remove_target_element`](#function-remove_target_element)
- [`add_target_brush`](#function-add_target_brush)
- [`remove_target_brush`](#function-remove_target_brush)

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

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

### to_ref

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

Returns a strong reference to this object.

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

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

### get_id

```rust
fn get_id(self: &Self) -> String
```

`GetId`: the id the elements and brushes the light lights target.

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

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

### on_connected

```rust
fn on_connected(self: &Self, new_element: &Visual)
```

`OnConnected`: the light is in the `Lights` of `new_element`, which
is in a visual tree.

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

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

### on_disconnected

```rust
fn on_disconnected(self: &Self, old_element: &Visual)
```

`OnDisconnected`: the light left `old_element`, or the element
left its visual tree.

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

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

### construct

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

Creates the class data.

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

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

### id

```rust
fn id(self: &Self) -> String
```

The id of the light (`GetId`).

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

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

### composition_light

```rust
fn composition_light(self: &Self) -> Option<Rc<CompositionLight>>
```

`CompositionLight`.

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

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

### set_composition_light

```rust
fn set_composition_light(self: &Self, light: Option<Rc<CompositionLight>>)
```

Sets the composition light (`None` removes it). While the light is
connected, the composition light is bound to the element that holds
it: its coordinate space is that element, and it lights the targets
of the id of the light in its subtree.

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

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

### host

```rust
fn host(self: &Self) -> Option<Ref<Visual>>
```

The element whose `Lights` holds the light, while it is connected.

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

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

### is_connected

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

Whether the light is connected to an element.

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

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

### add_target_element

```rust
fn add_target_element(id: &str, element: &Visual)
```

`AddTargetElement(id, element)`: the XAML lights of id `id` light
`element` (its content and its subtree) where it is in the subtree of
the element that holds them.

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

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

### remove_target_element

```rust
fn remove_target_element(id: &str, element: &Visual)
```

`RemoveTargetElement(id, element)`.

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

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

### add_target_brush

```rust
fn add_target_brush(id: &str, brush: &Rc<dyn IBrush>)
```

`AddTargetBrush(id, brush)`: the XAML lights of id `id` light `brush`
where it is drawn in the subtree of the element that holds them. Only
a XAML composition brush can be lit (its scene lighting effects
receive the light); other brushes are left as they are.

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

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

### remove_target_brush

```rust
fn remove_target_brush(id: &str, brush: &Rc<dyn IBrush>)
```

`RemoveTargetBrush(id, brush)`.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`XamlLightImplExt`](/docs/0.5.0/api/ferroui-base/media/trait-xamllightimplext/)
- [`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<XamlLight>`](/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/)
- [`XamlLightImpl`](/docs/0.5.0/api/ferroui-base/media/trait-xamllightimpl/)

## Availability

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