jellyflow_runtime/runtime/events/view.rs
1use jellyflow_core::core::{CanvasPoint, EdgeId, GroupId, NodeId};
2
3/// View-state projection change events.
4///
5/// These are the B-layer equivalent of XyFlow's selection/viewport updates (which are embedded in
6/// their node/edge arrays). In Jellyflow, view-state is intentionally separate from the serialized
7/// graph document.
8///
9/// Only viewport/selection changes are surfaced here. Other persisted editor configuration is
10/// observable through selector subscriptions on [`super::NodeGraphStoreSnapshot`].
11#[derive(Debug, Clone)]
12pub enum ViewChange {
13 Viewport {
14 pan: CanvasPoint,
15 zoom: f32,
16 },
17 Selection {
18 nodes: Vec<NodeId>,
19 edges: Vec<EdgeId>,
20 groups: Vec<GroupId>,
21 },
22}
23
24impl ViewChange {
25 pub fn viewport(pan: CanvasPoint, zoom: f32) -> Self {
26 Self::Viewport { pan, zoom }
27 }
28
29 pub fn selection(nodes: Vec<NodeId>, edges: Vec<EdgeId>, groups: Vec<GroupId>) -> Self {
30 Self::Selection {
31 nodes,
32 edges,
33 groups,
34 }
35 }
36}