ThemeVariant
struct · ferroui-base · v0.5.0
struct ThemeVariant
Specifies a UI theme variant that should be used for the control and application types.
Theme variants are compared by their key.
Members
newdefaultlightdarkactual_theme_variant_propertyrequested_theme_variant_propertykeyinherit_variantupdate_actual_theme_variantregister_theme_variant_root_typeto_platform_theme_variant
new
fn new(key: impl Into<ResourceKey>, inherit_variant: Option<ThemeVariant>) -> Self
Creates a theme variant.
key is the key of the custom theme variant. inherit_variant is the
variant that this variant inherits from: if set, a resource that is
missing from the theme dictionary of the current variant is looked up
in the dictionary of the inherited one. Inheriting the default variant
is not supported.
default
fn default() -> ThemeVariant
Use the default theme variant: inherit the variant from the parent, and at the root use the variant of the platform.
light
fn light() -> ThemeVariant
Use the Light theme variant.
dark
fn dark() -> ThemeVariant
Use the Dark theme variant.
actual_theme_variant_property
fn actual_theme_variant_property() -> &'static StyledProperty<Option<ThemeVariant>>
Defines the ActualThemeVariant property: the theme variant in
effect for an element, inherited down the tree. It is None
until a root or an element with a requested variant sets it.
requested_theme_variant_property
fn requested_theme_variant_property() -> &'static StyledProperty<Option<ThemeVariant>>
Defines the RequestedThemeVariant property: the theme variant requested for an element and its descendants.
key
fn key(self: &Self) -> &ResourceKey
Key of the theme variant by which variants are compared.
inherit_variant
fn inherit_variant(self: &Self) -> Option<ThemeVariant>
The theme variant that this variant inherits from.
update_actual_theme_variant
fn update_actual_theme_variant(target: &FerroObject)
Updates the actual theme variant of target from its requested
theme variant: a requested variant other than the default becomes the
actual one, otherwise the actual variant is inherited.
register_theme_variant_root_type
fn register_theme_variant_root_type(type_: &'static TypeInfo)
Declares that the objects of a class that is not a styled element
(the application class) are roots of theme variant resolution.
Styled elements say so through the is_theme_variant_root virtual.
(Upstream: the IThemeVariantRoot interface.)
to_platform_theme_variant
fn to_platform_theme_variant(theme_variant: Option<&ThemeVariant>) -> Option<PlatformThemeVariant>
The platform theme variant of a theme variant (the original's explicit conversion to a nullable platform theme variant): the light and the dark variant convert to their counterparts, another variant converts as the variant it inherits from, and a variant that inherits from neither, or no variant, converts to nothing.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeResourceKeyObjectPropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedToStringErasedDestructorIntoEitherCloneFrom<PlatformThemeVariant>DefaultPartialEqEqHashDisplayDebugFromStrMarkupTypedValueTypeRegistration
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.