pub trait DrawingTool: Send {
// Required methods
fn kind(&self) -> &'static str;
fn anchors(&self) -> &[Anchor];
fn anchors_mut(&mut self) -> &mut Vec<Anchor>;
fn anchor_count(&self) -> AnchorCount;
fn build(&self, ctx: &DrawingCtx<'_>, out: &mut FrameBuilder<'_>);
fn hit_test(&self, ctx: &DrawingCtx<'_>, p: PointPx) -> Option<HitPart>;
fn handles(&self, ctx: &DrawingCtx<'_>, out: &mut Vec<PointPx>);
fn style(&self) -> &DrawingStyle;
fn save(&self) -> DrawingData;
// Provided methods
fn move_handle(&mut self, handle: usize, to: Anchor) { ... }
fn finish(&mut self) { ... }
}Expand description
A drawing tool. Built-in tools are listed in
BUILTIN_KINDS; custom tools are registered with
DrawingManager::register.
build runs for every frame and must not allocate (it only writes into
the frame’s pools through out).
Required Methods§
Sourcefn anchors_mut(&mut self) -> &mut Vec<Anchor>
fn anchors_mut(&mut self) -> &mut Vec<Anchor>
Anchors, for moving the drawing.
Sourcefn anchor_count(&self) -> AnchorCount
fn anchor_count(&self) -> AnchorCount
How the drawing is created.
Sourcefn build(&self, ctx: &DrawingCtx<'_>, out: &mut FrameBuilder<'_>)
fn build(&self, ctx: &DrawingCtx<'_>, out: &mut FrameBuilder<'_>)
Draws the drawing.
Sourcefn hit_test(&self, ctx: &DrawingCtx<'_>, p: PointPx) -> Option<HitPart>
fn hit_test(&self, ctx: &DrawingCtx<'_>, p: PointPx) -> Option<HitPart>
What p hits, if anything (within DrawingCtx::hit_tolerance of
lines).
Sourcefn handles(&self, ctx: &DrawingCtx<'_>, out: &mut Vec<PointPx>)
fn handles(&self, ctx: &DrawingCtx<'_>, out: &mut Vec<PointPx>)
Handles of the selected drawing, written into out (empty on entry;
core reuses it, so any number of handles does not allocate). Handle
k is dragged with move_handle(k, …).
Sourcefn style(&self) -> &DrawingStyle
fn style(&self) -> &DrawingStyle
Style.
Sourcefn save(&self) -> DrawingData
fn save(&self) -> DrawingData
Saved form; a factory given it builds an equal drawing.
Provided Methods§
Sourcefn move_handle(&mut self, handle: usize, to: Anchor)
fn move_handle(&mut self, handle: usize, to: Anchor)
Drags handle handle to to. The default moves anchor handle.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".