Skip to main content

Surface

Trait Surface 

Source
pub trait Surface: Send + Sync {
    // Required method
    fn paint(&self, gfx: &GfxContext, rect: Rect);

    // Provided methods
    fn pointer(&self, ev: Pointer, size: (f32, f32)) -> bool { ... }
    fn scroll(&self, dy: f32, size: (f32, f32)) -> bool { ... }
}
Expand description

What a surface widget draws and how it takes the pointer — see the module docs.

Required Methods§

Source

fn paint(&self, gfx: &GfxContext, rect: Rect)

Draws into rect (screen GUI pixels, the widget’s box less its padding). Called every frame the widget is visible.

Provided Methods§

Source

fn pointer(&self, ev: Pointer, size: (f32, f32)) -> bool

A pointer event; true = used (a Down that returns false lets the click through to what’s under the surface). size is the box’s width and height.

Source

fn scroll(&self, dy: f32, size: (f32, f32)) -> bool

The mouse wheel turned over the surface (dy > 0 = up); true = used (scroll containers around it then don’t scroll).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§