# Styles

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/styling/struct-styles/

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

```rust
struct Styles
```

A style that consists of a number of child styles.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L22)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`with_owner`](#function-with_owner)
- [`collection_changed`](#function-collection_changed)
- [`owner_changed`](#function-owner_changed)
- [`count`](#function-count)
- [`owner`](#function-owner)
- [`resources`](#function-resources)
- [`set_resources`](#function-set_resources)
- [`has_resources`](#function-has_resources)
- [`get`](#function-get)
- [`set`](#function-set)
- [`snapshot`](#function-snapshot)
- [`try_get_resource`](#function-try_get_resource)
- [`add_range`](#function-add_range)
- [`insert_range`](#function-insert_range)
- [`move_item`](#function-move_item)
- [`move_range`](#function-move_range)
- [`remove_all`](#function-remove_all)
- [`remove_range`](#function-remove_range)
- [`index_of`](#function-index_of)
- [`insert`](#function-insert)
- [`remove_at`](#function-remove_at)
- [`add`](#function-add)
- [`clear`](#function-clear)
- [`contains`](#function-contains)
- [`remove`](#function-remove)
- [`add_owner`](#function-add_owner)
- [`remove_owner`](#function-remove_owner)

<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/styling/styles.rs#L32)

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

### to_ref

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

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L32)

<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/styling/styles.rs#L64)

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

### new

```rust
fn new() -> Ref<Self>
```

Creates an empty styles collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L77)

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

### with_owner

```rust
fn with_owner(owner: impl Into<ResourceHostRef>) -> Ref<Self>
```

Creates an empty styles collection that belongs to `owner`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L82)

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

### collection_changed

```rust
fn collection_changed(self: &Self, handler: impl Fn(&NotifyCollectionChangedEventArgs<'a, Rc<dyn IStyle>>) -> () + 'static) -> Rc<dyn IDisposable>
```

Raised when the collection changes. Disposing the returned handle
unsubscribes.

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

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

### owner_changed

```rust
fn owner_changed(self: &Self, handler: impl Fn() -> () + 'static) -> Rc<dyn IDisposable>
```

Raised when the owner of the collection changes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L104)

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

### count

```rust
fn count(self: &Self) -> usize
```

The number of styles.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L120)

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

### owner

```rust
fn owner(self: &Self) -> Option<ResourceHostRef>
```

The owner of the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L125)

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

### resources

```rust
fn resources(self: &Self) -> Ref<ResourceDictionary>
```

The dictionary of style resources.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L143)

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

### set_resources

```rust
fn set_resources(self: &Self, value: Ref<ResourceDictionary>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L152)

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

### has_resources

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

Whether the collection or any of its styles has resources.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L170)

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

### get

```rust
fn get(self: &Self, index: usize) -> Rc<dyn IStyle>
```

The style at `index`. Panics if out of range.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L186)

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

### set

```rust
fn set(self: &Self, index: usize, value: impl Into<Rc<dyn IStyle>>)
```

Replaces the style at `index`.

The replacement is notified as a removal followed by an insertion.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L193)

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

### snapshot

```rust
fn snapshot(self: &Self) -> Rc<Vec<Rc<dyn IStyle>>>
```

A snapshot of the styles.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L200)

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

### try_get_resource

```rust
fn try_get_resource(self: &Self, key: &ResourceKey, theme: Option<&ThemeVariant>) -> Option<ResourceValue>
```

Tries to find a resource in the collection's resources and then in
its styles, last style first.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L215)

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

### add_range

```rust
fn add_range(self: &Self, items: impl IntoIterator<Item = Rc<dyn IStyle>>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L234)

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

### insert_range

```rust
fn insert_range(self: &Self, index: usize, items: impl IntoIterator<Item = Rc<dyn IStyle>>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L238)

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

### move_item

```rust
fn move_item(self: &Self, old_index: usize, new_index: usize)
```



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

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

### move_range

```rust
fn move_range(self: &Self, old_index: usize, count: usize, new_index: usize)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L246)

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

### remove_all

```rust
fn remove_all(self: &Self, items: impl IntoIterator<Item = Rc<dyn IStyle>>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L250)

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

### remove_range

```rust
fn remove_range(self: &Self, index: usize, count: usize)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L256)

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

### index_of

```rust
fn index_of(self: &Self, item: impl Into<Rc<dyn IStyle>>) -> Option<usize>
```

The index of a style, if it is in the collection.

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

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

### insert

```rust
fn insert(self: &Self, index: usize, item: impl Into<Rc<dyn IStyle>>)
```



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

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

### remove_at

```rust
fn remove_at(self: &Self, index: usize)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L270)

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

### add

```rust
fn add(self: &Self, item: impl Into<Rc<dyn IStyle>>)
```

Adds a style to the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L275)

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

### clear

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

Removes all styles from the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L280)

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

### contains

```rust
fn contains(self: &Self, item: impl Into<Rc<dyn IStyle>>) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L284)

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

### remove

```rust
fn remove(self: &Self, item: impl Into<Rc<dyn IStyle>>) -> bool
```

Removes a style from the collection. Returns whether it was present.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L289)

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

### add_owner

```rust
fn add_owner(self: &Self, owner: &ResourceHostRef)
```

Adds an owner to the collection and the resource providers in it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L300)

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

### remove_owner

```rust
fn remove_owner(self: &Self, owner: &ResourceHostRef)
```

Removes the owner of the collection and the resource providers in it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/styles.rs#L319)

## 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<Styles>`](/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/)
- [`DefaultConstructible`](/docs/0.5.0/api/ferroui-base/trait-defaultconstructible/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)

## Availability

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