Skip to main content

ParentDataElement

Struct ParentDataElement 

Source
pub struct ParentDataElement { /* private fields */ }
Expand description

An Element that uses a ParentDataWidget as its configuration.

Implementations§

Source§

impl ParentDataElement

Source

pub fn new(app: &mut App, widget: WidgetRef) -> Handle<Self>

Creates an element that uses the given widget as its configuration.

Source

pub fn widget(self: Handle<Self>, app: &App) -> &dyn AnyParentDataWidget

The widget, as a parent data widget.

Source

pub fn apply_widget_out_of_turn<W: ParentDataWidget>( self: Handle<Self>, app: &mut App, new_widget: &W, )

Calls ParentDataWidget::apply_parent_data on the given widget, passing it the RenderObject whose parent data this element is ultimately responsible for.

This allows a render object’s RenderObject::parent_data to be modified without triggering a build. This is generally ill-advised, but makes sense in situations such as the following:

  • Build and layout are currently under way, but the ParentData in question does not affect layout, and the value to be applied could not be determined before build and layout (e.g. it depends on the layout of a descendant).

  • Paint is currently under way, but the ParentData in question does not affect layout or paint, and the value to be applied could not be determined before paint (e.g. it depends on the compositing phase).

In either case, the next build is expected to cause this element to be configured with the given new widget (or a widget with equivalent data).

Only ParentDataWidgets that return true for ParentDataWidget::debug_can_apply_out_of_turn can be applied this way.

The new widget must have the same child as the current widget.

Trait Implementations§

Source§

impl ComponentElement for ParentDataElement

Source§

fn component_data(self: Handle<Self>, app: &App) -> &ComponentElementData

The child slot and build flag, held under the field component.
Source§

fn component_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut ComponentElementData

Source§

fn build(self: Handle<Self>, app: &mut App) -> WidgetRef

Subclasses should override this function to actually call the appropriate build function (e.g., StatelessWidget::build or State::build) for their widget.
Source§

fn build_tracked(self: Handle<Self>, app: &mut App) -> WidgetRef

Runs build inside App::entity_track and binds watches.
Source§

fn child(self: Handle<Self>, app: &App) -> Option<AnyElement>

The child this element built, if any.
Source§

fn mount( self: Handle<Self>, app: &mut App, parent: Option<AnyElement>, new_slot: Option<Slot>, )

ComponentElement.mount: the base mount, then the first build.
Source§

fn first_build(self: Handle<Self>, app: &mut App)

ComponentElement._firstBuild.
Source§

fn perform_rebuild(self: Handle<Self>, app: &mut App)

Calls the build method and then updates the widget tree. Read more
Source§

fn visit_children_component( self: Handle<Self>, app: &App, visitor: &mut dyn FnMut(AnyElement), )

ComponentElement.visitChildren.
Source§

fn forget_child(self: Handle<Self>, app: &mut App, child: AnyElement)

ComponentElement.forgetChild.
Source§

impl Element for ParentDataElement

Source§

const IS_PARENT_DATA_ELEMENT: bool = true

Dart’s this is ParentDataElement.
Source§

fn element_data(self: Handle<Self>, app: &App) -> &ElementData

Dart’s base-class fields, held under the field element (element_accessors!).
Source§

fn element_data_mut(self: Handle<Self>, app: &mut App) -> &mut ElementData

Source§

fn visit_children( self: Handle<Self>, app: &App, visitor: &mut dyn FnMut(AnyElement), )

Calls the argument for each child. Must be overridden by subclasses that support having children. Read more
Source§

fn render_object_attaching_child( self: Handle<Self>, app: &App, ) -> Option<AnyElement>

Returns the child of this Element that will insert a RenderObject into an ancestor of this Element to construct the render tree. Read more
Source§

fn forget_child(self: Handle<Self>, app: &mut App, child: AnyElement)

Remove the given child from the element’s child list, in preparation for the child being reused elsewhere in the element tree.
Source§

fn debug_doing_build(self: Handle<Self>, app: &App) -> bool

Whether this element is in the middle of building.
Source§

fn mount( self: Handle<Self>, app: &mut App, parent: Option<AnyElement>, new_slot: Option<Slot>, )

Add this element to the tree in the given slot of the given parent. Read more
Source§

fn update(self: Handle<Self>, app: &mut App, new_widget: WidgetRef)

Change the widget used to configure this element. Read more
Source§

fn perform_rebuild(self: Handle<Self>, app: &mut App)

Cause the widget to update itself. Read more
Source§

fn apply_parent_data( self: Handle<Self>, app: &mut App, render_object: AnyRenderObject, ) -> bool

ParentDataWidget.applyParentData through the element that holds the widget.
Source§

fn as_element(self: Handle<Self>) -> AnyElement

The type-erased handle to this element.
Source§

fn debug_visit_onstage_children( self: Handle<Self>, app: &App, visitor: &mut dyn FnMut(AnyElement), )

Calls the argument for each child considered onstage. Read more
Source§

fn update_slot(self: Handle<Self>, app: &mut App, new_slot: Option<Slot>)

Called by AnyElement::update_slot_for_child when the slot for a child has changed.
Source§

fn attach_render_object( self: Handle<Self>, app: &mut App, new_slot: Option<Slot>, )

Add AnyElement::render_object to the render tree at the location specified by new_slot. Read more
Source§

fn detach_render_object(self: Handle<Self>, app: &mut App)

Remove AnyElement::render_object from the render tree. Read more
Source§

fn activate(self: Handle<Self>, app: &mut App)

Transition from the “inactive” to the “active” lifecycle state.
Source§

fn deactivate(self: Handle<Self>, app: &mut App)

Transition from the “active” to the “inactive” lifecycle state.
Source§

fn debug_deactivated(self: Handle<Self>, app: &mut App)

Called, in debug mode, after children have been deactivated.
Source§

fn unmount(self: Handle<Self>, app: &mut App)

Transition from the “inactive” to the “defunct” lifecycle state.
Source§

fn did_change_dependencies(self: Handle<Self>, app: &mut App)

Called when a dependency of this element changes.
Source§

fn update_inheritance(self: Handle<Self>, app: &mut App)

Dart’s _updateInheritance: inherit the parent’s inherited-element map.
Source§

fn attach_notification_tree(self: Handle<Self>, app: &mut App)

Called in mount and activate to register this element in the notification tree. Read more
Source§

fn build_scope(self: Handle<Self>, app: &App) -> Handle<BuildScope>

The BuildScope whose dirty list this element is in. Read more
Source§

fn mark_needs_build(self: Handle<Self>, app: &mut App)

Marks the element as dirty and adds it to the global list of widgets to rebuild in the next frame. Read more
Source§

fn on_notification( self: Handle<Self>, app: &mut App, notification: &dyn Notification, ) -> bool

Called when a notification of the appropriate type arrives at this location in the tree (Dart’s NotifiableElementMixin.onNotification). Read more
Source§

fn debug_expects_render_object_for_slot( self: Handle<Self>, app: &App, slot: Option<&Slot>, ) -> bool

Whether the child in the provided slot (or one of its descendants) must insert a RenderObject into its ancestor RenderObjectElement by calling RenderObjectElement::insert_render_object_child on it.
Source§

fn render_object(self: Handle<Self>, app: &App) -> Option<AnyRenderObject>

The render object at (or below) this location in the tree.
Source§

const IS_RENDER_OBJECT_ELEMENT: bool = false

Dart’s this is RenderObjectElement.
Source§

fn insert_render_object_child( self: Handle<Self>, app: &mut App, child: AnyRenderObject, slot: Option<Slot>, )

RenderObjectElement.insertRenderObjectChild.
Source§

fn move_render_object_child( self: Handle<Self>, app: &mut App, child: AnyRenderObject, old_slot: Option<Slot>, new_slot: Option<Slot>, )

RenderObjectElement.moveRenderObjectChild.
Source§

fn remove_render_object_child( self: Handle<Self>, app: &mut App, child: AnyRenderObject, slot: Option<Slot>, )

RenderObjectElement.removeRenderObjectChild.
Source§

fn update_parent_data( self: Handle<Self>, app: &mut App, parent_data_element: AnyElement, )

RenderObjectElement._updateParentData: apply a parent-data widget to this element’s render object.
Source§

const IS_INHERITED_ELEMENT: bool = false

Dart’s this is InheritedElement.
Source§

fn update_dependencies( self: Handle<Self>, app: &mut App, dependent: AnyElement, aspect: Option<Rc<dyn Any>>, )

InheritedElement.updateDependencies.
Source§

fn remove_dependent(self: Handle<Self>, app: &mut App, dependent: AnyElement)

InheritedElement.removeDependent.
Source§

fn state_handle_id(self: Handle<Self>, app: &App) -> Option<(TypeId, HandleId)>

Dart’s this is StatefulElement && state is T: the state’s type and arena id.
Source§

fn debug_fill_properties( self: Handle<Self>, app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s debugFillProperties as an element class overrides it: the properties it adds after Element’s, and RenderObjectElement’s for a render object element, which the framework adds first since a trait default cannot call super.
Source§

fn debug_describe_children( self: Handle<Self>, app: &App, ) -> Vec<Rc<dyn DiagnosticsNode>>

Dart’s debugDescribeChildren: the children a dump shows under this element, by default every child visit_children visits.
Source§

impl ProxyElement for ParentDataElement

Source§

fn proxied_child(self: Handle<Self>, app: &App) -> WidgetRef

The proxied child widget.
Source§

fn notify_clients(self: Handle<Self>, app: &mut App, _old_widget: WidgetRef)

Notify other objects that the widget associated with this element has changed. Read more
Source§

fn updated(self: Handle<Self>, app: &mut App, old_widget: WidgetRef)

Called during build when the widget has changed. Read more
Source§

fn update(self: Handle<Self>, app: &mut App, new_widget: WidgetRef)

ProxyElement.update.

Auto Trait Implementations§

§

impl !RefUnwindSafe for ParentDataElement

§

impl !Send for ParentDataElement

§

impl !Sync for ParentDataElement

§

impl !UnwindSafe for ParentDataElement

§

impl Forget for ParentDataElement

§

impl Freeze for ParentDataElement
where NonZero<u32>: Freeze, &'static ElementVTable: Freeze, *const RcInner<dyn Any> is !null: Freeze, PhantomData<RcInner<dyn Any>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze, PhantomData<fn() -> BuildOwner>: Freeze, PhantomData<fn() -> BuildScope>: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<HashMap<TypeId, AnyElement>> is !null: Freeze, PhantomData<RcInner<HashMap<TypeId, AnyElement>>>: Freeze, *const RcInner<NotificationNode> is !null: Freeze, PhantomData<RcInner<NotificationNode>>: Freeze, *const u8 is !null: Freeze, PhantomData<(AnyElement, ())>: Freeze, PhantomData<(EntityId, Subscription)>: Freeze,

§

impl Move for ParentDataElement

§

impl Unpin for ParentDataElement
where NonZero<u32>: Unpin, &'static ElementVTable: Unpin, Rc<dyn Any>: Unpin, Rc<dyn Widget>: Unpin, Rc<Keep>: Unpin, Rc<HashMap<TypeId, AnyElement>>: Unpin, Rc<NotificationNode>: Unpin, *const u8 is !null: Unpin, Rc<Cell<bool>>: Unpin,

§

impl UnsafeUnpin for ParentDataElement
where NonZeroU32Inner: UnsafeUnpin, &'static ElementVTable: UnsafeUnpin, *const RcInner<dyn Any> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Any>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin, PhantomData<fn() -> BuildOwner>: UnsafeUnpin, PhantomData<fn() -> BuildScope>: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const RcInner<HashMap<TypeId, AnyElement>> is !null: UnsafeUnpin, PhantomData<RcInner<HashMap<TypeId, AnyElement>>>: UnsafeUnpin, *const RcInner<NotificationNode> is !null: UnsafeUnpin, PhantomData<RcInner<NotificationNode>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<(AnyElement, ())>: UnsafeUnpin, PhantomData<(EntityId, Subscription)>: UnsafeUnpin,

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

Source§

fn downcast(&self) -> &T

Source§

impl<T> ElementBase for T
where T: Element,

Source§

fn rebuild(self: Handle<Self>, app: &mut App, force: bool)

Element.rebuild for an element whose type is known: calls its perform_rebuild directly rather than through the vtable, so a first build adds no frame on the way down the tree.
Source§

fn render_object_attaching_child( self: Handle<Self>, app: &App, ) -> Option<AnyElement>

Element.renderObjectAttachingChild: the single child, if any.
Source§

fn mount( self: Handle<Self>, app: &mut App, parent: Option<AnyElement>, new_slot: Option<Slot>, )

Element.mount.
Source§

fn update(self: Handle<Self>, app: &mut App, new_widget: WidgetRef)

Element.update.
Source§

fn update_slot(self: Handle<Self>, app: &mut App, new_slot: Option<Slot>)

Element.updateSlot.
Source§

fn attach_render_object( self: Handle<Self>, app: &mut App, new_slot: Option<Slot>, )

Element.attachRenderObject.
Source§

fn detach_render_object(self: Handle<Self>, app: &mut App)

Element.detachRenderObject.
Source§

fn activate(self: Handle<Self>, app: &mut App)

Element.activate.
Source§

fn deactivate(self: Handle<Self>, app: &mut App)

Element.deactivate.
Source§

fn unmount(self: Handle<Self>, app: &mut App)

Element.unmount.
Source§

fn perform_rebuild(self: Handle<Self>, app: &mut App)

Element.performRebuild: clears the dirty flag.
Source§

fn did_change_dependencies(self: Handle<Self>, app: &mut App)

Element.didChangeDependencies.
Source§

fn attach_notification_tree(self: Handle<Self>, app: &mut App)

Element.attachNotificationTree: inherit the parent’s notification chain.
Source§

fn build_scope(self: Handle<Self>, app: &App) -> Handle<BuildScope>

Element.buildScope: the scope inherited from the parent at mount.
Source§

fn mark_needs_build(self: Handle<Self>, app: &mut App)

Element.markNeedsBuild.
Source§

fn update_inheritance(self: Handle<Self>, app: &mut App)

Element._updateInheritance.
Source§

fn render_object(self: Handle<Self>, app: &App) -> Option<AnyRenderObject>

Element.renderObject: walk down through the attaching children.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

Source§

fn upcast(&self) -> Option<&T>