Skip to main content

Component

Struct Component 

Source
pub struct Component {
Show 16 fields pub node: Option<Component>, pub id: SmolStr, pub root_element: ElementRc, pub parent_element: RefCell<ElementWeak>, pub optimized_elements: RefCell<Vec<ElementRc>>, pub root_constraints: RefCell<LayoutConstraints>, pub child_insertion_point: RefCell<Option<ChildrenInsertionPoint>>, pub init_code: RefCell<InitCode>, pub popup_windows: RefCell<Vec<PopupWindow>>, pub timers: RefCell<Vec<Timer>>, pub menu_item_tree: RefCell<Vec<Rc<Component>>>, pub inherits_popup_window: Cell<bool>, pub exported_global_names: RefCell<Vec<ExportedName>>, pub used: Cell<bool>, pub private_properties: RefCell<Vec<(SmolStr, Type)>>, pub from_library: Cell<bool>,
}
Expand description

A component is a type in the language which can be instantiated, Or is materialized for repeated expression.

Fields§

§node: Option<Component>§id: SmolStr§root_element: ElementRc§parent_element: RefCell<ElementWeak>

The parent element within the parent component if this component represents a repeated element

§optimized_elements: RefCell<Vec<ElementRc>>

List of elements that are not attached to the root anymore because they have been optimized away, but their properties may still be in use

§root_constraints: RefCell<LayoutConstraints>

The layout constraints of the root item

§child_insertion_point: RefCell<Option<ChildrenInsertionPoint>>

When creating this component and inserting “children”, append them to the children of the element pointer to by this field.

§init_code: RefCell<InitCode>§popup_windows: RefCell<Vec<PopupWindow>>§timers: RefCell<Vec<Timer>>§menu_item_tree: RefCell<Vec<Rc<Component>>>§inherits_popup_window: Cell<bool>

This component actually inherits PopupWindow (although that has been changed to a Window by the lower_popups pass)

§exported_global_names: RefCell<Vec<ExportedName>>

The names under which this component should be accessible if it is a global singleton and exported.

§used: Cell<bool>

True if this component is used as a sub-component by at least one other component.

§private_properties: RefCell<Vec<(SmolStr, Type)>>

The list of properties (name and type) declared as private in the component. This is used to issue better error in the generated code if the property is used.

§from_library: Cell<bool>

True if this component is imported from an external library.

Implementations§

Source§

impl Component

Source

pub fn from_node( node: Component, diag: &mut BuildDiagnostics, tr: &TypeRegister, ) -> Rc<Self>

Source

pub fn is_global(&self) -> bool

This component is a global component introduced with the “global” keyword

Source

pub fn is_interface(&self) -> bool

This is an interface introduced with the “interface” keyword

Source

pub fn inherits_system_tray_icon(&self) -> bool

True if this component’s root resolves to the SystemTrayIcon native class. Uses native_class() rather than builtin_type() so the check still matches once the root has been resolved to Native(SystemTrayIcon) after resolve_native_classes.

Source

pub fn global_aliases(&self) -> Vec<SmolStr>

Returns the names of aliases to global singletons, exactly as specified in the .slint markup (not normalized).

Source

pub fn repeater_count(&self) -> u32

Source

pub fn parent_element(&self) -> Option<ElementRc>

Convenience accessor to get the parent element if this component is a repeated component, or None otherwise.

§Panics

Panics if the Self::parent_element member is currently mutably borrowed

Trait Implementations§

Source§

impl Debug for Component

Source§

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

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

impl Default for Component

Source§

fn default() -> Component

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

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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.