Esempio n. 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();
                }
            }
        }
Esempio n. 2
0
        public GridTreeViewItem(GridViewData data)
        {
            ItemData = data;

            id          = ItemData.ID;
            depth       = ItemData.Depth;
            displayName = ItemData.DisplayName;
        }
 public virtual GridViewData[] GetChilds(GridViewData data)
 {
     if (data.IsExpand)
     {
         return(data.Children.ToArray());
     }
     return(new GridViewData[0]);
 }
 public GridViewModel()
 {
     RootData = new GridViewData(string.Empty)
     {
         ID       = -1,
         Depth    = -1,
         IsExpand = true,
     };
 }
 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);
        }
Esempio n. 7
0
        public void RemoveItem(SystemObject data)
        {
            GridViewData viewData = ViewModel.GetDataByUserdata(data);

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

                Reload();
            }
        }
Esempio n. 8
0
 protected override bool CanMultiSelect(TreeViewItem item)
 {
     if (IsMultiSelect && GetCanMultiSelect != null)
     {
         GridViewData data = ((GridTreeViewItem)item).ItemData;
         return(GetCanMultiSelect(data));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 9
0
        protected override void OnDrawRowItem(Rect rect, GridViewData itemData)
        {
            Rect drawRect = rect;

            if (ShowSeparator)
            {
                drawRect.height -= SEPARATOR_LINE_HEIGHT;
            }
            EditorGUI.LabelField(drawRect, itemData.DisplayName);

            drawRect.y     += drawRect.height;
            drawRect.height = SEPARATOR_LINE_HEIGHT;
            EGUI.DrawHorizontalLine(drawRect);
        }
        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);
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 12
0
 protected virtual void DrawCellItem(Rect cellRect, int index, GridViewData itemData)
 {
     EditorGUI.LabelField(cellRect, itemData.DisplayName);
 }
 protected virtual void OnDataCollapse(GridViewData data)
 {
 }
 protected virtual void OnDataExpand(GridViewData data)
 {
 }
 public virtual bool HasChild(GridViewData data)
 {
     return(data.Children.Count > 0);
 }
Esempio n. 16
0
 protected virtual void OnItemDoubleClicked(GridViewData itemData)
 {
 }
Esempio n. 17
0
 protected virtual void OnItemContextClicked(GridViewData itemData)
 {
 }
 public void InsertData(int index, GridViewData data)
 {
     InsertChildData(index, RootData, data);
 }
Esempio n. 19
0
 protected virtual void DrawRowItem(Rect rect, GridViewData itemData)
 {
     EditorGUI.LabelField(rect, itemData.DisplayName);
 }
Esempio n. 20
0
        protected override float GetCustomRowHeight(int row, TreeViewItem item)
        {
            GridViewData data = ((GridTreeViewItem)item).ItemData;

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

            OnItemContextClicked?.Invoke(data);
        }
 public void AddData(GridViewData data)
 {
     AddChildData(RootData, data);
 }
Esempio n. 23
0
 protected virtual void OnDrawColumnItem(Rect rect, int columnIndex, GridViewData columnItemData)
 {
     EditorGUI.LabelField(rect, $"{columnItemData.DisplayName}-{columnIndex}");
 }
Esempio n. 24
0
 protected virtual float GetRowHeight(GridViewData itemData)
 {
     return(EditorGUIUtility.singleLineHeight);
 }
Esempio n. 25
0
 protected override float GetRowHeight(GridViewData itemData)
 {
     return(base.GetRowHeight(itemData) + (ShowSeparator? SEPARATOR_LINE_HEIGHT : 0.0f));
 }