Skip to main content

DrawingInteraction

Struct DrawingInteraction 

Source
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

Source

pub fn new() -> Self

Creates a new interaction handler with no selection and no active drag.

Source

pub fn deselect(&mut self)

Clears the current drawing selection.

Source

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).

Source

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.

Source

pub fn start_drag_handle(&mut self, drawing: &Drawing, handle: HandlePos)

Begins a handle drag operation, saving the drawing’s current state for undo.

Source

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.

Source

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.

Source

pub fn is_dragging(&self) -> bool

Returns true if a handle drag is currently in progress.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn select_at( &mut self, point: Pos2, drawings: &[Drawing], timeframe: &str, ) -> bool

Hit-tests at point and selects the topmost drawing found.

Returns true if a drawing was selected, false if the click hit empty space (which deselects the current selection).

Trait Implementations§

Source§

impl Default for DrawingInteraction

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeSend for T
where T: Send + Sync + ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.