WinUITheme
struct · ferroui-themes-winui · v0.5.0
struct WinUITheme
Includes the WinUI theme in an application.
Members
TYPEto_refdensity_style_propertyDOCUMENT_URIhigh_contrastconstructnewwith_service_providerwith_partsdensity_styleset_density_styletry_get_resourceas_styleas_resource_provider
TYPE
const TYPE: &'static $crate::TypeInfo
The runtime type of this class.
to_ref
fn to_ref(self: &Self) -> $crate::Ref<WinUITheme>
Returns a strong reference to this object.
density_style_property
fn density_style_property() -> &'static DirectProperty<WinUITheme, DensityStyle>
Defines the DensityStyle property.
DOCUMENT_URI
const DOCUMENT_URI: &'static str
The URI of the document of the class.
high_contrast
fn high_contrast() -> ThemeVariant
The high contrast theme variant of the theme: the HighContrast theme dictionaries of
WinUI. Request it like the light and dark variants
(window.set_requested_theme_variant(Some(WinUITheme::high_contrast())), or
RequestedThemeVariant="{x:Static winui:WinUITheme.HighContrast}" in markup). It inherits
the dark variant, which the platform is told of (the colours of its dictionaries are the
ones of the "High Contrast Black" theme of Windows).
construct
fn construct() -> Self
Field initialisation; see Styles::construct. Registers the
acrylic of the theme for the prewarm of the GPU programs, made after
the first frame of a window rather than when a pane, a flyout or a
menu first shows the material (#437).
new
fn new() -> Ref<Self>
Creates the theme.
Panics
Panics if the documents of the theme fail to load.
with_service_provider
fn with_service_provider(sp: Option<Rc<dyn IServiceProvider>>) -> Ref<Self>
Creates the theme; sp is the parent's service provider.
The full theme: every unit of its compiled markup. A later load of the theme by URI gets the full theme too, unless the application registered the units it keeps.
Panics
Panics if the documents of the theme fail to load, or if the loaded document lacks the compact styles.
with_parts
fn with_parts(sp: Option<Rc<dyn IServiceProvider>>, parts: rt::ThemeParts) -> Ref<Self>
Creates the theme from some of the units of its compiled markup (#568, step 3 of
docs/porting/theme-trimming.md); sp is the parent's service provider.
parts are units of crate::compiled_xaml::THEME_UNITS, in canonical order (ascending
indices), with the ambient unit (index 0) first: the table an application's build writes
when it trims its themes (the default; [package.metadata.ferroui] theme-trimming = false
turns it off). The theme
applies those units, at the places of the full theme and in its order; a unit that parts
leaves out adds nothing. Only the units named are linked into the application. In debug
builds a lookup of a control theme that parts left out logs once that it was trimmed.
Panics
Panics if the documents of the theme fail to load, or if the loaded
document lacks the compact styles (parts without the ambient unit).
density_style
fn density_style(self: &Self) -> DensityStyle
The density style of the theme (normal, compact).
set_density_style
fn set_density_style(self: &Self, value: DensityStyle)
try_get_resource
fn try_get_resource(self: &Self, key: &ResourceKey, theme: Option<&ThemeVariant>) -> Option<ResourceValue>
Tries to find a resource within the theme: the compact resources are checked first when the density style is compact.
as_style
fn as_style(self: &Self) -> Rc<dyn IStyle>
The theme as a style, for the style collections of applications and
elements (application.styles().add(theme.as_style())).
as_resource_provider
fn as_resource_provider(self: &Self) -> Rc<dyn IResourceProvider>
The theme as a resource provider.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>ReceiverAnyFerroObjectImplExtClassDefaultsErasedDestructorIntoEitherDerefUpcast<T>Upcast<WinUITheme>StaticTypeObjectTypeSubclassable<T>DefaultConstructibleFerroObjectImpl
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.