# theme_roots

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-build/theme_roots/

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

```rust
module theme_roots
```

The units of the themes an application keeps (#568, steps 3 and 4 of
docs/porting/theme-trimming.md): the opt-in of the application, its roots, and the closure of
the roots over the unit graph of a theme.

Not a port of an upstream file. A theme whose compiled markup is partitioned into units states
its unit graph in its `.xamlmeta` (`theme_units`: for each unit the keys and type keys it
defines, the keys it references and the types it constructs or selects). An application (unless
`[package.metadata.ferroui] theme-trimming = false` in its manifest turns it off) constructs the
theme from the units its build computes here:

- **Roots.** The types the compiled documents of the application construct, select or name in
  `{x:Type}`, with their base classes (from the type models); every token of the documents that
  may name a key; the names of `theme-roots = ["Name", ..]` (a unit, by the path of its
  document, or a type or a key); the names and string literals of the Rust sources of the
  application ([`source_roots`](/docs/0.5.0/api/ferroui-build/theme_roots/function-source_roots/): a name that is a type key or a class, a string that is a key);
  and the roots a build script adds (`Roots::extend`). `theme-roots = "all"` and a build with
  `ferroui-base/full-themes` (`DEP_FERROUI_BASE_XAML_FULL_THEMES`: the run-time loader, hot
  reload, the designer, DevTools, Inspect) keep every unit. What the compiled documents of the
  dependencies name is a root too (the `references` of their `.xamlmeta`).
- **Live types.** A live type makes its base classes live, and the classes its code creates
  (the creates edges of the type models, `TypeModel::creates`: `ListBox` creates
  `ListBoxItem`), transitively (`TypeGraph::live`).
- **Closure.** The ambient unit (index 0) is always kept. A unit is kept when it defines a live
  key or the type key of a live type, or is named. A kept unit makes its references live keys
  (`StaticResource`, `DynamicResource`, `BasedOn`, `Theme` and every other mention of a key) and
  its types live types: the types its templates construct root their own control themes.

The result is the canonical indices of the kept units, ascending: the order of the table the
build writes and `with_parts` takes.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/theme_roots.rs#L1)

## Contents

- [`MANIFEST_TABLE`](/docs/0.5.0/api/ferroui-build/theme_roots/constant-manifest_table/) — constant
- [`TRIMMING_KEY`](/docs/0.5.0/api/ferroui-build/theme_roots/constant-trimming_key/) — constant
- [`ROOTS_KEY`](/docs/0.5.0/api/ferroui-build/theme_roots/constant-roots_key/) — constant
- [`COMPILE_BINDINGS_KEY`](/docs/0.5.0/api/ferroui-build/theme_roots/constant-compile_bindings_key/) — constant
- [`compile_bindings_from_manifest`](/docs/0.5.0/api/ferroui-build/theme_roots/function-compile_bindings_from_manifest/) — function
- [`ThemeTrimming`](/docs/0.5.0/api/ferroui-build/theme_roots/struct-themetrimming/) — struct
- [`Roots`](/docs/0.5.0/api/ferroui-build/theme_roots/struct-roots/) — struct
- [`TypeGraph`](/docs/0.5.0/api/ferroui-build/theme_roots/struct-typegraph/) — struct
- [`source_roots`](/docs/0.5.0/api/ferroui-build/theme_roots/function-source_roots/) — function
- [`kept_units`](/docs/0.5.0/api/ferroui-build/theme_roots/function-kept_units/) — function
- [`parts_static_name`](/docs/0.5.0/api/ferroui-build/theme_roots/function-parts_static_name/) — function
- [`unit_static_path`](/docs/0.5.0/api/ferroui-build/theme_roots/function-unit_static_path/) — function

## Availability

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