Skip to main content

RenderObjectWithLayoutCallbackMixin

Trait RenderObjectWithLayoutCallbackMixin 

Source
pub trait RenderObjectWithLayoutCallbackMixin: RenderBox {
    // Required methods
    fn layout_callback_data(
        self: RenderHandle<Self>,
        app: &App,
    ) -> &RenderObjectWithLayoutCallbackData;
    fn layout_callback_data_mut(
        self: RenderHandle<Self>,
        app: &mut App,
    ) -> &mut RenderObjectWithLayoutCallbackData;
    fn layout_callback(self: RenderHandle<Self>, app: &mut App);

    // Provided methods
    fn run_layout_callback(self: RenderHandle<Self>, app: &mut App) { ... }
    fn schedule_layout_callback(self: RenderHandle<Self>, app: &mut App) { ... }
}
Expand description

A mixin for RenderObjects that run a layout callback (typically one that builds a widget subtree) during perform_layout, as LayoutBuilder’s render object does.

Implementers keep the bag under a field named layout_callback, implement layout_callback, and call run_layout_callback in their perform_layout. The mixin is on the box protocol here because scheduling needs the tree methods.

Required Methods§

Source

fn layout_callback_data( self: RenderHandle<Self>, app: &App, ) -> &RenderObjectWithLayoutCallbackData

The mixin’s bag.

Source

fn layout_callback_data_mut( self: RenderHandle<Self>, app: &mut App, ) -> &mut RenderObjectWithLayoutCallbackData

Source

fn layout_callback(self: RenderHandle<Self>, app: &mut App)

The layout callback to run in perform_layout, through run_layout_callback, which invokes it with AnyRenderObject::invoke_layout_callback.

Provided Methods§

Source

fn run_layout_callback(self: RenderHandle<Self>, app: &mut App)

Invokes layout_callback with AnyRenderObject::invoke_layout_callback.

Must be called in perform_layout, and only after the callback was scheduled.

Source

fn schedule_layout_callback(self: RenderHandle<Self>, app: &mut App)

Schedules the layout callback to be run in the next layout pass, marking this object for layout.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§