pub struct RouteTool {
state: RouteToolState,
preview_path: Vec<TaggedPoint>,
preview_cache: Option<Box<PreviewCache>>,
return_to_select: bool,
}Fields§
§state: RouteToolState§preview_path: Vec<TaggedPoint>§preview_cache: Option<Box<PreviewCache>>Cached router + fixed legs for the live preview; rebuilt only when a
waypoint is added or a new route starts, and dropped when the gesture ends
(which also covers commit changing the set of existing routes). Boxed to
keep it off the Tool enum’s stack footprint — it is the widest thing a
tool owns, and only the route tool ever has one.
return_to_select: boolWhen set, completing or cancelling the route returns to the select tool (the route was started from a select-tool hover target) rather than staying in the route tool ready for the next route.
Implementations§
Source§impl RouteTool
impl RouteTool
Sourcepub fn routing_from(start: PinId, head: Pos2) -> Self
pub fn routing_from(start: PinId, head: Pos2) -> Self
Start routing immediately from start, with the route head at head:
the caller hands off mid-gesture and the in-progress handling carries
the same gesture to a connecting anchor.
Sourcepub fn routing_from_select(start: PinId, head: Pos2) -> Self
pub fn routing_from_select(start: PinId, head: Pos2) -> Self
Like Self::routing_from, but completing or cancelling the route returns
to the select tool. Used when a route is started from a select-tool hover
target.
Sourcefn commit(
&mut self,
data: &mut Drawing<'_>,
start: PinId,
finish: FinishTarget,
waypoints: Vec<Waypoint>,
) -> RouteToolState
fn commit( &mut self, data: &mut Drawing<'_>, start: PinId, finish: FinishTarget, waypoints: Vec<Waypoint>, ) -> RouteToolState
Build and add the route from start to finish through waypoints and
return to Idle. A FinishTarget::NewPin finish reconstructs its pin
first, in this same frame, so the pin and route collapse into one undo
step (state is snapshotted once per frame). A degenerate (zero-length)
route is rejected, leaving the proposal in place — and, importantly, no
pin is created in that case.
Sourcefn finish_pos(data: &Drawing<'_>, finish: &FinishTarget) -> Option<Pos2>
fn finish_pos(data: &Drawing<'_>, finish: &FinishTarget) -> Option<Pos2>
Resolve a finish target’s world position. An existing anchor resolves
through data; a new-pin target reports the slot’s prospective connection
point directly (the pin doesn’t exist yet).
Sourcefn finish_at(
data: &Drawing<'_>,
start: PinId,
pos: Pos2,
) -> Option<FinishTarget>
fn finish_at( data: &Drawing<'_>, start: PinId, pos: Pos2, ) -> Option<FinishTarget>
Resolve the cursor at pos to a finish target during routing: an existing
anchor (other than start) takes priority; failing that, the free slot’s
marker a press there would land on — the same one the “(+)” and the
add-pin tool commit on, so no two tools disagree about where it is.
fn update_preview(&mut self, data: &mut Drawing<'_>)
Sourcefn preview_route(
&mut self,
data: &Drawing<'_>,
gesture: &PreviewRequest<'_>,
) -> Vec<TaggedPoint>
fn preview_route( &mut self, data: &Drawing<'_>, gesture: &PreviewRequest<'_>, ) -> Vec<TaggedPoint>
Route the in-progress route start → waypoints → end for the live preview,
reusing the cached router. start_pos/end are grid-snapped. The router is
(re)built only when its fixed inputs change — a different start (new route)
or a different waypoint count (a waypoint was added); the moving cursor
(end) does not change the graph and is routed via the existing L-path
fallback. Routes read-only (SelfCost::Skip semantics) so the cache never
accumulates the in-progress route’s own occupancy between frames.
Sourcefn draw_new_pin_markers<C: Canvas>(
data: &Drawing<'_>,
painter: &mut Style<'_, C>,
)
fn draw_new_pin_markers<C: Canvas>( data: &Drawing<'_>, painter: &mut Style<'_, C>, )
While a route is in progress, surface the nearest block’s new-pin markers so the route can terminate on a not-yet-existent pin.
fn render<C: Canvas>(&self, data: &Drawing<'_>, painter: &mut Style<'_, C>)
Sourcefn draw_end_target<C: Canvas>(
data: &Drawing<'_>,
start: PinId,
painter: &mut Style<'_, C>,
)
fn draw_end_target<C: Canvas>( data: &Drawing<'_>, start: PinId, painter: &mut Style<'_, C>, )
Grow the green route-end target on the anchor nearest the cursor (other than
start), mirroring the select tool’s start affordance.
Sourcefn draw_hover_anchor_target<C: Canvas>(
data: &Drawing<'_>,
painter: &mut Style<'_, C>,
)
fn draw_hover_anchor_target<C: Canvas>( data: &Drawing<'_>, painter: &mut Style<'_, C>, )
Before a route starts, show the same animated anchor target the select tool’s route-start does, so hovering the route tool over a pin reads identically.
fn world_pointer<C: Canvas>(painter: &Style<'_, C>) -> Option<Pos2>
Trait Implementations§
Source§impl ToolTrait for RouteTool
impl ToolTrait for RouteTool
fn name(&self) -> ToolName
fn widget<C: Canvas>( &mut self, data: &mut Drawing<'_>, interaction: &Interaction, painter: &mut Style<'_, C>, ) -> Option<Transition>
Source§fn 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, )
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>
fn selection(&self) -> Option<Deletable>
Source§fn overlay_anchor(&self) -> Option<Pos2>
fn overlay_anchor(&self) -> Option<Pos2>
Auto Trait Implementations§
impl Freeze for RouteTool
impl RefUnwindSafe for RouteTool
impl Send for RouteTool
impl Sync for RouteTool
impl Unpin for RouteTool
impl UnsafeUnpin for RouteTool
impl UnwindSafe for RouteTool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more