jellyflow_runtime/io/config/state/views/
selection.rs1use jellyflow_core::interaction::NodeGraphModifierKey;
2
3use crate::io::config::keys::NodeGraphDeleteKey;
4use crate::io::config::types::{NodeGraphBoxSelectEdges, NodeGraphSelectionMode};
5
6use super::super::NodeGraphInteractionState;
7
8#[derive(Debug, Clone, Copy, PartialEq)]
10pub struct NodeGraphSelectionInteraction {
11 pub elements_selectable: bool,
12 pub edges_selectable: bool,
13 pub selection_on_drag: bool,
14 pub select_nodes_on_drag: bool,
15 pub selection_mode: NodeGraphSelectionMode,
16 pub box_select_edges: NodeGraphBoxSelectEdges,
17 pub selection_key: NodeGraphModifierKey,
18 pub multi_selection_key: NodeGraphModifierKey,
19}
20
21#[derive(Debug, Clone, Copy, PartialEq, Eq)]
23pub struct NodeGraphDeleteInteraction {
24 pub nodes_deletable: bool,
25 pub edges_deletable: bool,
26 pub delete_key: NodeGraphDeleteKey,
27}
28
29impl NodeGraphInteractionState {
30 pub fn selection_interaction(&self) -> NodeGraphSelectionInteraction {
31 NodeGraphSelectionInteraction {
32 elements_selectable: self.elements_selectable,
33 edges_selectable: self.edges_selectable,
34 selection_on_drag: self.selection_on_drag,
35 select_nodes_on_drag: self.select_nodes_on_drag,
36 selection_mode: self.selection_mode,
37 box_select_edges: self.box_select_edges,
38 selection_key: self.selection_key,
39 multi_selection_key: self.multi_selection_key,
40 }
41 }
42
43 pub fn delete_interaction(&self) -> NodeGraphDeleteInteraction {
44 NodeGraphDeleteInteraction {
45 nodes_deletable: self.nodes_deletable,
46 edges_deletable: self.edges_deletable,
47 delete_key: self.delete_key,
48 }
49 }
50}