use jellyflow_core::core::CanvasPoint;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SelectionDragActivationInput {
pub screen_delta: CanvasPoint,
pub pane_click_distance: f32,
pub selection_key_pressed: bool,
}
impl SelectionDragActivationInput {
pub fn new(
screen_delta: CanvasPoint,
pane_click_distance: f32,
selection_key_pressed: bool,
) -> Self {
Self {
screen_delta,
pane_click_distance,
selection_key_pressed,
}
}
}
pub fn selection_drag_threshold_met(input: SelectionDragActivationInput) -> bool {
if !input.screen_delta.is_finite() {
return false;
}
let required_distance = if input.selection_key_pressed {
0.0
} else if input.pane_click_distance.is_finite() {
input.pane_click_distance.max(0.0)
} else {
return false;
};
input.screen_delta.x.hypot(input.screen_delta.y) > required_distance
}