public RecentsController(LibraryTabElement libraryTab)
 {
     m_libraryTab   = libraryTab;
     m_recentsGroup = libraryTab.Q <GraphGroupFoldout>(RECENTS_FOLDOUT);
     m_recentsGroup.Setup("Recent", GraphGroupFoldout.SortRule.NONE, m_libraryTab.OnObjectFieldDoubleClick);
     m_recentsGroup.AddDisplayFieldManipulator(m_libraryTab.GetAddToFavManip);
 }
 public FavoritesController(LibraryTabElement libraryTab)
 {
     m_libraryTab     = libraryTab;
     m_favoritesGroup = m_libraryTab.Q <GraphGroupFoldout>(FAVORITES_FOLDOUT);
     m_favoritesGroup.Setup("Favorites", GraphGroupFoldout.SortRule.TYPE_AND_NAME, m_libraryTab.OnObjectFieldDoubleClick);
     m_favoritesGroup.AddDisplayFieldManipulator(m_libraryTab.GetRemoveFromFavManip);
 }
            public AllGraphsController(LibraryTabElement libraryTab)
            {
                m_searchField = libraryTab.Q <ToolbarSearchField>(SEARCH_FIELD);
                m_searchField.RegisterValueChangedCallback(x => { OnSearchQueryChanged(x.newValue); });
                m_allGraphsGroup = libraryTab.Q <VisualElement>(ALL_GRAPHS_GROUP);
                m_libraryTab     = libraryTab;

                PopulateGroups();
            }
Exemple #4
0
        /// <summary>
        /// When the UI is enabled, it sets up all the VisualElement references and loads in the window data.
        /// </summary>
        private void OnEnable()
        {
            //==================================Load Initial Data======================================//
            var uxmlAsset = Resources.Load <VisualTreeAsset>(ResourceAssetPaths.LogicalGraphWindow_UXML);

            uxmlAsset.CloneTree(rootVisualElement);
            m_mainSplitView     = rootVisualElement.Q <UIElements.TwoPaneSplitView>(MAIN_SPLITVIEW);
            m_graphTypeMetadata = new GraphTypeMetadata();
            //=========================================================================================//=

            //==================================Register Toolbar=======================================//
            m_toolbar = rootVisualElement.Q <Toolbar>(TOOLBAR);

            // Save Button
            m_saveGraphButton = new ToolbarButton(() =>
            {
                if (m_openedGraphInstance != null)
                {
                    EditorUtility.SetDirty(m_openedGraphInstance);
                    AssetDatabase.SaveAssets();
                }
            });
            m_saveGraphButton.text = "Save";
            m_toolbar.Add(m_saveGraphButton);
            //=========================================================================================//

            //====================================Register Panels======================================//
            // Left panel is dependent on the right (NodeGraphView) so ordering is important!
            VisualElement mainPanelRight = rootVisualElement.Q <VisualElement>(MAIN_PANEL_RIGHT);
            VisualElement mainPanelLeft  = rootVisualElement.Q <VisualElement>(MAIN_PANEL_LEFT);

            // Populate right panel
            m_nodeGraphView = new NodeGraphView(m_graphTypeMetadata);
            m_nodeGraphView.StretchToParentSize();
            m_nodeGraphView.OnAddToSelection      += OnGraphElementSelectionAdded;
            m_nodeGraphView.OnRemoveFromSelection += OnGraphElementSelectionRemoved;
            m_nodeGraphView.OnClearSelection      += OnGraphElementSelectionCleared;
            mainPanelRight.Add(m_nodeGraphView);

            m_customMenuController = new CustomMenuController(mainPanelRight, m_nodeGraphView);

            // Populate left panel
            List <(string, TabContentElement)> tabs = new List <(string, TabContentElement)>();

            tabs.Add(("Library", m_libraryTab = new LibraryTabElement((string guid) => { OpenGraph(guid); }, m_customMenuController, m_graphTypeMetadata)));
            tabs.Add(("Inspector", m_inspectorTab = new InspectorTabElement(m_nodeGraphView)));
            m_nodeGraphView.OnRemoveNode += (node) => { m_inspectorTab.SetNode(null, null); };
            m_mainTabGroup = new TabGroupElement(tabs);
            m_mainTabGroup.StretchToParentSize();
            m_nodeGraphView.OnMouseClick += () => { m_mainTabGroup.SelectTab(m_inspectorTab); };
            mainPanelLeft.Add(m_mainTabGroup);

            // Other setup
            m_inspectorTab.GraphInspector.OnBlackboardElementChanged += (undoGroup) => { m_nodeGraphView.CallAllNodeViewDrawerBlackboardElementChanged(undoGroup); };
            //=========================================================================================//

            //==================================Callback Listeners=====================================//
            GraphModificationProcessor.OnGraphCreated    += OnNewGraphCreated;
            GraphModificationProcessor.OnGraphWillDelete += OnGraphWillDelete;
            //=========================================================================================//

            // Deserialize the editor window data.
            DeserializeData();
        }