Skip to main content

HandleService

Struct HandleService 

Source
pub struct HandleService;
Expand description

Stateless service for selection handle operations on drawings.

All methods are static (&self-free) since HandleService carries no state. It computes handle positions, performs hit testing, updates handle positions during drags, and renders the handles onto the chart.

Implementations§

Source§

impl HandleService

Source

pub fn get_handles(drawing: &Drawing) -> Vec<(HandlePos, Pos2)>

Returns the selection handles for a drawing based on its tool type.

Handle layouts vary by tool type:

  • Two-point tools (TrendLine, Fibonacci, etc.): Start and End handles
  • Rectangle and Gann box: Four corner handles and four edge handles
  • Single-point tools (HorizontalLine, VerticalLine): One Start handle
  • Glyphs: Four resize corners around the centre and a Middle move handle
  • Image: One bottom-right corner that resizes with locked proportions
  • Brushes: One Middle handle on the stroke, which moves it whole
  • Three-anchor channels: Four indexed handles, one at each line end
  • Bars pattern: Start and End at the ends of its copy
  • Multi-point tools: Indexed handles at each anchor
Source

pub fn hit_test_handle( drawing: &Drawing, point: Pos2, handle_size: f32, ) -> Option<HandlePos>

Hit-tests to find which handle (if any) is at a screen position.

Returns Some(HandlePos) if point is within handle_size * 1.5 pixels of a handle center, None otherwise.

Source

pub fn update_handle<F, G, H>( drawing: &mut Drawing, handle: HandlePos, new_pos: Pos2, x_to_bar: F, y_to_price: G, translate_price: H, )
where F: Fn(f32) -> f32, G: Fn(f32) -> f64, H: Fn(f64, f32, f32) -> f64,

Moves a handle to a new screen position, updating both screen coordinates and chart coordinates using the provided conversion closures.

For the Middle handle, every anchor that moves with the drawing (all but a bars pattern’s source) is translated by the delta between the old and new centroid positions. translate_price(price, from_y, to_y) shifts their prices in scale units; other handles use y_to_price.

Source

pub fn render_handles( painter: &Painter, drawing: &Drawing, config: &HandleConfig, dragging_handle: Option<HandlePos>, )

Renders selection handles like the selection dots of a series: an accent ring around the chart background.

The actively dragged handle (if any) is filled with HandleConfig::selected_color; the others are ringed with HandleConfig::color.

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.