示例#1
0
        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();
                }
            }
        }
示例#2
0
 public virtual GridViewData[] GetChilds(GridViewData data)
 {
     if (data.IsExpand)
     {
         return(data.Children.ToArray());
     }
     return(new GridViewData[0]);
 }
示例#3
0
        public GridTreeViewItem(GridViewData data)
        {
            ItemData = data;

            id          = ItemData.ID;
            depth       = ItemData.Depth;
            displayName = ItemData.DisplayName;
        }
示例#4
0
 public GridViewModel()
 {
     RootData = new GridViewData(string.Empty)
     {
         ID       = -1,
         Depth    = -1,
         IsExpand = true,
     };
 }
示例#5
0
        public void RemoveItem(SystemObject data)
        {
            GridViewData viewData = ViewModel.GetDataByUserdata(data);

            if (viewData != null)
            {
                ViewModel.RemoveData(viewData);

                Reload();
            }
        }
示例#6
0
 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);
     }
 }
示例#7
0
        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);
        }
示例#8
0
 protected override bool CanMultiSelect(TreeViewItem item)
 {
     if (IsMultiSelect && GetCanMultiSelect != null)
     {
         GridViewData data = ((GridTreeViewItem)item).ItemData;
         return(GetCanMultiSelect(data));
     }
     else
     {
         return(false);
     }
 }
示例#9
0
        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);
            }
        }
示例#10
0
        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);
            }
        }
示例#11
0
        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);
            }
        }
示例#12
0
        protected override float GetCustomRowHeight(int row, TreeViewItem item)
        {
            GridViewData data = ((GridTreeViewItem)item).ItemData;

            return(OnGetRowHeight != null?OnGetRowHeight(data) : base.GetCustomRowHeight(row, item));
        }
示例#13
0
        protected override void ContextClickedItem(int id)
        {
            GridViewData data = ViewModel.GetDataByID(id);

            OnItemContextClicked?.Invoke(data);
        }
示例#14
0
 protected virtual void OnDataExpand(GridViewData data)
 {
 }
示例#15
0
 protected virtual void OnDataCollapse(GridViewData data)
 {
 }
示例#16
0
 public void AddData(GridViewData data)
 {
     AddChildData(RootData, data);
 }
示例#17
0
 public void InsertData(int index, GridViewData data)
 {
     InsertChildData(index, RootData, data);
 }
示例#18
0
 protected virtual void OnItemContextClicked(GridViewData itemData)
 {
 }
示例#19
0
 protected virtual void OnDrawRowItem(Rect rect, GridViewData itemData)
 {
     EditorGUI.LabelField(rect, itemData.DisplayName);
 }
示例#20
0
 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}");
 }
示例#22
0
 protected virtual float GetRowHeight(GridViewData itemData)
 {
     return(EditorGUIUtility.singleLineHeight);
 }
示例#23
0
 protected override float GetRowHeight(GridViewData itemData)
 {
     return(base.GetRowHeight(itemData) + (ShowSeparator? SEPARATOR_LINE_HEIGHT : 0.0f));
 }
示例#24
0
 protected virtual void OnItemDoubleClicked(GridViewData itemData)
 {
 }
示例#25
0
 public virtual bool HasChild(GridViewData data)
 {
     return(data.Children.Count > 0);
 }