pub struct DrawingInteraction {
pub sel_drawing: Option<usize>,
pub dragging_handle: Option<(usize, HandlePos)>,
/* private fields */
}Expand description
Self-contained interaction handler for chart drawings.
Manages selection state, handle dragging, and hit testing. Unlike
DrawingManager which coordinates all
services, DrawingInteraction focuses purely on pointer-based interaction.
Fields§
§sel_drawing: Option<usize>Currently selected drawing ID, or None.
dragging_handle: Option<(usize, HandlePos)>Handle currently being dragged: (drawing_id, handle_position).
Implementations§
Source§impl DrawingInteraction
impl DrawingInteraction
Sourcepub fn get_handles(&self, drawing: &Drawing) -> Vec<(HandlePos, Pos2)>
pub fn get_handles(&self, drawing: &Drawing) -> Vec<(HandlePos, Pos2)>
Returns the selection handle positions for a drawing, determined by its
tool type (see HandleService::get_handles
for the canonical implementation).
Sourcepub fn hit_test_handle(
&self,
point: Pos2,
drawing: &Drawing,
handle_size: f32,
) -> Option<HandlePos>
pub fn hit_test_handle( &self, point: Pos2, drawing: &Drawing, handle_size: f32, ) -> Option<HandlePos>
Hit-tests a screen point against the handles of a drawing.
Returns Some(HandlePos) if the point is within handle_size * 1.5
pixels of a handle center, None otherwise.
Sourcepub fn start_drag_handle(&mut self, drawing: &Drawing, handle: HandlePos)
pub fn start_drag_handle(&mut self, drawing: &Drawing, handle: HandlePos)
Begins a handle drag operation, saving the drawing’s current state for undo.
Sourcepub fn take_drag_old_state(&mut self) -> Option<Drawing>
pub fn take_drag_old_state(&mut self) -> Option<Drawing>
Takes the pre-drag drawing state for undo purposes. Consumes the stored
snapshot, returning None on subsequent calls until a new drag begins.
Sourcepub fn end_drag_handle(&mut self) -> Option<Drawing>
pub fn end_drag_handle(&mut self) -> Option<Drawing>
Ends the handle drag operation, returning the pre-drag drawing state (for undo) and clearing the drag state.
Sourcepub fn is_dragging(&self) -> bool
pub fn is_dragging(&self) -> bool
Returns true if a handle drag is currently in progress.
Sourcepub fn get_drag_target(&self) -> Option<(usize, HandlePos)>
pub fn get_drag_target(&self) -> Option<(usize, HandlePos)>
Returns the current drag target: (drawing_id, handle_position), or
None if no drag is active.
Sourcepub fn render_handles(
&self,
painter: &Painter,
drawing: &Drawing,
options: &DrawingOptions,
)
pub fn render_handles( &self, painter: &Painter, drawing: &Drawing, options: &DrawingOptions, )
Renders selection handles for a drawing as filled squares with borders.
The actively dragged handle is highlighted with DrawingOptions::handle_sel_color.
Sourcepub fn hit_test(
&self,
point: Pos2,
drawings: &[Drawing],
timeframe: &str,
) -> Option<usize>
pub fn hit_test( &self, point: Pos2, drawings: &[Drawing], timeframe: &str, ) -> Option<usize>
Hit-tests a screen point against all visible drawings, from the top layer down (descending z-order, and the later drawing first where the z-order is the same).
Returns the ID of the topmost drawing at point, or None if no drawing
was hit. Respects visibility and per-timeframe visibility filtering.
Uses tool-specific hit testing (line distance, rectangle containment,
Fibonacci level proximity, etc.) with a 5-pixel tolerance.
Sourcepub fn hit_test_painted(point: Pos2, shapes: &[ClippedShape]) -> bool
pub fn hit_test_painted(point: Pos2, shapes: &[ClippedShape]) -> bool
Hit-tests the shapes painted for one drawing, including text extents and filled zones.
Pass the clipped shapes emitted by the renderer, excluding selection handles. The
manager records them during render_all; standalone hosts can retain their own paint
commands. Uses a five-pixel tolerance along strokes and respects every shape’s clip.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DrawingInteraction
impl RefUnwindSafe for DrawingInteraction
impl Send for DrawingInteraction
impl Sync for DrawingInteraction
impl Unpin for DrawingInteraction
impl UnsafeUnpin for DrawingInteraction
impl UnwindSafe for DrawingInteraction
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more