jellyflow_runtime/runtime/selection/
pointer_claim.rs1use jellyflow_core::core::CanvasPoint;
2
3use super::activation::{SelectionDragActivationInput, selection_drag_threshold_met};
4
5#[derive(Debug, Clone, Copy, PartialEq)]
7pub struct SelectionPointerClaimInput {
8 pub screen_delta: CanvasPoint,
9 pub pane_click_distance: f32,
10 pub selection_key_pressed: bool,
11 pub user_selection_active: bool,
12}
13
14impl SelectionPointerClaimInput {
15 pub fn new(
16 screen_delta: CanvasPoint,
17 pane_click_distance: f32,
18 selection_key_pressed: bool,
19 user_selection_active: bool,
20 ) -> Self {
21 Self {
22 screen_delta,
23 pane_click_distance,
24 selection_key_pressed,
25 user_selection_active,
26 }
27 }
28}
29
30#[derive(Debug, Clone, Copy, PartialEq, Eq)]
32pub enum SelectionPointerClaim {
33 Unclaimed,
34 SelectionMayClaimDrag,
35 SelectionOwnsDrag,
36}
37
38pub fn resolve_selection_pointer_claim(input: SelectionPointerClaimInput) -> SelectionPointerClaim {
39 if input.user_selection_active {
40 return SelectionPointerClaim::SelectionOwnsDrag;
41 }
42
43 if input.selection_key_pressed
44 && selection_drag_threshold_met(SelectionDragActivationInput::new(
45 input.screen_delta,
46 input.pane_click_distance,
47 true,
48 ))
49 {
50 return SelectionPointerClaim::SelectionMayClaimDrag;
51 }
52
53 SelectionPointerClaim::Unclaimed
54}