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§
fn name(&self) -> ToolName
fn widget<C: Canvas>( &mut self, data: &mut Drawing<'_>, interaction: &Interaction, painter: &mut Style<'_, C>, ) -> Option<Transition>
Provided Methods§
Sourcefn preview<C: Canvas>(
&mut self,
_data: &mut Drawing<'_>,
_interaction: &Interaction,
_painter: &mut Style<'_, C>,
_phase: &PreviewPhase,
)
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.
Sourcefn selection(&self) -> Option<Deletable>
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.
Sourcefn overlay_anchor(&self) -> Option<Pos2>
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.