Skip to main content

jellyflow_runtime/runtime/conformance/scenario/action/
node.rs

1use crate::runtime::drag::{NodeNudgeRequest, PointerGestureClaim};
2use crate::runtime::resize::{NodePointerResizeRequest, NodeResizeRequest};
3use crate::runtime::selection::NodePointerDownInput;
4use jellyflow_core::core::{CanvasPoint, NodeId};
5
6use super::ConformanceAction;
7
8pub(super) fn kind(action: &ConformanceAction) -> Option<&'static str> {
9    Some(match action {
10        ConformanceAction::ApplyNodeDrag { .. } => "apply_node_drag",
11        ConformanceAction::ApplyNodeDragSession { .. } => "apply_node_drag_session",
12        ConformanceAction::ApplyNodeResize { .. } => "apply_node_resize",
13        ConformanceAction::ApplyNodePointerResize { .. } => "apply_node_pointer_resize",
14        ConformanceAction::ApplyNodePointerResizeSession { .. } => {
15            "apply_node_pointer_resize_session"
16        }
17        ConformanceAction::ApplyNodePointerDown { .. } => "apply_node_pointer_down",
18        ConformanceAction::ApplyNodeNudge { .. } => "apply_node_nudge",
19        _ => return None,
20    })
21}
22
23impl ConformanceAction {
24    pub fn apply_node_drag(node: NodeId, to: CanvasPoint) -> Self {
25        Self::ApplyNodeDrag { node, to }
26    }
27
28    pub fn apply_node_drag_session(node: NodeId, start: CanvasPoint, to: CanvasPoint) -> Self {
29        Self::ApplyNodeDragSession { node, start, to }
30    }
31
32    pub fn apply_node_resize(request: NodeResizeRequest) -> Self {
33        Self::ApplyNodeResize { request }
34    }
35
36    pub fn apply_node_pointer_resize(request: NodePointerResizeRequest) -> Self {
37        Self::ApplyNodePointerResize { request }
38    }
39
40    pub fn apply_node_pointer_resize_session(request: NodePointerResizeRequest) -> Self {
41        Self::ApplyNodePointerResizeSession { request }
42    }
43
44    pub fn apply_node_pointer_down(
45        node: NodeId,
46        multi_selection_active: bool,
47        screen_delta: CanvasPoint,
48    ) -> Self {
49        Self::ApplyNodePointerDown {
50            input: NodePointerDownInput {
51                node,
52                multi_selection_active,
53                screen_delta,
54            },
55            expected_claim: None,
56        }
57    }
58
59    pub fn apply_node_pointer_down_expect_claim(
60        node: NodeId,
61        multi_selection_active: bool,
62        screen_delta: CanvasPoint,
63        expected_claim: PointerGestureClaim,
64    ) -> Self {
65        Self::ApplyNodePointerDown {
66            input: NodePointerDownInput {
67                node,
68                multi_selection_active,
69                screen_delta,
70            },
71            expected_claim: Some(expected_claim),
72        }
73    }
74
75    pub fn apply_node_nudge(request: NodeNudgeRequest) -> Self {
76        Self::ApplyNodeNudge { request }
77    }
78}