jellyflow_runtime/runtime/selection/
activation.rs1use jellyflow_core::core::CanvasPoint;
2
3#[derive(Debug, Clone, Copy, PartialEq)]
9pub struct SelectionDragActivationInput {
10 pub screen_delta: CanvasPoint,
11 pub pane_click_distance: f32,
12 pub selection_key_pressed: bool,
13}
14
15impl SelectionDragActivationInput {
16 pub fn new(
17 screen_delta: CanvasPoint,
18 pane_click_distance: f32,
19 selection_key_pressed: bool,
20 ) -> Self {
21 Self {
22 screen_delta,
23 pane_click_distance,
24 selection_key_pressed,
25 }
26 }
27}
28
29pub fn selection_drag_threshold_met(input: SelectionDragActivationInput) -> bool {
34 if !input.screen_delta.is_finite() {
35 return false;
36 }
37
38 let required_distance = if input.selection_key_pressed {
39 0.0
40 } else if input.pane_click_distance.is_finite() {
41 input.pane_click_distance.max(0.0)
42 } else {
43 return false;
44 };
45
46 input.screen_delta.x.hypot(input.screen_delta.y) > required_distance
47}