private void BuildItems(GridTreeViewItem parentItem, GridViewData data) { GridTreeViewItem item = new GridTreeViewItem(data); if (parentItem.children == null) { parentItem.children = new List <TreeViewItem>(); } parentItem.children.Add(item); if (data.IsExpand) { if (ViewModel.HasChild(data)) { foreach (var child in data.Children) { BuildItems(item, child); } } } else { if (ViewModel.HasChild(data)) { item.children = TreeView.CreateChildListForCollapsedParent(); } } }
public virtual GridViewData[] GetChilds(GridViewData data) { if (data.IsExpand) { return(data.Children.ToArray()); } return(new GridViewData[0]); }
public GridTreeViewItem(GridViewData data) { ItemData = data; id = ItemData.ID; depth = ItemData.Depth; displayName = ItemData.DisplayName; }
public GridViewModel() { RootData = new GridViewData(string.Empty) { ID = -1, Depth = -1, IsExpand = true, }; }
public void RemoveItem(SystemObject data) { GridViewData viewData = ViewModel.GetDataByUserdata(data); if (viewData != null) { ViewModel.RemoveData(viewData); Reload(); } }
private void GetDeepChilds(GridViewData data, ref List <GridViewData> dataList, bool isIncludeSelf = false) { if (isIncludeSelf) { dataList.Add(data); } foreach (var child in data.Children) { GetDeepChilds(child, ref dataList, true); } }
public void AddChildData(GridViewData parentData, GridViewData childData) { parentData.IsExpand = true; parentData.Children.Add(childData); childData.Parent = parentData; childData.ID = m_IDCreator.NextID; childData.Depth = parentData.Depth + 1; m_IDToDataDic.Add(childData.ID, childData); }
protected override bool CanMultiSelect(TreeViewItem item) { if (IsMultiSelect && GetCanMultiSelect != null) { GridViewData data = ((GridTreeViewItem)item).ItemData; return(GetCanMultiSelect(data)); } else { return(false); } }
public void RemoveData(GridViewData data) { GridViewData parentData = data.Parent; parentData.Children.Remove(data); data.Parent = null; List <GridViewData> dataList = new List <GridViewData>(); GetDeepChilds(data, ref dataList, true); foreach (var child in dataList) { m_IDToDataDic.Remove(child.ID); } }
protected override void OnDrawRowItem(Rect rect, GridViewData itemData) { Rect drawRect = rect; if (ShowSeparator) { drawRect.height -= SEPARATOR_LINE_HEIGHT; } EditorGUI.LabelField(drawRect, itemData.DisplayName); if (ShowSeparator) { drawRect.y += drawRect.height; drawRect.height = SEPARATOR_LINE_HEIGHT; EGUI.DrawHorizontalLine(drawRect); } }
protected override void SelectionChanged(IList <int> selectedIds) { if (OnItemSelectedChanged != null) { GridViewData[] datas = new GridViewData[selectedIds.Count]; for (int i = 0; i < selectedIds.Count; ++i) { datas[i] = ViewModel.GetDataByID(selectedIds[i]); } OnItemSelectedChanged(datas); } else { base.SelectionChanged(selectedIds); } }
protected override float GetCustomRowHeight(int row, TreeViewItem item) { GridViewData data = ((GridTreeViewItem)item).ItemData; return(OnGetRowHeight != null?OnGetRowHeight(data) : base.GetCustomRowHeight(row, item)); }
protected override void ContextClickedItem(int id) { GridViewData data = ViewModel.GetDataByID(id); OnItemContextClicked?.Invoke(data); }
protected virtual void OnDataExpand(GridViewData data) { }
protected virtual void OnDataCollapse(GridViewData data) { }
public void AddData(GridViewData data) { AddChildData(RootData, data); }
public void InsertData(int index, GridViewData data) { InsertChildData(index, RootData, data); }
protected virtual void OnItemContextClicked(GridViewData itemData) { }
protected virtual void OnDrawRowItem(Rect rect, GridViewData itemData) { EditorGUI.LabelField(rect, itemData.DisplayName); }
protected virtual void DrawCellItem(Rect cellRect, int index, GridViewData itemData) { EditorGUI.LabelField(cellRect, itemData.DisplayName); }
protected virtual void OnDrawColumnItem(Rect rect, int columnIndex, GridViewData columnItemData) { EditorGUI.LabelField(rect, $"{columnItemData.DisplayName}-{columnIndex}"); }
protected virtual float GetRowHeight(GridViewData itemData) { return(EditorGUIUtility.singleLineHeight); }
protected override float GetRowHeight(GridViewData itemData) { return(base.GetRowHeight(itemData) + (ShowSeparator? SEPARATOR_LINE_HEIGHT : 0.0f)); }
protected virtual void OnItemDoubleClicked(GridViewData itemData) { }
public virtual bool HasChild(GridViewData data) { return(data.Children.Count > 0); }