Exemple #1
0
        public bool IsLastClickedPartOfRows()
        {
            List <TreeViewItem> rows = this.data.GetRows();

            if (rows.Count == 0)
            {
                return(false);
            }
            return(TreeView.GetIndexOfID(rows, this.state.lastClickedID) >= 0);
        }
Exemple #2
0
 public virtual void RemoveFakeItem()
 {
     if (this.HasFakeItem())
     {
         List <TreeViewItem> rows = this.GetRows();
         int indexOfID            = TreeView.GetIndexOfID(rows, this.m_FakeItem.id);
         if (indexOfID != -1)
         {
             rows.RemoveAt(indexOfID);
         }
         this.m_FakeItem = null;
     }
 }
        public override void InsertFakeItem(int id, int parentID, string name, Texture2D icon)
        {
            TreeViewItem treeViewItem1 = this.FindItem(id);

            if (treeViewItem1 != null)
            {
                Debug.LogError((object)("Cannot insert fake Item because id is not unique " + (object)id + " Item already there: " + treeViewItem1.displayName));
            }
            else if (this.FindItem(parentID) != null)
            {
                this.SetExpanded(parentID, true);
                List <TreeViewItem> rows   = this.GetRows();
                int          indexOfId1    = TreeView.GetIndexOfID(rows, parentID);
                TreeViewItem treeViewItem2 = indexOfId1 < 0 ? this.m_RootItem : rows[indexOfId1];
                int          depth         = treeViewItem2.depth + 1;
                this.m_FakeItem      = new TreeViewItem(id, depth, treeViewItem2, name);
                this.m_FakeItem.icon = icon;
                int itemIdForNewItem = this.GetInsertAfterItemIDForNewItem(name, treeViewItem2);
                int indexOfId2       = TreeView.GetIndexOfID(rows, itemIdForNewItem);
                if (indexOfId2 >= 0)
                {
                    do
                    {
                        ;
                    }while (++indexOfId2 < rows.Count && rows[indexOfId2].depth > depth);
                    if (indexOfId2 < rows.Count)
                    {
                        rows.Insert(indexOfId2, this.m_FakeItem);
                    }
                    else
                    {
                        rows.Add(this.m_FakeItem);
                    }
                }
                else if (rows.Count > 0)
                {
                    rows.Insert(0, this.m_FakeItem);
                }
                else
                {
                    rows.Add(this.m_FakeItem);
                }
                this.m_NeedRefreshVisibleFolders = false;
                this.m_TreeView.Frame(this.m_FakeItem.id, true, false);
                this.m_TreeView.Repaint();
            }
            else
            {
                Debug.LogError((object)("No parent Item found with ID: " + (object)parentID));
            }
        }
Exemple #4
0
        public void OffsetSelection(int offset)
        {
            List <TreeViewItem> rows = this.data.GetRows();

            if (rows.Count == 0)
            {
                return;
            }
            Event.current.Use();
            int row = Mathf.Clamp(TreeView.GetIndexOfID(rows, this.state.lastClickedID) + offset, 0, rows.Count - 1);

            this.EnsureRowIsVisible(row, true);
            this.SelectionByKey(rows[row]);
        }
Exemple #5
0
        public virtual void RemoveFakeItem()
        {
            if (!this.HasFakeItem())
            {
                return;
            }
            List <TreeViewItem> visibleRows = this.GetVisibleRows();
            int indexOfID = TreeView.GetIndexOfID(visibleRows, this.m_FakeItem.id);

            if (indexOfID != -1)
            {
                visibleRows.RemoveAt(indexOfID);
            }
            this.m_FakeItem = null;
        }
        public virtual void RemoveFakeItem()
        {
            if (!this.HasFakeItem())
            {
                return;
            }
            List <TreeViewItem> rows = this.GetRows();
            int indexOfId            = TreeView.GetIndexOfID(rows, this.m_FakeItem.id);

            if (indexOfId != -1)
            {
                rows.RemoveAt(indexOfId);
            }
            this.m_FakeItem = (TreeViewItem)null;
        }
Exemple #7
0
        public void OffsetSelection(int offset)
        {
            List <TreeViewItem> visibleRows = this.data.GetVisibleRows();

            if (visibleRows.Count == 0)
            {
                return;
            }
            Event.current.Use();
            int indexOfID = TreeView.GetIndexOfID(visibleRows, this.state.lastClickedID);
            int num       = Mathf.Clamp(indexOfID + offset, 0, visibleRows.Count - 1);

            this.EnsureRowIsVisible(num, visibleRows);
            this.SelectionByKey(visibleRows[num]);
        }
Exemple #8
0
 public override void InsertFakeItem(int id, int parentID, string name, Texture2D icon)
 {
   bool isCreatingNewFolder = this.GetCreateAssetUtility().endAction is DoCreateFolder;
   TreeViewItem treeViewItem1 = this.FindItem(id);
   if (treeViewItem1 != null)
     Debug.LogError((object) ("Cannot insert fake Item because id is not unique " + (object) id + " Item already there: " + treeViewItem1.displayName));
   else if (this.FindItem(parentID) != null)
   {
     this.SetExpanded(parentID, true);
     List<TreeViewItem> rows = this.GetRows();
     int indexOfId1 = TreeView.GetIndexOfID(rows, parentID);
     TreeViewItem treeViewItem2 = indexOfId1 < 0 ? this.m_RootItem : rows[indexOfId1];
     int depth = treeViewItem2.depth + (treeViewItem2 != this.m_RootItem ? 1 : 0);
     this.m_FakeItem = new TreeViewItem(id, depth, treeViewItem2, name);
     this.m_FakeItem.icon = icon;
     int itemIdForNewItem = this.GetInsertAfterItemIDForNewItem(name, treeViewItem2, isCreatingNewFolder, this.foldersFirst);
     int indexOfId2 = TreeView.GetIndexOfID(rows, itemIdForNewItem);
     if (indexOfId2 >= 0)
     {
       do
         ;
       while (++indexOfId2 < rows.Count && rows[indexOfId2].depth > depth);
       if (indexOfId2 < rows.Count)
         rows.Insert(indexOfId2, this.m_FakeItem);
       else
         rows.Add(this.m_FakeItem);
     }
     else if (rows.Count > 0)
       rows.Insert(0, this.m_FakeItem);
     else
       rows.Add(this.m_FakeItem);
     this.m_NeedRefreshVisibleFolders = false;
     this.m_TreeView.Frame(this.m_FakeItem.id, true, false);
     this.m_TreeView.Repaint();
   }
   else
     Debug.LogError((object) "No parent Item found");
 }
Exemple #9
0
        public void Frame(int id, bool frame, bool ping)
        {
            float        num          = -1f;
            TreeViewItem treeViewItem = null;

            if (frame)
            {
                this.RevealNode(id);
                List <TreeViewItem> visibleRows = this.data.GetVisibleRows();
                int indexOfID = TreeView.GetIndexOfID(visibleRows, id);
                if (indexOfID >= 0)
                {
                    treeViewItem = visibleRows[indexOfID];
                    num          = this.gui.GetTopPixelOfRow(indexOfID, visibleRows);
                    this.EnsureRowIsVisible(indexOfID, visibleRows);
                }
            }
            if (ping)
            {
                if (num == -1f)
                {
                    List <TreeViewItem> visibleRows2 = this.data.GetVisibleRows();
                    int indexOfID2 = TreeView.GetIndexOfID(visibleRows2, id);
                    if (indexOfID2 >= 0)
                    {
                        treeViewItem = visibleRows2[indexOfID2];
                        num          = this.gui.GetTopPixelOfRow(indexOfID2, visibleRows2);
                    }
                }
                if (num >= 0f && treeViewItem != null)
                {
                    float num2 = (this.GetContentSize().y <= this.m_TotalRect.height) ? 0f : -16f;
                    this.gui.BeginPingNode(treeViewItem, num, this.m_TotalRect.width + num2);
                }
            }
        }
Exemple #10
0
        public override void InsertFakeItem(int id, int parentID, string name, Texture2D icon)
        {
            bool         isCreatingNewFolder = this.GetCreateAssetUtility().endAction is DoCreateFolder;
            TreeViewItem treeViewItem        = this.FindItem(id);

            if (treeViewItem != null)
            {
                Debug.LogError(string.Concat(new object[]
                {
                    "Cannot insert fake Item because id is not unique ",
                    id,
                    " Item already there: ",
                    treeViewItem.displayName
                }));
                return;
            }
            if (this.FindItem(parentID) != null)
            {
                this.SetExpanded(parentID, true);
                List <TreeViewItem> rows = this.GetRows();
                int          indexOfID   = TreeView.GetIndexOfID(rows, parentID);
                TreeViewItem treeViewItem2;
                if (indexOfID >= 0)
                {
                    treeViewItem2 = rows[indexOfID];
                }
                else
                {
                    treeViewItem2 = this.m_RootItem;
                }
                int num = treeViewItem2.depth + ((treeViewItem2 != this.m_RootItem) ? 1 : 0);
                this.m_FakeItem      = new TreeViewItem(id, num, treeViewItem2, name);
                this.m_FakeItem.icon = icon;
                int insertAfterItemIDForNewItem = this.GetInsertAfterItemIDForNewItem(name, treeViewItem2, isCreatingNewFolder, this.foldersFirst);
                int num2 = TreeView.GetIndexOfID(rows, insertAfterItemIDForNewItem);
                if (num2 >= 0)
                {
                    while (++num2 < rows.Count)
                    {
                        if (rows[num2].depth <= num)
                        {
                            break;
                        }
                    }
                    if (num2 < rows.Count)
                    {
                        rows.Insert(num2, this.m_FakeItem);
                    }
                    else
                    {
                        rows.Add(this.m_FakeItem);
                    }
                }
                else if (rows.Count > 0)
                {
                    rows.Insert(0, this.m_FakeItem);
                }
                else
                {
                    rows.Add(this.m_FakeItem);
                }
                this.m_NeedRefreshVisibleFolders = false;
                this.m_TreeView.Frame(this.m_FakeItem.id, true, false);
                this.m_TreeView.Repaint();
            }
            else
            {
                Debug.LogError("No parent Item found");
            }
        }
        public override void InsertFakeItem(int id, int parentID, string name, Texture2D icon)
        {
            TreeViewItem treeViewItem = this.FindItem(id);

            if (treeViewItem != null)
            {
                Debug.LogError(string.Concat(new object[]
                {
                    "Cannot insert fake Item because id is not unique ",
                    id,
                    " Item already there: ",
                    treeViewItem.displayName
                }));
                return;
            }
            if (this.FindItem(parentID) != null)
            {
                this.SetExpanded(parentID, true);
                List <TreeViewItem> visibleRows = this.GetVisibleRows();
                int          indexOfID          = TreeView.GetIndexOfID(visibleRows, parentID);
                TreeViewItem treeViewItem2;
                if (indexOfID >= 0)
                {
                    treeViewItem2 = visibleRows[indexOfID];
                }
                else
                {
                    treeViewItem2 = this.m_RootItem;
                }
                int num = treeViewItem2.depth + 1;
                this.m_FakeItem      = new TreeViewItem(id, num, treeViewItem2, name);
                this.m_FakeItem.icon = icon;
                int insertAfterItemIDForNewItem = this.GetInsertAfterItemIDForNewItem(name, treeViewItem2);
                int num2 = TreeView.GetIndexOfID(visibleRows, insertAfterItemIDForNewItem);
                if (num2 >= 0)
                {
                    while (++num2 < visibleRows.Count)
                    {
                        if (visibleRows[num2].depth <= num)
                        {
                            break;
                        }
                    }
                    if (num2 < visibleRows.Count)
                    {
                        visibleRows.Insert(num2, this.m_FakeItem);
                    }
                    else
                    {
                        visibleRows.Add(this.m_FakeItem);
                    }
                }
                else
                {
                    if (visibleRows.Count > 0)
                    {
                        visibleRows.Insert(0, this.m_FakeItem);
                    }
                    else
                    {
                        visibleRows.Add(this.m_FakeItem);
                    }
                }
                this.m_NeedRefreshVisibleFolders = false;
                this.m_TreeView.Frame(this.m_FakeItem.id, true, false);
                this.m_TreeView.Repaint();
            }
            else
            {
                Debug.LogError("No parent Item found with ID: " + parentID);
            }
        }
        public override void InsertFakeItem(int id, int parentID, string name, Texture2D icon)
        {
            bool         isCreatingNewFolder = this.GetCreateAssetUtility().endAction is DoCreateFolder;
            TreeViewItem item = this.FindItem(id);

            if (item != null)
            {
                Debug.LogError(string.Concat(new object[] { "Cannot insert fake Item because id is not unique ", id, " Item already there: ", item.displayName }));
            }
            else if (this.FindItem(parentID) == null)
            {
                Debug.LogError("No parent Item found");
            }
            else
            {
                TreeViewItem rootItem;
                this.SetExpanded(parentID, true);
                List <TreeViewItem> rows = this.GetRows();
                int indexOfID            = TreeView.GetIndexOfID(rows, parentID);
                if (indexOfID >= 0)
                {
                    rootItem = rows[indexOfID];
                }
                else
                {
                    rootItem = base.m_RootItem;
                }
                int depth = rootItem.depth + ((rootItem != base.m_RootItem) ? 1 : 0);
                base.m_FakeItem      = new TreeViewItem(id, depth, rootItem, name);
                base.m_FakeItem.icon = icon;
                int num3  = this.GetInsertAfterItemIDForNewItem(name, rootItem, isCreatingNewFolder, this.foldersFirst);
                int index = TreeView.GetIndexOfID(rows, num3);
                if (index < 0)
                {
                    if (rows.Count > 0)
                    {
                        rows.Insert(0, base.m_FakeItem);
                    }
                    else
                    {
                        rows.Add(base.m_FakeItem);
                    }
                }
                else
                {
                    while (++index < rows.Count)
                    {
                        if (rows[index].depth <= depth)
                        {
                            break;
                        }
                    }
                    if (index < rows.Count)
                    {
                        rows.Insert(index, base.m_FakeItem);
                    }
                    else
                    {
                        rows.Add(base.m_FakeItem);
                    }
                }
                base.m_NeedRefreshVisibleFolders = false;
                base.m_TreeView.Frame(base.m_FakeItem.id, true, false);
                base.m_TreeView.Repaint();
            }
        }
Exemple #13
0
        public bool IsLastClickedPartOfRows()
        {
            List <TreeViewItem> rows = this.data.GetRows();

            return(rows.Count != 0 && TreeView.GetIndexOfID(rows, this.state.lastClickedID) >= 0);
        }
        public override void InsertFakeItem(int id, int parentID, string name, Texture2D icon)
        {
            TreeViewItem item = this.FindItem(id);

            if (item != null)
            {
                Debug.LogError(string.Concat(new object[] { "Cannot insert fake Item because id is not unique ", id, " Item already there: ", item.displayName }));
            }
            else if (this.FindItem(parentID) == null)
            {
                Debug.LogError("No parent Item found with ID: " + parentID);
            }
            else
            {
                TreeViewItem rootItem;
                this.SetExpanded(parentID, true);
                List <TreeViewItem> visibleRows = this.GetVisibleRows();
                int indexOfID = TreeView.GetIndexOfID(visibleRows, parentID);
                if (indexOfID >= 0)
                {
                    rootItem = visibleRows[indexOfID];
                }
                else
                {
                    rootItem = base.m_RootItem;
                }
                int depth = rootItem.depth + 1;
                base.m_FakeItem      = new TreeViewItem(id, depth, rootItem, name);
                base.m_FakeItem.icon = icon;
                int insertAfterItemIDForNewItem = this.GetInsertAfterItemIDForNewItem(name, rootItem);
                int index = TreeView.GetIndexOfID(visibleRows, insertAfterItemIDForNewItem);
                if (index < 0)
                {
                    if (visibleRows.Count > 0)
                    {
                        visibleRows.Insert(0, base.m_FakeItem);
                    }
                    else
                    {
                        visibleRows.Add(base.m_FakeItem);
                    }
                }
                else
                {
                    while (++index < visibleRows.Count)
                    {
                        if (visibleRows[index].depth <= depth)
                        {
                            break;
                        }
                    }
                    if (index < visibleRows.Count)
                    {
                        visibleRows.Insert(index, base.m_FakeItem);
                    }
                    else
                    {
                        visibleRows.Add(base.m_FakeItem);
                    }
                }
                base.m_NeedRefreshVisibleFolders = false;
                base.m_TreeView.Frame(base.m_FakeItem.id, true, false);
                base.m_TreeView.Repaint();
            }
        }
Exemple #15
0
        public virtual bool IsRevealed(int id)
        {
            List <TreeViewItem> rows = this.GetRows();

            return(TreeView.GetIndexOfID(rows, id) >= 0);
        }
Exemple #16
0
        public bool IsVisible(int id)
        {
            List <TreeViewItem> visibleRows = this.data.GetVisibleRows();

            return(TreeView.GetIndexOfID(visibleRows, id) >= 0);
        }
Exemple #17
0
 public virtual bool IsRevealed(int id)
 {
     return(TreeView.GetIndexOfID(this.GetRows(), id) >= 0);
 }