Exemplo n.º 1
0
        protected override void InitData()
        {
            WindowConfigSource = FileConfigSource.CreateFileConfigSource("ViewConfig/TestWindow/config.txt", true, typeof(GridViewTestWindowSetting1));

            m_ItemDataSource = WindowConfigSource.GetValue <ItemDataSource>("Gvds");
            if (m_ItemDataSource == null)
            {
                m_ItemDataSource = new ItemDataSource();
                WindowConfigSource.SetValue("Gvds", m_ItemDataSource);
            }
            m_ItemDataSource.SetConfigSource(WindowConfigSource);

            m_GridViewGroup = new GridViewGroup(m_LayoutGroupMgr, m_ItemDataSource);

            var gridView  = m_GridViewGroup.GetGridView();
            var searchBar = m_GridViewGroup.GetSearchBar();

            gridView.LoadConfig("GvConfig", WindowConfigSource);
            searchBar.LoadConfig("Name", WindowConfigSource);

            m_GridViewGroup.GetGridView().GirdItemPopupMenuAction += GirdItemPopupMenuAction;
            m_GridViewGroup.GetGridView().GridViewPopupMenuAction += GridViewPopupMenuAction;

            m_GridViewGroup.UpdateItemsBySearchText();

            m_LayoutGroupMgr.AddViewGroup(m_GridViewGroup);
        }
Exemplo n.º 2
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;
        }
        protected override void InitData()
        {
            WindowConfigSource = FileConfigSource.CreateFileConfigSource("ViewConfig/TestWindow/config4.txt", true, typeof(FolderTreeViewTestWindowConfig));

            m_FolderTreeViewGroup        = new FolderTreeViewGroup(m_LayoutGroupMgr, WindowConfigSource, "TreeViewStateConfig", "TreeViewDataContainer");
            m_FolderTreeViewGroup.Active = false;

            m_DataContainer          = m_FolderTreeViewGroup.GetDataContainer();
            m_DataContainer.ExtNames = ExtNames;
            m_DataContainer.UpdateValidItems();

            m_TreeView = m_FolderTreeViewGroup.GetTreeView();
            m_TreeView.useExpansionAnimation            = true;
            m_TreeView.deselectOnUnhandledMouseDown     = true;
            m_TreeView.contextClickItemCallback         = ContextClickItemCallback;
            m_TreeView.contextClickOutsideItemsCallback = ContextClickOutsideItemsCallback;

            m_LayoutGroupMgr.AddViewGroup(m_FolderTreeViewGroup);

            m_TipsViewGroup             = new TipsViewGroup(m_LayoutGroupMgr);
            m_TipsViewGroup.Active      = false;
            m_TipsViewGroup.TipStr      = "当前根目录路径不存在,请配置根目录路径";
            m_TipsViewGroup.DrawAction += () =>
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("选择目录"))
                {
                    var path = EditorUtility.OpenFolderPanel("选择目录", "", "");
                    if (!string.IsNullOrEmpty(path))
                    {
                        if (m_DataContainer.RootFolderPath != path)
                        {
                            m_DataContainer.RootFolderPath = path;
                            m_TreeView.state.expandedIDs   = new List <int>();
                            m_TreeView.state.selectedIDs   = new List <int>();
                            m_TreeView.state.lastClickedID = Int32.MinValue;
                            m_TreeView.state.scrollPos     = Vector2.zero;
                            if (m_TreeView.data != null)
                            {
                                m_TreeView.data.ReloadData();
                            }
                            WindowConfigSource.SetConfigDirty();
                            WindowConfigSource.SaveConfigLazily();
                        }
                    }
                }
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
            };
            m_LayoutGroupMgr.AddViewGroup(m_TipsViewGroup);
            CheckViewVisible();
        }
        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;
        }
Exemplo n.º 5
0
        protected override void InitData()
        {
            m_WindowConfigSource = FileConfigSource.CreateFileConfigSource("ViewConfig/TestWindow/config5.txt", true, typeof(FolderGridViewTestWindowSetting1));
            //m_WindowConfigSource = AssetConfigSource.CreateAssetConfigSource("config", true, typeof(FolderGridViewTestWindowSetting2));

            m_FolderGridViewGroup        = new FolderGridViewGroup(m_LayoutGroupMgr, m_WindowConfigSource, "TreeViewStateConfig", "TreeViewDataContainer", DragID);
            m_FolderGridViewGroup.Active = false;

            var gridView  = m_FolderGridViewGroup.GetGridView();
            var searchBar = m_FolderGridViewGroup.GetSearchBar();

            m_TreeView = m_FolderGridViewGroup.GetFolderGridViewGroup().GetTreeView();

            m_DataContainer          = m_FolderGridViewGroup.GetDataContainer();
            m_DataContainer.ExtNames = ExtNames;
            m_DataContainer.UpdateValidItems();

            gridView.LoadConfig("GvConfig", WindowConfigSource);
            searchBar.LoadConfig("SearchText", WindowConfigSource);

            gridView.GirdItemPopupMenuAction += GirdItemPopupMenuAction;
            gridView.GridViewPopupMenuAction += GridViewPopupMenuAction;

            m_TreeView = m_FolderGridViewGroup.GetFolderGridViewGroup().GetTreeView();
            m_TreeView.useExpansionAnimation    = true;
            m_TreeView.contextClickItemCallback = ContextClickItemCallback;

            m_FolderGridViewGroup.UpdateSelectionItemsAction += UpdateSelectionItems;
            m_FolderGridViewGroup.UpdateSearchItemsAction    += UpdateSearchItems;
            m_FolderGridViewGroup.UpdateItemsBySearchText();

            m_LayoutGroupMgr.AddViewGroup(m_FolderGridViewGroup);

            m_TipsViewGroup             = new TipsViewGroup(m_LayoutGroupMgr);
            m_TipsViewGroup.Active      = false;
            m_TipsViewGroup.TipStr      = "当前根目录路径不存在,请配置根目录路径";
            m_TipsViewGroup.DrawAction += () =>
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("选择目录"))
                {
                    var path = EditorUtility.OpenFolderPanel("选择目录", "", "");
                    if (!string.IsNullOrEmpty(path))
                    {
                        if (m_DataContainer.RootFolderPath != path)
                        {
                            m_DataContainer.RootFolderPath = path;
                            m_TreeView.state.expandedIDs   = new List <int>();
                            m_TreeView.state.selectedIDs   = new List <int>();
                            m_TreeView.state.lastClickedID = Int32.MinValue;
                            m_TreeView.state.scrollPos     = Vector2.zero;
                            if (m_TreeView.data != null)
                            {
                                m_TreeView.data.ReloadData();
                            }
                            m_WindowConfigSource.SetConfigDirty();
                        }
                    }
                }
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
            };
            m_LayoutGroupMgr.AddViewGroup(m_TipsViewGroup);

            CheckViewVisible();
        }