# IconSource

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/struct-iconsource/

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

```rust
struct IconSource
```

The base class of the descriptions of an icon that can be shared (WinUI's `IconSource`): each
`create_icon_element` creates a new icon element, and a later
change of a property of the source is set on every element it created that is still alive.

The source holds its elements weakly and does not subscribe to them, so neither keeps the
other alive. This class is abstract: it creates no element (`create_icon_element` is `None`,
as WinUI's base returns no element); the derived sources create theirs.



[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/icon_source.rs#L30)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`create_icon_element_core`](#function-create_icon_element_core)
- [`get_icon_element_property_core`](#function-get_icon_element_property_core)
- [`foreground_property`](#function-foreground_property)
- [`construct`](#function-construct)
- [`foreground`](#function-foreground)
- [`set_foreground`](#function-set_foreground)
- [`create_icon_element`](#function-create_icon_element)

<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.Controls/icon_source.rs#L35)

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

### to_ref

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

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/icon_source.rs#L35)

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

### create_icon_element_core

```rust
fn create_icon_element_core(self: &Self) -> Option<Ref<IconElement>>
```

Creates the icon element of the source with the values of its properties
(`CreateIconElementCore`); `None` for the abstract base.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/icon_source.rs#L35)

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

### get_icon_element_property_core

```rust
fn get_icon_element_property_core(self: &Self, property: &'static FerroProperty) -> Option<&'static FerroProperty>
```

The property of the icon elements that a property of the source is set on
(`GetIconElementPropertyCore`); `None` for a property that is not.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/icon_source.rs#L35)

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

### foreground_property

```rust
fn foreground_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
```

Defines the `Foreground` property: the foreground of the icons. Unset (`None`, the
default), an icon keeps the foreground it inherits.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/icon_source.rs#L102)

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

### construct

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/icon_source.rs#L111)

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

### foreground

```rust
fn foreground(self: &Self) -> Option<Rc<dyn IBrush>>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/icon_source.rs#L118)

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

### set_foreground

```rust
fn set_foreground(self: &Self, value: Option<Rc<dyn IBrush>>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/icon_source.rs#L121)

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

### create_icon_element

```rust
fn create_icon_element(self: &Self) -> Option<Ref<IconElement>>
```

Creates an icon element with the values of the source (`IconSource::CreateIconElement`):
the foreground only when the source has one, so that an icon without inherits its
foreground. `None` for a source that creates no element.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/icon_source.rs#L128)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`IconSourceImplExt`](/docs/0.5.0/api/ferroui-controls/trait-iconsourceimplext/)
- `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`
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<IconSource>`](/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/)
- [`IconSourceImpl`](/docs/0.5.0/api/ferroui-controls/trait-iconsourceimpl/)

## Availability

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