public void UpdateGraphIfAssetMoved() { IGraphModel graphModel = m_Store.GetState()?.CurrentGraphModel; if (graphModel != null) { string assetPath = graphModel.GetAssetPath(); m_LastGraphFilePath = assetPath; } }
void StoreOnStateChanged() { var editorDataModel = m_Store.GetState().EditorDataModel; UpdateFlags currentUpdateFlags = editorDataModel.UpdateFlags; if (currentUpdateFlags == 0) { return; } IGraphModel graphModel = m_Store.GetState()?.CurrentGraphModel; m_LastGraphFilePath = graphModel?.GetAssetPath(); if (m_Store.GetState().requestNodeAlignment) { if (graphModel is VSGraphModel vsGraphModel) { IEnumerable <INodeModel> entryPoints = vsGraphModel.Stencil.GetEntryPoints(vsGraphModel); vsGraphModel.LastChanges.ModelsToAutoAlign.AddRange(entryPoints); } } if (currentUpdateFlags.HasFlag(UpdateFlags.RequestCompilation)) { if (!currentUpdateFlags.HasFlag(UpdateFlags.CompilationResult)) { m_IdleTimer = Stopwatch.StartNew(); m_CompilationPendingLabel.EnableInClassList(k_CompilationPendingClassName, true); } } // The GraphGeometry part must happen BEFORE the GraphTopology part // When the onboarding page is displayed before loading a graph, we need first to insert the graphview in // the hierarchy (UpdateGraphContainer) then create the graph itself (UpdateTopology) // Fixes VSB-257: edge bubbles rely on a specific event order (AttachedToPanelEvent must occur early enough or the // bubble won't get attached) if (currentUpdateFlags.HasFlag(UpdateFlags.GraphGeometry)) { UpdateGraphContainer(); m_BlankPage.UpdateUI(); m_Menu.UpdateUI(); m_GraphView.schedule.Execute(() => { if (editorDataModel.NodeToFrameGuid != default) { m_GraphView.PanToNode(editorDataModel.NodeToFrameGuid); editorDataModel.NodeToFrameGuid = default; } }).ExecuteLater(1); } if (currentUpdateFlags.HasFlag(UpdateFlags.GraphTopology)) { if (graphModel != null) { AnalyticsHelper.Instance.FlushNodeCreationEvent(NodeCreationEvent.Keep); // if it was cancelled, already done if (!currentUpdateFlags.HasFlag(UpdateFlags.CompilationResult)) { m_IdleTimer = Stopwatch.StartNew(); m_CompilationPendingLabel.EnableInClassList(k_CompilationPendingClassName, true); } m_GraphView.NotifyTopologyChange(graphModel); } // A topology change should update everything. m_GraphView.UIController.UpdateTopology(); currentUpdateFlags |= UpdateFlags.All; } if (currentUpdateFlags.HasFlag(UpdateFlags.CompilationResult)) { UpdateCompilationErrorsDisplay(m_Store.GetState()); } ((VSGraphModel)m_Store.GetState().CurrentGraphModel)?.CheckIntegrity(GraphModel.Verbosity.Errors); if (graphModel != null && currentUpdateFlags.HasFlag(UpdateFlags.RequestRebuild)) { // var editors = Resources.FindObjectsOfTypeAll<VisualBehaviourInspector>(); // foreach (var editor in editors) // { // editor.Repaint(); // } } if (graphModel != null && graphModel.LastChanges.ModelsToAutoAlign.Any()) { var elementsToAlign = graphModel.LastChanges.ModelsToAutoAlign .Select(n => m_GraphView.UIController.ModelsToNodeMapping[n]); m_GraphView.schedule.Execute(() => { m_GraphView.AlignGraphElements(elementsToAlign); // Black magic counter spell to the curse cast by WindowsDropTargetImpl::DragPerformed. // Basically our scheduled alignment gets called right in the middle of a DragExit // (yes DragExit even though the Drag was performed properly, Look at WindowsDropTargetImpl::DragPerformed you'll understand...) // DragExit calls Application::TickTimer() in the middle of its execution, letting our scheduled task run // right after the TickTimer() resumes, since we're supposedly doing a DragExit (so a drag cancel) it Undoes the CurrentGroup // since we don't want our scheduled task to be canceled, we do the following Undo.IncrementCurrentGroup(); }); } }
void SetPersistenceKeyFromGraphModel(IGraphModel graphModel) { viewDataKey = graphModel?.GetAssetPath() + "__" + k_PersistenceKey; }