Struct Element

Source
pub struct Element {
Show 25 fields pub id: SmolStr, pub base_type: ElementType, pub bindings: BindingsMap, pub change_callbacks: BTreeMap<SmolStr, RefCell<Vec<Expression>>>, pub property_analysis: RefCell<HashMap<SmolStr, PropertyAnalysis>>, pub children: Vec<ElementRc>, pub enclosing_component: Weak<Component>, pub property_declarations: BTreeMap<SmolStr, PropertyDeclaration>, pub named_references: NamedReferenceContainer, pub repeated: Option<RepeatedElementInfo>, pub is_component_placeholder: bool, pub states: Vec<State>, pub transitions: Vec<Transition>, pub child_of_layout: bool, pub layout_info_prop: Option<(NamedReference, NamedReference)>, pub default_fill_parent: (bool, bool), pub accessibility_props: AccessibilityProps, pub geometry_props: Option<GeometryProps>, pub is_flickable_viewport: bool, pub has_popup_child: bool, pub item_index: OnceCell<u32>, pub item_index_of_first_children: OnceCell<u32>, pub is_legacy_syntax: bool, pub inline_depth: i32, pub debug: Vec<ElementDebugInfo>,
}
Expand description

An Element is an instantiation of a Component

Fields§

§id: SmolStr

The id as named in the original .slint file.

Note that it can only be used for lookup before inlining. After inlining there can be duplicated id in the component. The id are then re-assigned unique id in the assign_id pass

§base_type: ElementType§bindings: BindingsMap

Currently contains also the callbacks. FIXME: should that be changed?

§change_callbacks: BTreeMap<SmolStr, RefCell<Vec<Expression>>>§property_analysis: RefCell<HashMap<SmolStr, PropertyAnalysis>>§children: Vec<ElementRc>§enclosing_component: Weak<Component>

The component which contains this element.

§property_declarations: BTreeMap<SmolStr, PropertyDeclaration>§named_references: NamedReferenceContainer

Main owner for a reference to a property.

§repeated: Option<RepeatedElementInfo>

This element is part of a for <xxx> in <model>:

§is_component_placeholder: bool

This element is a placeholder to embed an Component at

§states: Vec<State>§transitions: Vec<Transition>§child_of_layout: bool

true when this item’s geometry is handled by a layout

§layout_info_prop: Option<(NamedReference, NamedReference)>

The property pointing to the layout info. (horizontal, vertical)

§default_fill_parent: (bool, bool)

Whether we have preferred-{width,height}: 100%

§accessibility_props: AccessibilityProps§geometry_props: Option<GeometryProps>

Reference to the property. This is always initialized from the element constructor, but is Option because it references itself

§is_flickable_viewport: bool

true if this Element is the fake Flickable viewport

§has_popup_child: bool

true if this Element may have a popup as child meaning it cannot be optimized because the popup references it.

§item_index: OnceCell<u32>

This is the component-local index of this item in the item tree array. It is generated after the last pass and before the generators run.

§item_index_of_first_children: OnceCell<u32>

the index of the first children in the tree, set with item_index

§is_legacy_syntax: bool

True when this element is in a component was declared with the := symbol instead of the component keyword

§inline_depth: i32

How many times the element was inlined

§debug: Vec<ElementDebugInfo>

Debug information about this element.

There can be several in case of inlining or optimization (child merged into their parent).

The order in the list is first the parent, and then the removed children.

Implementations§

Source§

impl Element

Source

pub fn make_rc(self) -> ElementRc

Source

pub fn from_node( node: Element, id: SmolStr, parent_type: ElementType, component_child_insertion_point: &mut Option<ChildrenInsertionPoint>, is_legacy_syntax: bool, diag: &mut BuildDiagnostics, tr: &TypeRegister, ) -> ElementRc

Source

pub fn lookup_property<'a>(&self, name: &'a str) -> PropertyLookupResult<'a>

Return the type of a property in this element or its base, along with the final name, in case the provided name points towards a property alias. Type::Invalid is returned if the property does not exist.

Source

pub fn native_class(&self) -> Option<Rc<NativeClass>>

Source

pub fn builtin_type(&self) -> Option<Rc<BuiltinElement>>

Source

pub fn layout_info_prop( &self, orientation: Orientation, ) -> Option<&NamedReference>

Source

pub fn original_name(&self) -> SmolStr

Returns the element’s name as specified in the markup, not normalized.

Source

pub fn is_binding_set( self: &Element, property_name: &str, need_explicit: bool, ) -> bool

Return true if the binding is set, either on this element or in a base

If need_explicit is true, then only consider binding set in the code, not the ones set by the compiler later.

Source

pub fn set_binding_if_not_set( &mut self, property_name: SmolStr, expression_fn: impl FnOnce() -> Expression, ) -> bool

Set the property property_name of this Element only if it was not set. the expression_fn will only be called if it isn’t set

returns true if the binding was changed

Source

pub fn sub_component(&self) -> Option<&Rc<Component>>

Source

pub fn element_infos(&self) -> String

Trait Implementations§

Source§

impl Debug for Element

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Element

Source§

fn default() -> Element

Returns the “default value” for a type. Read more
Source§

impl Spanned for Element

Auto Trait Implementations§

§

impl !Freeze for Element

§

impl !RefUnwindSafe for Element

§

impl !Send for Element

§

impl !Sync for Element

§

impl Unpin for Element

§

impl !UnwindSafe for Element

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,