pub struct SnapService { /* private fields */ }Expand description
Snap service for applying snap behavior to points
Implementations§
Source§impl SnapService
impl SnapService
Sourcepub fn with_options(options: SnapOptions) -> Self
pub fn with_options(options: SnapOptions) -> Self
Create with custom options
Sourcepub fn options(&self) -> &SnapOptions
pub fn options(&self) -> &SnapOptions
Get the current options
Sourcepub fn options_mut(&mut self) -> &mut SnapOptions
pub fn options_mut(&mut self) -> &mut SnapOptions
Get mutable options
Sourcepub fn snap_point(&self, point: Pos2, targets: &SnapTargets) -> Pos2
pub fn snap_point(&self, point: Pos2, targets: &SnapTargets) -> Pos2
Apply snap to a point
Applies in order:
- Snap to price (Y axis)
- Snap to time (X axis)
- Magnet mode (snap to nearest drawing point)
Sourcepub fn snap_point_with_drawing_points<I>(
&self,
point: Pos2,
prices: &[f32],
times: &[f32],
drawing_points: I,
) -> Pos2where
I: IntoIterator<Item = Pos2>,
pub fn snap_point_with_drawing_points<I>(
&self,
point: Pos2,
prices: &[f32],
times: &[f32],
drawing_points: I,
) -> Pos2where
I: IntoIterator<Item = Pos2>,
Apply snap to a point, sourcing magnet targets from a borrowed iterator.
Identical behavior to SnapService::snap_point, but the magnet-mode
drawing points are supplied as an iterator rather than an owned Vec.
This lets per-pointer-move callers (e.g. during a drag) borrow the live
drawing geometry instead of cloning every point of every drawing on each
pointer event. The iterator is only consumed when magnet mode is active.
Sourcepub fn would_snap(&self, point: Pos2, targets: &SnapTargets) -> bool
pub fn would_snap(&self, point: Pos2, targets: &SnapTargets) -> bool
Check if a point would snap
Returns true if the point would be modified by snapping.
Sourcepub fn get_snap_indicator(
&self,
point: Pos2,
targets: &SnapTargets,
) -> Option<Pos2>
pub fn get_snap_indicator( &self, point: Pos2, targets: &SnapTargets, ) -> Option<Pos2>
Get snap indicator position if snapping is active
Returns the snapped position only if it differs from input, useful for showing snap indicators in the UI.
Sourcepub fn set_snap_to_price(&mut self, enabled: bool)
pub fn set_snap_to_price(&mut self, enabled: bool)
Enable/disable snap to price
Sourcepub fn set_snap_to_time(&mut self, enabled: bool)
pub fn set_snap_to_time(&mut self, enabled: bool)
Enable/disable snap to time
Sourcepub fn set_magnet_mode(&mut self, enabled: bool)
pub fn set_magnet_mode(&mut self, enabled: bool)
Enable/disable magnet mode
Sourcepub fn set_snap_distance(&mut self, distance: f32)
pub fn set_snap_distance(&mut self, distance: f32)
Set snap distance
Sourcepub fn set_magnet_distance(&mut self, distance: f32)
pub fn set_magnet_distance(&mut self, distance: f32)
Set magnet distance
Trait Implementations§
Source§impl Clone for SnapService
impl Clone for SnapService
Source§fn clone(&self) -> SnapService
fn clone(&self) -> SnapService
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SnapService
impl Debug for SnapService
Auto Trait Implementations§
impl Freeze for SnapService
impl RefUnwindSafe for SnapService
impl Send for SnapService
impl Sync for SnapService
impl Unpin for SnapService
impl UnsafeUnpin for SnapService
impl UnwindSafe for SnapService
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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