FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    StyledElement

    struct · ferroui-base · v0.5.0

    struct StyledElement
    

    Extends an Animatable with the following features:

    • An inherited DataContext.
    • Implements the logical tree.
    • A collection of class strings for custom styling.
    • Implements styling: tracks the frames applied by styles and themes.

    View source

    Members

    get_logical_ancestors

    fn get_logical_ancestors(self: &Self) -> LogicalAncestors
    

    Enumerates the ancestors of the element in the logical tree, from its parent to the root.

    Source

    get_self_and_logical_ancestors

    fn get_self_and_logical_ancestors(self: &Self) -> LogicalAncestors
    

    Enumerates the element and its ancestors in the logical tree.

    Source

    find_logical_ancestor_of_type

    fn find_logical_ancestor_of_type<T: ObjectType>(self: &Self, include_self: bool) -> Option<Ref<T>>
    

    Finds the first logical ancestor of class T, optionally starting with the element itself.

    Source

    get_logical_children

    fn get_logical_children(self: &Self) -> Rc<Vec<Ref<StyledElement>>>
    

    The logical children of the element.

    Source

    get_logical_descendants

    fn get_logical_descendants(self: &Self) -> LogicalDescendants
    

    Enumerates the descendants of the element in the logical tree, in depth-first pre-order.

    Source

    get_self_and_logical_descendants

    fn get_self_and_logical_descendants(self: &Self) -> LogicalDescendants
    

    Enumerates the element and its descendants in the logical tree, in depth-first pre-order.

    Source

    find_logical_descendant_of_type

    fn find_logical_descendant_of_type<T: ObjectType>(self: &Self, include_self: bool) -> Option<Ref<T>>
    

    Finds the first logical descendant of class T (depth first), optionally starting with the element itself.

    Source

    get_logical_parent

    fn get_logical_parent(self: &Self) -> Option<Ref<StyledElement>>
    

    The logical parent of the element.

    Source

    get_logical_parent_of_type

    fn get_logical_parent_of_type<T: ObjectType>(self: &Self) -> Option<Ref<T>>
    

    The logical parent of the element, if it is of class T.

    Source

    get_logical_siblings

    fn get_logical_siblings(self: &Self) -> Rc<Vec<Ref<StyledElement>>>
    

    The children of the logical parent of the element, including the element itself; empty when the element has no logical parent.

    Source

    is_logical_ancestor_of

    fn is_logical_ancestor_of(self: &Self, target: Option<&StyledElement>) -> bool
    

    Whether the element is a logical ancestor of target.

    Source

    TYPE

    const TYPE: &'static $crate::TypeInfo
    

    The runtime type of this class.

    Source

    to_ref

    fn to_ref(self: &Self) -> $crate::Ref<StyledElement>
    

    Returns a strong reference to this object.

    Source

    begin_init

    fn begin_init(self: &Self)
    

    Signals the beginning of a batch of initialization: styling is deferred until the matching end_init.

    Source

    try_end_init

    fn try_end_init(self: &Self) -> Result<(), InitializationError>
    

    Signals the end of a batch of initialization: the element is styled (if it is attached to a rooted logical tree) and initialized. A style or control theme that cannot be applied (two setters for the same property) is an error, the counterpart of the invalid operation EndInit raises in the managed original; what follows the failure is skipped. This is the overridable member; end_init is the form that panics on the error.

    Source

    logical_children_collection_changed

    fn logical_children_collection_changed(self: &Self, e: &NotifyCollectionChangedEventArgs<'_, Ref<StyledElement>>)
    

    Called when the logical children collection changes.

    Source

    on_attached_to_logical_tree

    fn on_attached_to_logical_tree(self: &Self, e: &LogicalTreeAttachmentEventArgs)
    

    Called when the styled element is added to a rooted logical tree.

    Source

    on_detached_from_logical_tree

    fn on_detached_from_logical_tree(self: &Self, e: &LogicalTreeAttachmentEventArgs)
    

    Called when the styled element is removed from a rooted logical tree.

    Source

    on_data_context_changed

    fn on_data_context_changed(self: &Self)
    

    Called when the data context changes.

    Source

    on_data_context_begin_update

    fn on_data_context_begin_update(self: &Self)
    

    Called when the data context begins updating.

    Source

    on_data_context_end_update

    fn on_data_context_end_update(self: &Self)
    

    Called when the data context finishes updating.

    Source

    on_initialized

    fn on_initialized(self: &Self)
    

    Called when the control finishes initialization.

    Source

    style_key_override

    fn style_key_override(self: &Self) -> &'static TypeInfo
    

    The type by which the element is styled. Defaults to the element's own type; override to be styled as a base class.

    Source

    on_control_theme_changed

    fn on_control_theme_changed(self: &Self)
    

    Called when the control theme changes.

    Source

    on_templated_parent_control_theme_changed

    fn on_templated_parent_control_theme_changed(self: &Self)
    

    Called when the templated parent's control theme changes.

    Source

    invalidate_styles

    fn invalidate_styles(self: &Self, recurse: bool)
    

    Detaches all styles from the element (and optionally from its inheritance children) so that they are re-applied.

    Source

    is_logical_root

    fn is_logical_root(self: &Self) -> bool
    

    Whether the element is the root of a logical tree.

    Source

    styling_parent

    fn styling_parent(self: &Self) -> Option<StyleHostRef>
    

    The parent style host of the element: by default the inheritance parent, when it is a styled element. The root of a tree overrides this to return the host of the global styles.

    Source

    notify_child_resources_changed

    fn notify_child_resources_changed(self: &Self, e: ResourcesChangedEventArgs)
    

    Notifies the children of the element that the resources visible to them have changed. The base method notifies the logical children.

    Source

    child_index_provider

    fn child_index_provider(self: &Self) -> Option<Rc<dyn IChildIndexProvider>>
    

    The child index provider implemented by the element, if any. Used to match the children of the element by their position.

    Source

    is_theme_variant_root

    fn is_theme_variant_root(self: &Self) -> bool
    

    Whether the element is a root of theme variant resolution: at a root the default theme variant resolves to the variant of the platform instead of being inherited.

    Source

    data_context_property

    fn data_context_property() -> &'static StyledProperty<Option<BoxedValue>>
    

    Defines the DataContext property.

    Source

    name_property

    fn name_property() -> &'static DirectProperty<StyledElement, Option<String>>
    

    Defines the Name property.

    Source

    parent_property

    fn parent_property() -> &'static DirectProperty<StyledElement, Option<Ref<StyledElement>>>
    

    Defines the Parent property.

    Source

    templated_parent_property

    fn templated_parent_property() -> &'static DirectProperty<StyledElement, Option<Ref<FerroObject>>>
    

    Defines the TemplatedParent property.

    Source

    theme_property

    fn theme_property() -> &'static StyledProperty<Option<Ref<ControlTheme>>>
    

    Defines the Theme property.

    Source

    construct

    fn construct() -> Self
    

    Creates the class data; see FerroObject::construct.

    Source

    new

    fn new() -> Ref<Self>
    

    Source

    attached_to_logical_tree

    fn attached_to_logical_tree(self: &Self, handler: impl Fn(&LogicalTreeAttachmentEventArgs) -> () + 'static) -> Subscription
    

    Raised when the styled element is attached to a rooted logical tree.

    Source

    detached_from_logical_tree

    fn detached_from_logical_tree(self: &Self, handler: impl Fn(&LogicalTreeAttachmentEventArgs) -> () + 'static) -> Subscription
    

    Raised when the styled element is detached from a rooted logical tree.

    Source

    data_context_changed

    fn data_context_changed(self: &Self, handler: impl Fn() -> () + 'static) -> Subscription
    

    Occurs when the data context property changes.

    Source

    initialized

    fn initialized(self: &Self, handler: impl Fn() -> () + 'static) -> Subscription
    

    Occurs when the styled element has finished initialization.

    Source

    resources_changed

    fn resources_changed(self: &Self, handler: impl Fn(&ResourcesChangedEventArgs) -> () + 'static) -> Subscription
    

    Raised when the resources change on the element or an ancestor of the element.

    Source

    actual_theme_variant_changed

    fn actual_theme_variant_changed(self: &Self, handler: impl Fn() -> () + 'static) -> Subscription
    

    Raised when the theme variant in effect for the element changes.

    Source

    name

    fn name(self: &Self) -> Option<String>
    

    The name of the styled element.

    An element's name is used to uniquely identify it within its name scope. Once the element has been styled its name may not be changed.

    Source

    has_name

    fn has_name(self: &Self, name: &str) -> bool
    

    Whether the name of the styled element is name, without a copy of the name (the name selectors of styles test it for every element they are evaluated on).

    Source

    set_name

    fn set_name(self: &Self, value: Option<String>)
    

    Source

    classes

    fn classes(self: &Self) -> Classes
    

    The styled element's classes.

    The collection is returned by handle: clones refer to the same collection.

    Source

    pseudo_classes

    fn pseudo_classes(self: &Self) -> &dyn IPseudoClasses
    

    The pseudoclasses of the element, settable by the control itself.

    Source

    set_pseudo_class

    fn set_pseudo_class(self: &Self, name: &str, value: bool)
    

    Adds or removes a pseudoclass. Removing one from an element whose classes were never made makes nothing: an element without classes holds none to remove. An addition (FerroUI deviation, desktop-performance.md section 9.21): every input element removed its focus, pointer-over and disabled pseudoclasses when constructed, which made its collection of classes (three allocations) whether it would ever have a class or not.

    Source

    data_context

    fn data_context(self: &Self) -> Option<BoxedValue>
    

    The control's data context.

    The data context is an inherited property that specifies the default object that will be used for data binding.

    Source

    set_data_context

    fn set_data_context(self: &Self, value: Option<BoxedValue>)
    

    Source

    is_initialized

    fn is_initialized(self: &Self) -> bool
    

    Whether the element has finished initialization.

    For more information about when this happens, see the initialized event.

    Source

    styles

    fn styles(self: &Self) -> Ref<Styles>
    

    The styles for the styled element.

    Styles for the entire application are added to the application's styles collection.

    Source

    is_styles_initialized

    fn is_styles_initialized(self: &Self) -> bool
    

    Whether the styles collection of the element has been created.

    Source

    style_key

    fn style_key(self: &Self) -> &'static TypeInfo
    

    The type by which the element is styled.

    Source

    resources

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

    The styled element's resource dictionary.

    Source

    resources_if_created

    fn resources_if_created(self: &Self) -> Option<Ref<ResourceDictionary>>
    

    The resource dictionary of the element if it has been created; unlike resources, this does not create one.

    Source

    set_resources

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

    Source

    theme

    fn theme(self: &Self) -> Option<Ref<ControlTheme>>
    

    The theme to be applied to the element.

    By default the theme is looked up as a resource keyed by the element's style key; setting this property takes precedence over that lookup.

    Source

    set_theme

    fn set_theme(self: &Self, value: impl Into<Nullable<ControlTheme>>)
    

    Source

    actual_theme_variant

    fn actual_theme_variant(self: &Self) -> Option<ThemeVariant>
    

    The UI theme variant that is currently used by the element, which might be different than the requested theme variant. None until a theme variant has been established for the element or an ancestor.

    Source

    has_resources

    fn has_resources(self: &Self) -> bool
    

    Whether the element or its styles have resources.

    Source

    try_get_resource

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

    Tries to find a resource within the element: in its resource dictionary, then in its styles.

    Source

    try_find_resource

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

    Tries to find a resource by searching up the logical tree and then the global styles.

    Source

    find_resource

    fn find_resource(self: &Self, key: &ResourceKey) -> ResourceValue
    

    Finds a resource by searching up the logical tree and then the global styles. Returns the unset value marker if it is not found.

    Source

    templated_parent

    fn templated_parent(self: &Self) -> Option<Ref<FerroObject>>
    

    The styled element whose lookless template this element is part of.

    Source

    set_templated_parent

    fn set_templated_parent(self: &Self, value: impl Into<Nullable<FerroObject>>)
    

    Sets the templated parent. Called by the template that creates the element.

    Source

    logical_children

    fn logical_children(self: &Self) -> &FerroList<Ref<StyledElement>>
    

    The styled element's logical children.

    Source

    is_attached_to_logical_tree

    fn is_attached_to_logical_tree(self: &Self) -> bool
    

    Whether the element is attached to a rooted logical tree.

    Source

    parent

    fn parent(self: &Self) -> Option<Ref<StyledElement>>
    

    The styled element's logical parent.

    Source

    apply_styling

    fn apply_styling(self: &Self) -> bool
    

    Applies styling to the control if the control is initialized and styling is not already applied.

    The styling system will automatically apply styling when required, so this method need only be called by tests or in rare special cases.

    Returns true if styling is applied to the control, false if the control is still initializing.

    Source

    try_apply_styling

    fn try_apply_styling(self: &Self) -> Result<bool, DuplicateSetterError>
    

    As apply_styling, reporting a style or control theme that cannot be applied (two setters for the same property: the invalid operation of the managed original) instead of panicking. After an error the styling pass is ended and the element is not marked as styled, as when the managed original throws.

    Source

    end_init

    fn end_init(self: &Self)
    

    Signals the end of a batch of initialization (try_end_init). A style or control theme that cannot be applied panics with the message of the error.

    Source

    initialize_if_needed

    fn initialize_if_needed(self: &Self)
    

    Marks the element as initialized and raises the initialization notifications, if initialization is complete.

    Source

    set_parent

    fn set_parent(self: &Self, parent: impl Into<Nullable<StyledElement>>)
    

    Sets the element's logical parent.

    You should not usually need to call this method: it is called when an element is added to or removed from a logical children collection.

    Source

    notify_attached_to_logical_tree

    fn notify_attached_to_logical_tree(self: &Self, e: &LogicalTreeAttachmentEventArgs)
    

    Notifies the element that it has been attached to a rooted logical tree. Called by a parent for children that are part of its logical tree without being in its logical children collection (the template child of a templated control).

    Source

    notify_detached_from_logical_tree

    fn notify_detached_from_logical_tree(self: &Self, e: &LogicalTreeAttachmentEventArgs)
    

    Notifies the element that it has been detached from a rooted logical tree. See notify_attached_to_logical_tree.

    Source

    get_effective_theme

    fn get_effective_theme(self: &Self) -> Option<Ref<ControlTheme>>
    

    The theme in effect for the element: the Theme property if set, otherwise the control theme resource keyed by the element's style key that is visible to the element (a resource holding a Ref<ControlTheme>).

    Source

    styles_added

    fn styles_added(self: &Self, styles: &[Rc<dyn IStyle>])
    

    Called when styles are added to the styles collection of the element or a nested styles collection.

    Source

    styles_removed

    fn styles_removed(self: &Self, styles: &[Rc<dyn IStyle>])
    

    Called when styles are removed from the styles collection of the element or a nested styles collection.

    Source

    notify_resources_changed

    fn notify_resources_changed(self: &Self, e: ResourcesChangedEventArgs, propagate: bool)
    

    Notifies the element, and with propagate its children, that the resources visible to it have changed.

    Source

    set_data_context_with_priority

    fn set_data_context_with_priority(self: &Self, value: Option<BoxedValue>, priority: BindingPriority) -> Option<Rc<dyn IDisposable>>
    

    The priority-aware setter used by templates.

    Source

    bind_class

    fn bind_class(self: &Self, class_name: &str, source: &dyn BindingBase, anchor: Option<&Ref<FerroObject>>) -> Rc<dyn BindingExpressionBase>
    

    Binds the presence of the class class_name on this element to source. anchor provides the context the binding locates its source with when the element cannot.

    Source

    get_class_property

    fn get_class_property(class_name: &str) -> &'static FerroProperty
    

    The property a binding to the class class_name is set on.

    Source

    Trait implementations

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.