Skip to main content

ContentCx

Trait ContentCx 

Source
pub trait ContentCx<'a> {
    type Spec: Spec;

    // Required methods
    fn with_paint<R>(
        &mut self,
        f: impl FnOnce(&mut dyn RenderContext, &mut Widgets<'a>, &VisualView<Self::Spec>, &Tokens) -> R,
    ) -> R;
    fn time_ms(&self) -> u64;

    // Provided methods
    fn ime_area(&mut self, _rect: Rect) { ... }
    fn frame_now_ms(&self) -> f64 { ... }
    fn request_frame(&mut self) { ... }
    fn is_overlay(&self) -> bool { ... }
}
Expand description

A content hook context a widget convenience function can paint into.

Implemented for PanelCx and OverlayCx. The closure receives the disjoint pieces of one frame (paint target, registration face, this frame’s input truth, tokens) so a widget can register and draw without reaching an engine.

Required Associated Types§

Source

type Spec: Spec

The app vocabulary of the context.

Required Methods§

Source

fn with_paint<R>( &mut self, f: impl FnOnce(&mut dyn RenderContext, &mut Widgets<'a>, &VisualView<Self::Spec>, &Tokens) -> R, ) -> R

Run f against this frame’s paint target and registration face.

Source

fn time_ms(&self) -> u64

Host clock in whole milliseconds. Same unit as TextFieldStore::cursor_visible.

Provided Methods§

Source

fn ime_area(&mut self, _rect: Rect)

Report the focused field’s caret rect so the OS IME window opens there.

Source

fn frame_now_ms(&self) -> f64

The frame clock in milliseconds, unrounded: the stamp scroll containers share within one frame.

Source

fn request_frame(&mut self)

Ask for another frame (an animation or a scroll is still moving).

Source

fn is_overlay(&self) -> bool

Painting into an overlay (a modal makes the page’s scroll containers inert to keys).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<'a, S: Spec> ContentCx<'a> for OverlayCx<'a, S>

Source§

type Spec = S

Source§

impl<'a, S: Spec> ContentCx<'a> for PanelCx<'a, S>

Source§

type Spec = S