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; }
public FolderTreeViewGroup(ViewGroupManager owner, EditorWindowConfigSource configSource, string stateConfigName, string containerConfigName, string dragId = null) : base(owner) { m_ConfigSource = configSource; if (configSource != null) { m_TreeViewState = configSource.GetValue <TreeViewState>(stateConfigName); if (m_TreeViewState == null) { m_TreeViewState = new TreeViewState(); configSource.SetValue(stateConfigName, m_TreeViewState); configSource.SetConfigDirty(); } m_TreeViewState.SetConfigSource(configSource); m_TreeItemContainer = configSource.GetValue <FolderTreeItemContainer>(containerConfigName); if (m_TreeItemContainer == null) { m_TreeItemContainer = ScriptableObject.CreateInstance <FolderTreeItemContainer>(); m_TreeItemContainer.ConfigSource = configSource; 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); m_DataSource = new FolderTreeViewDataSource(m_TreeView, m_TreeItemContainer, m_ConfigSource); m_TreeViewGUI = new FolderTreeViewGUI(m_TreeView, m_TreeItemContainer); m_TreeViewDragging = new FolderTreeViewDragging(m_TreeView, dragId != null ? dragId : m_TreeView.GetHashCode().ToString()); DeleteItemsAction += DeleteItems; DuplicateItemsAction += DuplicateItems; m_TreeViewGUI.RenameEndAction += RenameItem; m_TreeViewGUI.BeginRenameAction += () => { m_TreeView.state.renameOverlay.isRenamingFilename = true; }; m_TreeViewDragging.EndDragAction += (hasError) => { if (hasError) { m_TreeItemContainer.UpdateValidItems(); } m_TreeView.data.RefreshData(); m_ConfigSource.SetConfigDirty(); }; }
private void RefreshBottomBarSelectedItem(int[] idList) { if (idList != null && idList.Length > 0) { var index = m_GridViewDataSource.GetItemIndexByItemId(idList[0]); if (index == -1) { var item = m_ConfigSource.GetValue <FolderGridItem>(BottomSelectedItem); var parentItem = m_TreeView.FindItem(item.ParentId) as FolderTreeViewItem; if (parentItem == null) { return; } if (parentItem.hasChildren) { foreach (var child in parentItem.children) { if (child.id == item.Id) { m_BottomBarSelectedItem = item; m_BottomBar.SelectedPathSplitted.Clear(); return; } } } if (parentItem.FileList != null) { foreach (var child in parentItem.FileList) { if (child.id == item.Id) { m_BottomBarSelectedItem = item; m_BottomBar.SelectedPathSplitted.Clear(); return; } } } return; } m_BottomBarSelectedItem = m_GridViewDataSource.GetItemByIndex(index) as FolderGridItem; m_ConfigSource.SetValue(BottomSelectedItem, m_BottomBarSelectedItem); m_BottomBar.SelectedPathSplitted.Clear(); } else { m_BottomBarSelectedItem = null; m_ConfigSource.SetValue <FolderGridItem>(BottomSelectedItem, null); m_BottomBar.SelectedPathSplitted.Clear(); } m_ConfigSource.SetConfigDirty(); }
public void LoadConfig(string configName, EditorWindowConfigSource configSource) { m_SearchTextConfigName = configName; m_WindowConfigSource = configSource; if (m_WindowConfigSource != null && !string.IsNullOrEmpty(m_SearchTextConfigName)) { var text = m_WindowConfigSource.GetValue <string>(m_SearchTextConfigName); if (!string.IsNullOrEmpty(text)) { SearchText = text; } } }
public void LoadConfig(string configName, EditorWindowConfigSource configSource) { if (configSource != null && !string.IsNullOrEmpty(configName)) { var viewConfig = configSource.GetValue <GridViewConfig>(configName); if (viewConfig != null) { viewConfig.SetConfigSource(configSource); m_ViewConfig = viewConfig; if (GridSizeChangedAction != null) { GridSizeChangedAction(m_ViewConfig.GridSize); } } else { viewConfig = new GridViewConfig(); viewConfig.SetConfigSource(configSource); configSource.SetValue(configName, viewConfig); } } }
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"); } }; }