Skip to main content

Primitive

Trait Primitive 

Source
pub trait Primitive<D>: Send + Sync {
    // Required methods
    fn measure(&self, data: &D, label: Vec2) -> Vec2;
    fn paint(&self, cx: &KitCx<'_>, data: &D, part: &Part<'_>);
    fn paint_label(&self, cx: &KitCx<'_>, data: &D, part: &Part<'_>);

    // Provided method
    fn hit(&self, _data: &D, rect: Rect, pos: Pos2) -> bool { ... }
}
Expand description

A component’s drawing handler. Every component’s handlers have this shape; D is the component’s data.

Required Methods§

Source

fn measure(&self, data: &D, label: Vec2) -> Vec2

The size of a part around a label of size label.

Source

fn paint(&self, cx: &KitCx<'_>, data: &D, part: &Part<'_>)

Paints a part’s box (everything but its label).

Source

fn paint_label(&self, cx: &KitCx<'_>, data: &D, part: &Part<'_>)

Paints a part’s label, after the widget’s own content.

Provided Methods§

Source

fn hit(&self, _data: &D, rect: Rect, pos: Pos2) -> bool

Whether pos hits the part (a part that is not a rectangle).

Implementors§