예제 #1
0
        protected override void InitData()
        {
            WindowConfigSource = FileConfigSource.CreateFileConfigSource("ViewConfig/TestWindow/config6.txt", true, typeof(GraphEditorWindowSetting));

            m_GraphViewGroup = new GraphViewGroup(m_LayoutGroupMgr, WindowConfigSource, "TreeViewStateConfig", "TreeViewDataContainer");
            m_GraphView      = m_GraphViewGroup.graphView;

            m_GraphViewGroup.showMainButton = true;
            m_GraphViewGroup.mainButtonName = "Categories";

            m_DataContainer = m_GraphViewGroup.treeItemContainer;
            m_TreeView      = m_GraphViewGroup.treeView;
            m_TreeView.useExpansionAnimation            = true;
            m_TreeView.contextClickItemCallback         = ContextClickItemCallback;
            m_TreeView.contextClickOutsideItemsCallback = ContextClickOutsideItemsCallback;
            m_TreeView.selectionChangedCallback        += TreeViewSelectionChanged;

            m_LayoutGroupMgr.AddViewGroup(m_GraphViewGroup);

            m_GraphViewGroup.objectTreeViewGroup.needUndo         = false;
            m_GraphViewGroup.objectTreeViewGroup.OnGUIInitAction += () =>
            {
                TreeViewSelectionChanged(m_TreeView.GetSelection());
            };
            m_GraphViewGroup.objectTreeViewGroup.GetTreeViewGUI().RenameEndAction += (item, text) =>
            {
                m_TreeView.data.OnSearchChanged();
            };

            m_GraphViewGroup.searchBar.OnTextChangedAction += OnTextChangedAction;
            m_GraphViewGroup.searchBar.LoadConfig("searchText", WindowConfigSource);
            m_TreeView.state.searchString = m_GraphViewGroup.searchBar.SearchText;
            m_TreeView.dragEndedCallback += DragEnedCallback;
        }
예제 #2
0
        public GraphViewGroup(ViewGroupManager owner, EditorWindowConfigSource configSource, string stateConfigName,
                              string containerConfigName, string dragId = null) : base(owner)
        {
            m_WindowConfig = configSource;
            if (m_WindowConfig != null)
            {
                if (m_WindowConfig.FindProperty(mainButtonOnConfigKey) != null)
                {
                    m_IsMainButtonOn = m_WindowConfig.GetValue <bool>(mainButtonOnConfigKey);
                }

                if (configSource.FindProperty(stateConfigName) != null)
                {
                    m_TreeViewState = configSource.GetValue <TreeViewState>(stateConfigName);
                }
                if (m_TreeViewState == null)
                {
                    m_TreeViewState = new TreeViewState();
                    if (configSource.FindProperty(stateConfigName) != null)
                    {
                        configSource.SetValue(stateConfigName, m_TreeViewState);
                    }
                    configSource.SetConfigDirty();
                }
                m_TreeViewState.SetConfigSource(configSource);

                if (configSource.FindProperty(containerConfigName) != null)
                {
                    m_TreeItemContainer = configSource.GetValue <TreeItemContainer>(containerConfigName);
                }
                if (m_TreeItemContainer == null)
                {
                    m_TreeItemContainer = ScriptableObject.CreateInstance <TreeItemContainer>();
                    m_TreeItemContainer.ConfigSource = configSource;
                    if (configSource.FindProperty(containerConfigName) != null)
                    {
                        configSource.SetValue(containerConfigName, m_TreeItemContainer);
                    }
                    configSource.SetConfigDirty();
                }
                else
                {
                    m_TreeItemContainer.ConfigSource = configSource;
                    m_TreeItemContainer.UpdateItemsParent();
                }
            }

            m_GraphView = new GraphView(owner, configSource);

            m_HorizontalSplitLine = new HorizontalSplitLine(m_SplitLineStartPosX, HorizontalSplitLineMinX);
            m_HorizontalSplitLine.ConfigSource = configSource;

            m_ObjectTreeViewGroup = new ObjectTreeViewGroup(owner, configSource, stateConfigName, containerConfigName,
                                                            dragId);
            m_TreeView = m_ObjectTreeViewGroup.GetTreeView();

            m_SearchBar              = new SearchBar(owner);
            m_SearchBar.OnGUIAction += ShowBarGUI;
        }
        protected override void InitData()
        {
            WindowConfigSource = FileConfigSource.CreateFileConfigSource("ViewConfig/TestWindow/config3.txt", true, typeof(ObjectTreeViewTestWindowConfig));

            m_ObjectTreeViewGroup = new ObjectTreeViewGroup(m_LayoutGroupMgr, WindowConfigSource, "TreeViewStateConfig", "TreeViewDataContainer");

            m_DataContainer = m_ObjectTreeViewGroup.GetDataContainer();
            m_TreeView      = m_ObjectTreeViewGroup.GetTreeView();
            m_TreeView.useExpansionAnimation            = true;
            m_TreeView.deselectOnUnhandledMouseDown     = true;
            m_TreeView.contextClickItemCallback         = ContextClickItemCallback;
            m_TreeView.contextClickOutsideItemsCallback = ContextClickOutsideItemsCallback;

            m_LayoutGroupMgr.AddViewGroup(m_ObjectTreeViewGroup);

            Undo.undoRedoPerformed += UndoRedoPerformedAction;
        }
예제 #4
0
        public ObjectTreeViewGroup(ViewGroupManager owner, EditorWindowConfigSource configSource,
                                   string stateConfigName, string containerConfigName, string dragId = null) : base(owner)
        {
            m_ConfigSource = configSource;
            if (configSource != null)
            {
                if (configSource.FindProperty(stateConfigName) != null)
                {
                    m_TreeViewState = configSource.GetValue <TreeViewState>(stateConfigName);
                }
                if (m_TreeViewState == null)
                {
                    m_TreeViewState = new TreeViewState();
                    if (configSource.FindProperty(stateConfigName) != null)
                    {
                        configSource.SetValue(stateConfigName, m_TreeViewState);
                    }
                    configSource.SetConfigDirty();
                }
                m_TreeViewState.SetConfigSource(configSource);

                if (configSource.FindProperty(containerConfigName) != null)
                {
                    m_TreeItemContainer = configSource.GetValue <TreeItemContainer>(containerConfigName);
                }
                if (m_TreeItemContainer == null)
                {
                    m_TreeItemContainer = ScriptableObject.CreateInstance <TreeItemContainer>();
                    m_TreeItemContainer.ConfigSource = configSource;
                    if (configSource.FindProperty(containerConfigName) != null)
                    {
                        configSource.SetValue(containerConfigName, m_TreeItemContainer);
                    }
                    configSource.SetConfigDirty();
                }
                else
                {
                    m_TreeItemContainer.ConfigSource = configSource;
                    m_TreeItemContainer.UpdateItemsParent();
                }
            }

            if (m_TreeViewState == null)
            {
                m_TreeViewState = new TreeViewState();
            }

            m_TreeView         = new TreeView(owner.WindowOwner, m_TreeViewState);
            dataSource         = new ObjectTreeViewDataSource(m_TreeView, m_TreeItemContainer, m_ConfigSource);
            m_TreeViewGUI      = new ObjectTreeViewGUI(m_TreeView);
            m_TreeViewDragging = new ObjectTreeViewDragging(m_TreeView,
                                                            dragId != null ? dragId : m_TreeView.GetHashCode().ToString());

            DeleteItemsAction    += DeleteItems;
            DuplicateItemsAction += DuplicateItems;

            m_TreeViewGUI.BeginRenameAction += () =>
            {
                if (needUndo)
                {
                    Undo.RegisterCompleteObjectUndo(m_TreeItemContainer, "Rename Item");
                }
            };
            m_TreeViewDragging.PrepareDoDrag += () =>
            {
                if (needUndo)
                {
                    Undo.RegisterCompleteObjectUndo(m_TreeItemContainer, "Reparent Item");
                }
            };
        }