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
impl HandleService
Sourcepub fn get_handles(drawing: &Drawing) -> Vec<(HandlePos, Pos2)>
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
Sourcepub fn hit_test_handle(
drawing: &Drawing,
point: Pos2,
handle_size: f32,
) -> Option<HandlePos>
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.
Sourcepub 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,
)
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, )
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.
Sourcepub fn render_handles(
painter: &Painter,
drawing: &Drawing,
config: &HandleConfig,
dragging_handle: Option<HandlePos>,
)
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§
impl Freeze for HandleService
impl RefUnwindSafe for HandleService
impl Send for HandleService
impl Sync for HandleService
impl Unpin for HandleService
impl UnsafeUnpin for HandleService
impl UnwindSafe for HandleService
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