Skip to main content

ToolTrait

Trait ToolTrait 

Source
pub trait ToolTrait {
    // Required methods
    fn name(&self) -> ToolName;
    fn widget<C: Canvas>(
        &mut self,
        data: &mut Drawing<'_>,
        interaction: &Interaction,
        painter: &mut Style<'_, C>,
    ) -> Option<Transition>;

    // Provided methods
    fn preview<C: Canvas>(
        &mut self,
        _data: &mut Drawing<'_>,
        _interaction: &Interaction,
        _painter: &mut Style<'_, C>,
        _phase: &PreviewPhase,
    ) { ... }
    fn selection(&self) -> Option<Deletable> { ... }
    fn overlay_anchor(&self) -> Option<Pos2> { ... }
}

Required Methods§

Source

fn name(&self) -> ToolName

Source

fn widget<C: Canvas>( &mut self, data: &mut Drawing<'_>, interaction: &Interaction, painter: &mut Style<'_, C>, ) -> Option<Transition>

Provided Methods§

Source

fn preview<C: Canvas>( &mut self, _data: &mut Drawing<'_>, _interaction: &Interaction, _painter: &mut Style<'_, C>, _phase: &PreviewPhase, )

Advance this frame’s drag state and preview the geometry it implies. Runs before Self::widget paints, on every frame of a drag — including one carrying no event at all, which is what a repaint mid-drag looks like.

Source

fn selection(&self) -> Option<Deletable>

The item this tool currently has selected that can be deleted, if any. Used to drive the delete button overlay.

Source

fn overlay_anchor(&self) -> Option<Pos2>

A world-space point the selection overlay should anchor to, overriding the selection’s bounding box. A route spans a wide bbox but is picked at one spot, so its overlay anchors at the click instead of the whole polyline.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§