コード例 #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);
 }
コード例 #21
0
 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);
 }