Exemple #1
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;
        }
Exemple #2
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");
                }
            };
        }