protected void OnCollapseChangeEvent(ChangeEvent <bool> evt)
 {
     CommandDispatcher.Dispatch(new CollapseNodeCommand(evt.newValue, NodeModel));
 }
예제 #2
0
 public void SetUp(CommandDispatcher commandDispatcher, IGraphAssetModel assetModel, IGraphTemplate template)
 {
     m_CommandDispatcher = commandDispatcher;
     m_Template          = template;
     m_AssetModel        = assetModel;
 }
        public static IModelUI CreateVariableDeclarationModelUI(this ElementBuilder elementBuilder, CommandDispatcher commandDispatcher, IVariableDeclarationModel model)
        {
            IModelUI ui;

            if (elementBuilder.Context == BlackboardVariablePropertiesPart.blackboardVariablePropertiesPartCreationContext)
            {
                ui = new BlackboardVariablePropertyView();
            }
            else if (elementBuilder.Context == BlackboardVariablePart.blackboardVariablePartCreationContext)
            {
                ui = new BlackboardField();
            }
            else
            {
                ui = new BlackboardRow();
            }

            ui.SetupBuildAndUpdate(model, commandDispatcher, elementBuilder.View, elementBuilder.Context);
            return(ui);
        }
예제 #4
0
 public static T CreateUI <T>(IModelView view, CommandDispatcher commandDispatcher, IGraphElementModel model) where T : class, IModelUI
 {
     return(CreateUI <T>(view, commandDispatcher, model, null));
 }
예제 #5
0
 protected void OnCollapseButtonChange(ChangeEvent <bool> e)
 {
     CommandDispatcher.Dispatch(new CollapseVariableInBlackboard(Model as IVariableDeclarationModel, e.newValue));
 }
        public static IModelUI CreateValueBadgeModelUI(this ElementBuilder elementBuilder, CommandDispatcher commandDispatcher, IValueBadgeModel model)
        {
            var badge = new ValueBadge();

            badge.SetupBuildAndUpdate(model, commandDispatcher, elementBuilder.View, elementBuilder.Context);
            return(badge);
        }
예제 #7
0
 public abstract VisualElement CreateOnboardingElements(CommandDispatcher commandDispatcher);
 /// <summary>
 /// Initializes a new instance of the <see cref="BlackboardDragAndDropHandler"/> class.
 /// </summary>
 /// <param name="dragSource">The drag source.</param>
 /// <param name="dispatcher">The command dispatcher.</param>
 public BlackboardDragAndDropHandler(IDragSource dragSource, CommandDispatcher dispatcher)
 {
     DragSource = dragSource;
     Dispatcher = dispatcher;
 }
 // PF FIXME: instead of having this virtual on the Stencil, tools (VS) should replace the command
 // handler for CreateVariableNodesCommand
 public virtual void OnDragAndDropVariableDeclarations(CommandDispatcher commandDispatcher, List <(IVariableDeclarationModel, SerializableGUID, Vector2)> variablesToCreate)
예제 #10
0
        protected virtual void OnEnable()
        {
            // When we open a window (including when we start the Editor), a new GUID is assigned.
            // When a window is opened and there is a domain reload, the GUID stays the same.
            if (m_GUID == default)
            {
                m_GUID = SerializableGUID.Generate();
            }

            var initialState = CreateInitialState();

            CommandDispatcher = new CommandDispatcher(initialState);

            PluginRepository = new PluginRepository(this);

            rootVisualElement.Clear();
            rootVisualElement.pickingMode = PickingMode.Ignore;

            m_GraphContainer = new VisualElement {
                name = "graphContainer"
            };
            m_GraphView    = CreateGraphView();
            m_MainToolbar  = CreateMainToolbar();
            m_ErrorToolbar = CreateErrorToolbar();
            m_BlankPage    = CreateBlankPage();
            m_BlankPage?.CreateUI();

            if (m_MainToolbar != null)
            {
                rootVisualElement.Add(m_MainToolbar);
            }
            // AddTracingTimeline();
            rootVisualElement.Add(m_GraphContainer);
            if (m_ErrorToolbar != null)
            {
                m_GraphView.Add(m_ErrorToolbar);
            }

            m_GraphContainer.Add(m_GraphView);

            rootVisualElement.name = "gtfRoot";
            rootVisualElement.AddStylesheet("GraphViewWindow.uss");

            // PF FIXME: Use EditorApplication.playModeStateChanged / AssemblyReloadEvents ? Make sure it works on all domain reloads.

            // After a domain reload, all loaded objects will get reloaded and their OnEnable() called again
            // It looks like all loaded objects are put in a deserialization/OnEnable() queue
            // the previous graph's nodes/edges/... might be queued AFTER this window's OnEnable
            // so relying on objects to be loaded/initialized is not safe
            // hence, we need to defer the loading command
            rootVisualElement.schedule.Execute(() =>
            {
                var lastGraphFilePath = CommandDispatcher.State.WindowState.LastOpenedGraph.GetGraphAssetModelPath();
                var lastGraphId       = CommandDispatcher.State.WindowState.LastOpenedGraph.AssetLocalId;
                if (!string.IsNullOrEmpty(lastGraphFilePath))
                {
                    try
                    {
                        CommandDispatcher.Dispatch(new LoadGraphAssetCommand(
                                                       lastGraphFilePath,
                                                       lastGraphId,
                                                       PluginRepository,
                                                       CommandDispatcher.State.WindowState.LastOpenedGraph.BoundObject,
                                                       LoadGraphAssetCommand.LoadStrategies.KeepHistory));
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e);
                    }
                }
            }).ExecuteLater(0);

            m_GraphProcessingPendingLabel = new Label("Graph Processing Pending")
            {
                name = "graph-processing-pending-label"
            };

            if (WithSidePanel)
            {
                m_SidePanel = CreateModelInspectorView();
            }

            if (m_SidePanel != null)
            {
                m_GraphContainer.Add(m_SidePanel);
            }

            rootVisualElement.RegisterCallback <AttachToPanelEvent>(OnEnterPanel);
            rootVisualElement.RegisterCallback <DetachFromPanelEvent>(OnLeavePanel);
            // that will be true when the window is restored during the editor startup, so OnEnterPanel won't be called later
            if (rootVisualElement.panel != null)
            {
                OnEnterPanel(null);
            }

            titleContent = new GUIContent("Graph Tool");

            m_LockTracker.lockStateChanged.AddListener(OnLockStateChanged);

            m_AutomaticGraphProcessor = new AutomaticGraphProcessor(PluginRepository);
            CommandDispatcher.RegisterObserver(m_AutomaticGraphProcessor);
            rootVisualElement.RegisterCallback <MouseMoveEvent>(ResetGraphProcessorTimer);

            m_GraphProcessingStatusObserver = new GraphProcessingStatusObserver(m_GraphProcessingPendingLabel, m_ErrorToolbar);
            CommandDispatcher.RegisterObserver(m_GraphProcessingStatusObserver);

            m_SidePanelObserver = new SidePanelObserver(this);
            CommandDispatcher.RegisterObserver(m_SidePanelObserver);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="BlankPage"/> class.
 /// </summary>
 /// <param name="commandDispatcher">The command dispatcher.</param>
 /// <param name="onboardingProviders">The list of <see cref="OnboardingProviders"/> to display.</param>
 public BlankPage(CommandDispatcher commandDispatcher, IEnumerable <OnboardingProvider> onboardingProviders)
 {
     m_CommandDispatcher = commandDispatcher;
     OnboardingProviders = onboardingProviders;
 }