Skip to main content

View

Trait View 

Source
pub trait View: 'static {
    // Required methods
    fn id(&self) -> ViewId;
    fn metrics(&self) -> ViewMetrics;
    fn present(&self, scene: Arc<Scene>);
    fn host(&self) -> &dyn ViewHost;

    // Provided methods
    fn gesture_settings(&self) -> GestureSettings { ... }
    fn initial_data(&self) -> Option<String> { ... }
    fn request_id(&self) -> Option<RequestId> { ... }
    fn window(&self) -> Option<WindowRef> { ... }
}
Expand description

A stable handle to one host-provided view.

present is Flutter FlutterView.render. The host owns the surface; the framework builds a crate::Scene and hands it over.

Required Methods§

Source

fn id(&self) -> ViewId

Source

fn metrics(&self) -> ViewMetrics

Source

fn present(&self, scene: Arc<Scene>)

Renders and presents one scene, the frame’s layer tree, shared so the host may keep it: to present it again when the window is seen again, and to tell a scene equal to the last from one worth drawing. Physical pixels; the presenter applies no extra scaling. slices makes of it the picture a host draws and the composition layers a host with a compositor places in the same native transaction; a host without one draws the picture alone.

Source

fn host(&self) -> &dyn ViewHost

What the view asks of the system: its input methods, its cursor and its focus.

Provided Methods§

Source

fn gesture_settings(&self) -> GestureSettings

Flutter FlutterView.gestureSettings.

Source

fn initial_data(&self) -> Option<String>

What whoever gave or asked for this view attached to it, such as which screen to show: what the app asked for it with (crate::Platform::request_view), or what an embedder said, as Flutter web’s initialData does. None for a view with none.

Source

fn request_id(&self) -> Option<RequestId>

The request this view arrived for (crate::Platform::request_view, [crate::Platform::add_view]); None for a view the platform gave the app unasked.

Source

fn window(&self) -> Option<WindowRef>

The window this view is in, where the platform lets the app manage it, as NSView.window answers: every window on a desktop, whether the app asked for it or the platform gave it, such as WaOS’s window around a program’s view. None for a view in nothing the app may manage: a phone’s screen, a web page’s element, a host app’s view. Closing a view is its window’s: a view with none is not the app’s to close, and its way out is to quit.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§