# StyleBase

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

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

```rust
struct StyleBase
```

Base class for `Style`, `ControlTheme`
and `ContainerQuery`.

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

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`set_parent`](#function-set_parent)
- [`to_display_string`](#function-to_display_string)
- [`construct`](#function-construct)
- [`children`](#function-children)
- [`owner`](#function-owner)
- [`owner_changed`](#function-owner_changed)
- [`parent`](#function-parent)
- [`resources`](#function-resources)
- [`set_resources`](#function-set_resources)
- [`setters`](#function-setters)
- [`add_setter`](#function-add_setter)
- [`clear_setters`](#function-clear_setters)
- [`add`](#function-add)
- [`animations`](#function-animations)
- [`add_animation`](#function-add_animation)
- [`clear_animations`](#function-clear_animations)
- [`add_child`](#function-add_child)
- [`add_style`](#function-add_style)
- [`try_get_resource`](#function-try_get_resource)
- [`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/style_base.rs#L38)

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

### to_ref

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

Returns a strong reference to this object.

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

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

### set_parent

```rust
fn set_parent(self: &Self, parent: Option<&Ref<StyleBase>>)
```

Sets the parent style. Called when the style is added to or
removed from the children of another style; validates that the
style can be nested in `parent`.

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

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

### to_display_string

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

A string describing the style: its selector, target type or
query.

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

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

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

### children

```rust
fn children(self: &Self) -> StyleChildren
```

The children of the style.

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

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

### owner

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

The owner of the style: the resource host whose styles collection the
style, or an ancestor of it, was added to.

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

<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 style changes.

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

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

### parent

```rust
fn parent(self: &Self) -> Option<Ref<StyleBase>>
```

The parent style, if the style is a nested style.

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

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

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

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

### setters

```rust
fn setters(self: &Self) -> FerroList<Rc<dyn SetterBase>>
```

The style's setters. The list is returned by handle: clones refer
to the same list.

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

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

### add_setter

```rust
fn add_setter(self: &Self, setter: Rc<dyn SetterBase>)
```

Adds a setter to the style.

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

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

### clear_setters

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

Removes all setters from the style.

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

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

### add

```rust
fn add(self: &Self, setter: Rc<dyn SetterBase>)
```

Adds a setter to the style.

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

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

### animations

```rust
fn animations(self: &Self) -> FerroList<Rc<dyn IAnimation>>
```

The style's animations. The list is returned by handle: clones
refer to the same list.

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

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

### add_animation

```rust
fn add_animation(self: &Self, animation: impl Into<Rc<dyn IAnimation>>)
```

Adds an animation to the style: it runs on every control the style
applies to, while the style is active.

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

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

### clear_animations

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

Removes all animations from the style.

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

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

### add_child

```rust
fn add_child(self: &Self, child: &BoxedValue)
```

Adds an untyped child: a setter is added to the setters, a style to
the child styles. Panics for anything else.

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

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

### add_style

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

Adds a child style.

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

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

### try_get_resource

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

Tries to find a resource in the style's resources and then in its
child styles.

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

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

### add_owner

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

Adds an owner to the style.

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

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

### remove_owner

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

Removes the owner of the style.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`StyleBaseImplExt`](/docs/0.5.0/api/ferroui-base/styling/trait-stylebaseimplext/)
- [`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<StyleBase>`](/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/)
- [`StyleBaseImpl`](/docs/0.5.0/api/ferroui-base/styling/trait-stylebaseimpl/)

## Availability

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