Skip to main content

jellyflow_runtime/runtime/auto_pan/
store.rs

1use crate::runtime::store::NodeGraphStore;
2use crate::runtime::viewport::ViewportTransform;
3
4use super::planner::{compute_auto_pan, compute_selection_auto_pan};
5use super::types::{AutoPanOutcome, AutoPanPlan, AutoPanRequest, SelectionAutoPanRequest};
6
7impl AutoPanPlan {
8    pub fn apply_to_store(self, store: &mut NodeGraphStore) -> Option<ViewportTransform> {
9        store.apply_viewport_pan(self.viewport_pan_request())
10    }
11}
12
13impl NodeGraphStore {
14    /// Applies one auto-pan frame through normal viewport view-state publication.
15    pub fn apply_auto_pan(&mut self, request: AutoPanRequest) -> Option<AutoPanOutcome> {
16        let interaction = self.resolved_interaction_state();
17        let plan = compute_auto_pan(&interaction.auto_pan, request)?;
18        let transform = plan.apply_to_store(self)?;
19        Some(AutoPanOutcome { plan, transform })
20    }
21
22    /// Applies one selection-drag auto-pan frame through normal viewport publication.
23    pub fn apply_selection_auto_pan(
24        &mut self,
25        request: SelectionAutoPanRequest,
26    ) -> Option<AutoPanOutcome> {
27        let interaction = self.resolved_interaction_state();
28        let plan = compute_selection_auto_pan(&interaction.auto_pan, request)?;
29        let transform = plan.apply_to_store(self)?;
30        Some(AutoPanOutcome { plan, transform })
31    }
32}