Exemple #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;
        }
Exemple #2
0
        private void HandleCommandEventsForTreeView()
        {
            var type = Event.current.type;

            switch (type)
            {
            case EventType.ExecuteCommand:
            case EventType.ValidateCommand:
                var flag      = type == EventType.ExecuteCommand;
                var selection = m_TreeView.GetSelection();
                if (selection.Length == 0 || !m_TreeView.HasFocus())
                {
                    return;
                }
                if (Event.current.commandName == "Delete" || Event.current.commandName == "SoftDelete")
                {
                    Event.current.Use();
                    if (flag)
                    {
                        var askIfSure = Event.current.commandName == "SoftDelete";
                        if (DeleteItemsAction != null)
                        {
                            DeleteItemsAction(askIfSure);
                        }

                        if (DeleteDoneAction != null)
                        {
                            DeleteDoneAction();
                        }

                        m_TreeView.NotifyListenersThatSelectionChanged();
                    }
                    GUIUtility.ExitGUI();
                }
                else if (Event.current.commandName == "Duplicate")
                {
                    if (flag)
                    {
                        if (DuplicateItemsAction != null)
                        {
                            Event.current.Use();
                            DuplicateItemsAction();
                            m_TreeView.NotifyListenersThatSelectionChanged();
                        }
                    }
                    else
                    {
                        Event.current.Use();
                    }
                }
                break;
            }
        }
Exemple #3
0
 private void DragEnedCallback(int[] draggedIDs, bool draggedItemsFromOwnTreeView)
 {
     TreeViewSelectionChanged(m_TreeView.GetSelection());
 }