Пример #1
0
 public void OnGUI(List<ColumnViewElement> elements, ColumnView.ObjectColumnFunction previewColumnFunction, ColumnView.ObjectColumnFunction selectedSearchItemFunction, ColumnView.ObjectColumnFunction selectedRegularItemFunction, ColumnView.ObjectColumnGetDataFunction getDataForDraggingFunction)
 {
   ColumnView.InitStyles();
   this.m_ScrollPosition = GUILayout.BeginScrollView(this.m_ScrollPosition);
   GUILayout.BeginHorizontal();
   List<ColumnViewElement> columnViewElements = elements;
   int columnIndex = 0;
   object selectedObject;
   do
   {
     if (this.m_ListViewStates.Count == columnIndex)
       this.m_ListViewStates.Add(new ListViewState());
     if (this.m_CachedSelectedIndices.Count == columnIndex)
       this.m_CachedSelectedIndices.Add(-1);
     ListViewState listViewState = this.m_ListViewStates[columnIndex];
     listViewState.totalRows = columnViewElements.Count;
     if (columnIndex == 0)
       GUILayout.BeginVertical(GUILayout.MaxWidth(this.columnWidth));
     int cachedSelectedIndex = this.m_CachedSelectedIndices[columnIndex];
     int index1 = this.DoListColumn(listViewState, columnViewElements, columnIndex, cachedSelectedIndex, columnIndex != 0 ? (ColumnView.ObjectColumnFunction) null : selectedSearchItemFunction, selectedRegularItemFunction, getDataForDraggingFunction);
     if (Event.current.type == EventType.Layout && this.m_ColumnToFocusKeyboard == columnIndex)
     {
       this.m_ColumnToFocusKeyboard = -1;
       GUIUtility.keyboardControl = listViewState.ID;
       if (listViewState.row == -1 && columnViewElements.Count != 0)
         index1 = listViewState.row = 0;
     }
     if (columnIndex == 0)
     {
       if (this.isSearching)
       {
         KeyCode keyCode = ColumnView.StealImportantListviewKeys();
         if (keyCode != KeyCode.None)
           ListViewShared.SendKey(this.m_ListViewStates[0], keyCode);
       }
       this.m_SearchText = EditorGUILayout.ToolbarSearchField(this.m_SearchText);
       GUILayout.EndVertical();
     }
     if (index1 >= columnViewElements.Count)
       index1 = -1;
     if (Event.current.type == EventType.Layout && this.m_CachedSelectedIndices[columnIndex] != index1 && this.m_ListViewStates.Count > columnIndex + 1)
     {
       int index2 = columnIndex + 1;
       int count = this.m_ListViewStates.Count - (columnIndex + 1);
       this.m_ListViewStates.RemoveRange(index2, count);
       this.m_CachedSelectedIndices.RemoveRange(index2, count);
     }
     this.m_CachedSelectedIndices[columnIndex] = index1;
     selectedObject = index1 <= -1 ? (object) null : columnViewElements[index1].value;
     columnViewElements = selectedObject as List<ColumnViewElement>;
     ++columnIndex;
   }
   while (columnViewElements != null);
   for (; columnIndex < this.minimumNumberOfColumns; ++columnIndex)
     this.DoDummyColumn();
   ColumnView.DoPreviewColumn(selectedObject, previewColumnFunction);
   GUILayout.EndHorizontal();
   GUILayout.EndScrollView();
 }
Пример #2
0
 private void DoDoubleClick(ListViewElement element, ColumnViewElement columnViewElement, ColumnView.ObjectColumnFunction selectedSearchItemFunction, ColumnView.ObjectColumnFunction selectedRegularItemFunction)
 {
   if (Event.current.type != EventType.MouseDown || !element.position.Contains(Event.current.mousePosition) || (Event.current.button != 0 || Event.current.clickCount != 2))
     return;
   if (this.isSearching)
     this.DoSearchItemSelectedEvent(selectedSearchItemFunction, columnViewElement.value);
   else
     ColumnView.DoItemSelectedEvent(selectedRegularItemFunction, columnViewElement.value);
 }
Пример #3
0
 private static void DoDragAndDrop(ListViewState listView, ListViewElement element, List<ColumnViewElement> columnViewElements, ColumnView.ObjectColumnGetDataFunction getDataForDraggingFunction)
 {
   if (GUIUtility.hotControl == listView.ID && Event.current.type == EventType.MouseDown && (element.position.Contains(Event.current.mousePosition) && Event.current.button == 0))
     ((DragAndDropDelay) GUIUtility.GetStateObject(typeof (DragAndDropDelay), listView.ID)).mouseDownPosition = Event.current.mousePosition;
   if (GUIUtility.hotControl != listView.ID || Event.current.type != EventType.MouseDrag || (!GUIClip.visibleRect.Contains(Event.current.mousePosition) || !((DragAndDropDelay) GUIUtility.GetStateObject(typeof (DragAndDropDelay), listView.ID)).CanStartDrag()))
     return;
   object data = getDataForDraggingFunction != null ? getDataForDraggingFunction(columnViewElements[listView.row].value) : (object) null;
   if (data == null)
     return;
   DragAndDrop.PrepareStartDrag();
   DragAndDrop.objectReferences = new Object[0];
   DragAndDrop.paths = (string[]) null;
   DragAndDrop.SetGenericData("CustomDragData", data);
   DragAndDrop.StartDrag(columnViewElements[listView.row].name);
   Event.current.Use();
 }
Пример #4
0
 private int DoListColumn(ListViewState listView, List<ColumnViewElement> columnViewElements, int columnIndex, int selectedIndex, ColumnView.ObjectColumnFunction selectedSearchItemFunction, ColumnView.ObjectColumnFunction selectedRegularItemFunction, ColumnView.ObjectColumnGetDataFunction getDataForDraggingFunction)
 {
   if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return && listView.row > -1)
   {
     if (this.isSearching && selectedSearchItemFunction != null)
       this.DoSearchItemSelectedEvent(selectedSearchItemFunction, columnViewElements[selectedIndex].value);
     if (!this.isSearching && GUIUtility.keyboardControl == listView.ID && selectedRegularItemFunction != null)
       ColumnView.DoItemSelectedEvent(selectedRegularItemFunction, columnViewElements[selectedIndex].value);
   }
   if (GUIUtility.keyboardControl == listView.ID && Event.current.type == EventType.KeyDown && !this.isSearching)
   {
     switch (Event.current.keyCode)
     {
       case KeyCode.RightArrow:
         this.m_ColumnToFocusKeyboard = columnIndex + 1;
         Event.current.Use();
         break;
       case KeyCode.LeftArrow:
         this.m_ColumnToFocusKeyboard = columnIndex - 1;
         Event.current.Use();
         break;
     }
   }
   ListViewState state = listView;
   GUIStyle background = ColumnView.s_Styles.background;
   GUILayoutOption[] guiLayoutOptionArray = new GUILayoutOption[1]{ GUILayout.Width(this.columnWidth) };
   foreach (ListViewElement element in ListViewGUILayout.ListView(state, background, guiLayoutOptionArray))
   {
     ColumnViewElement columnViewElement = columnViewElements[element.row];
     if (element.row == listView.row && Event.current.type == EventType.Repaint)
     {
       Rect position = element.position;
       ++position.x;
       ++position.y;
       ColumnView.s_Styles.selected.Draw(position, false, true, true, GUIUtility.keyboardControl == listView.ID);
     }
     GUILayout.Label(columnViewElement.name);
     if (columnViewElement.value is List<ColumnViewElement>)
     {
       Rect position = element.position;
       position.x = (float) ((double) position.xMax - (double) ColumnView.s_Styles.categoryArrowIcon.width - 5.0);
       position.y += 2f;
       GUI.Label(position, (Texture) ColumnView.s_Styles.categoryArrowIcon);
     }
     this.DoDoubleClick(element, columnViewElement, selectedSearchItemFunction, selectedRegularItemFunction);
     ColumnView.DoDragAndDrop(listView, element, columnViewElements, getDataForDraggingFunction);
   }
   if (Event.current.type == EventType.Layout)
     selectedIndex = listView.row;
   return selectedIndex;
 }
Пример #5
0
 private static void DoPreviewColumn(object selectedObject, ColumnView.ObjectColumnFunction previewColumnFunction)
 {
   GUILayout.BeginVertical(ColumnView.s_Styles.background, new GUILayoutOption[0]);
   if (previewColumnFunction != null)
     previewColumnFunction(selectedObject);
   GUILayout.EndVertical();
 }
Пример #6
0
 private void DoSearchItemSelectedEvent(ColumnView.ObjectColumnFunction selectedSearchItemFunction, object value)
 {
   this.m_SearchText = string.Empty;
   ColumnView.DoItemSelectedEvent(selectedSearchItemFunction, value);
 }
Пример #7
0
 private static void DoItemSelectedEvent(ColumnView.ObjectColumnFunction selectedRegularItemFunction, object value)
 {
   if (selectedRegularItemFunction != null)
     selectedRegularItemFunction(value);
   Event.current.Use();
 }
Пример #8
0
        public void OnGUI(List <ColumnViewElement> elements, ColumnView.ObjectColumnFunction previewColumnFunction, ColumnView.ObjectColumnFunction selectedSearchItemFunction, ColumnView.ObjectColumnFunction selectedRegularItemFunction, ColumnView.ObjectColumnGetDataFunction getDataForDraggingFunction)
        {
            ColumnView.InitStyles();
            this.m_ScrollPosition = GUILayout.BeginScrollView(this.m_ScrollPosition);
            GUILayout.BeginHorizontal();
            List <ColumnViewElement> columnViewElements = elements;
            int    columnIndex = 0;
            object selectedObject;

            do
            {
                if (this.m_ListViewStates.Count == columnIndex)
                {
                    this.m_ListViewStates.Add(new ListViewState());
                }
                if (this.m_CachedSelectedIndices.Count == columnIndex)
                {
                    this.m_CachedSelectedIndices.Add(-1);
                }
                ListViewState listViewState = this.m_ListViewStates[columnIndex];
                listViewState.totalRows = columnViewElements.Count;
                if (columnIndex == 0)
                {
                    GUILayout.BeginVertical(GUILayout.MaxWidth(this.columnWidth));
                }
                int cachedSelectedIndex = this.m_CachedSelectedIndices[columnIndex];
                int index1 = this.DoListColumn(listViewState, columnViewElements, columnIndex, cachedSelectedIndex, columnIndex != 0 ? (ColumnView.ObjectColumnFunction)null : selectedSearchItemFunction, selectedRegularItemFunction, getDataForDraggingFunction);
                if (Event.current.type == EventType.Layout && this.m_ColumnToFocusKeyboard == columnIndex)
                {
                    this.m_ColumnToFocusKeyboard = -1;
                    GUIUtility.keyboardControl   = listViewState.ID;
                    if (listViewState.row == -1 && columnViewElements.Count != 0)
                    {
                        index1 = listViewState.row = 0;
                    }
                }
                if (columnIndex == 0)
                {
                    if (this.isSearching)
                    {
                        KeyCode keyCode = ColumnView.StealImportantListviewKeys();
                        if (keyCode != KeyCode.None)
                        {
                            ListViewShared.SendKey(this.m_ListViewStates[0], keyCode);
                        }
                    }
                    this.m_SearchText = EditorGUILayout.ToolbarSearchField(this.m_SearchText);
                    GUILayout.EndVertical();
                }
                if (index1 >= columnViewElements.Count)
                {
                    index1 = -1;
                }
                if (Event.current.type == EventType.Layout && this.m_CachedSelectedIndices[columnIndex] != index1 && this.m_ListViewStates.Count > columnIndex + 1)
                {
                    int index2 = columnIndex + 1;
                    int count  = this.m_ListViewStates.Count - (columnIndex + 1);
                    this.m_ListViewStates.RemoveRange(index2, count);
                    this.m_CachedSelectedIndices.RemoveRange(index2, count);
                }
                this.m_CachedSelectedIndices[columnIndex] = index1;
                selectedObject     = index1 <= -1 ? (object)null : columnViewElements[index1].value;
                columnViewElements = selectedObject as List <ColumnViewElement>;
                ++columnIndex;
            }while (columnViewElements != null);
            for (; columnIndex < this.minimumNumberOfColumns; ++columnIndex)
            {
                this.DoDummyColumn();
            }
            ColumnView.DoPreviewColumn(selectedObject, previewColumnFunction);
            GUILayout.EndHorizontal();
            GUILayout.EndScrollView();
        }
Пример #9
0
		private void DoDoubleClick(ListViewElement element, ColumnViewElement columnViewElement, ColumnView.ObjectColumnFunction selectedSearchItemFunction, ColumnView.ObjectColumnFunction selectedRegularItemFunction)
		{
			if (Event.current.type == EventType.MouseDown && element.position.Contains(Event.current.mousePosition) && Event.current.button == 0 && Event.current.clickCount == 2)
			{
				if (this.isSearching)
				{
					this.DoSearchItemSelectedEvent(selectedSearchItemFunction, columnViewElement.value);
				}
				else
				{
					ColumnView.DoItemSelectedEvent(selectedRegularItemFunction, columnViewElement.value);
				}
			}
		}
Пример #10
0
		private static void DoDragAndDrop(ListViewState listView, ListViewElement element, List<ColumnViewElement> columnViewElements, ColumnView.ObjectColumnGetDataFunction getDataForDraggingFunction)
		{
			if (GUIUtility.hotControl == listView.ID && Event.current.type == EventType.MouseDown && element.position.Contains(Event.current.mousePosition) && Event.current.button == 0)
			{
				DragAndDropDelay dragAndDropDelay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), listView.ID);
				dragAndDropDelay.mouseDownPosition = Event.current.mousePosition;
			}
			if (GUIUtility.hotControl == listView.ID && Event.current.type == EventType.MouseDrag && GUIClip.visibleRect.Contains(Event.current.mousePosition))
			{
				DragAndDropDelay dragAndDropDelay2 = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), listView.ID);
				if (dragAndDropDelay2.CanStartDrag())
				{
					object obj = (getDataForDraggingFunction != null) ? getDataForDraggingFunction(columnViewElements[listView.row].value) : null;
					if (obj == null)
					{
						return;
					}
					DragAndDrop.PrepareStartDrag();
					DragAndDrop.objectReferences = new UnityEngine.Object[0];
					DragAndDrop.paths = null;
					DragAndDrop.SetGenericData("CustomDragData", obj);
					DragAndDrop.StartDrag(columnViewElements[listView.row].name);
					Event.current.Use();
				}
			}
		}
Пример #11
0
		private int DoListColumn(ListViewState listView, List<ColumnViewElement> columnViewElements, int columnIndex, int selectedIndex, ColumnView.ObjectColumnFunction selectedSearchItemFunction, ColumnView.ObjectColumnFunction selectedRegularItemFunction, ColumnView.ObjectColumnGetDataFunction getDataForDraggingFunction)
		{
			if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return && listView.row > -1)
			{
				if (this.isSearching && selectedSearchItemFunction != null)
				{
					this.DoSearchItemSelectedEvent(selectedSearchItemFunction, columnViewElements[selectedIndex].value);
				}
				if (!this.isSearching && GUIUtility.keyboardControl == listView.ID && selectedRegularItemFunction != null)
				{
					ColumnView.DoItemSelectedEvent(selectedRegularItemFunction, columnViewElements[selectedIndex].value);
				}
			}
			if (GUIUtility.keyboardControl == listView.ID && Event.current.type == EventType.KeyDown && !this.isSearching)
			{
				KeyCode keyCode = Event.current.keyCode;
				if (keyCode != KeyCode.RightArrow)
				{
					if (keyCode == KeyCode.LeftArrow)
					{
						this.m_ColumnToFocusKeyboard = columnIndex - 1;
						Event.current.Use();
					}
				}
				else
				{
					this.m_ColumnToFocusKeyboard = columnIndex + 1;
					Event.current.Use();
				}
			}
			foreach (ListViewElement element in ListViewGUILayout.ListView(listView, ColumnView.s_Styles.background, new GUILayoutOption[]
			{
				GUILayout.Width(this.columnWidth)
			}))
			{
				ColumnViewElement columnViewElement = columnViewElements[element.row];
				if (element.row == listView.row && Event.current.type == EventType.Repaint)
				{
					Rect position = element.position;
					position.x += 1f;
					position.y += 1f;
					ColumnView.s_Styles.selected.Draw(position, false, true, true, GUIUtility.keyboardControl == listView.ID);
				}
				GUILayout.Label(columnViewElement.name, new GUILayoutOption[0]);
				if (columnViewElement.value is List<ColumnViewElement>)
				{
					Rect position2 = element.position;
					position2.x = position2.xMax - (float)ColumnView.s_Styles.categoryArrowIcon.width - 5f;
					position2.y += 2f;
					GUI.Label(position2, ColumnView.s_Styles.categoryArrowIcon);
				}
				this.DoDoubleClick(element, columnViewElement, selectedSearchItemFunction, selectedRegularItemFunction);
				ColumnView.DoDragAndDrop(listView, element, columnViewElements, getDataForDraggingFunction);
			}
			if (Event.current.type == EventType.Layout)
			{
				selectedIndex = listView.row;
			}
			return selectedIndex;
		}
Пример #12
0
        public void OnGUI(List <ColumnViewElement> elements, ColumnView.ObjectColumnFunction previewColumnFunction, ColumnView.ObjectColumnFunction selectedSearchItemFunction, ColumnView.ObjectColumnFunction selectedRegularItemFunction, ColumnView.ObjectColumnGetDataFunction getDataForDraggingFunction)
        {
            ColumnView.InitStyles();
            this.m_ScrollPosition = GUILayout.BeginScrollView(this.m_ScrollPosition, new GUILayoutOption[0]);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            List <ColumnViewElement> list = elements;
            int    i = 0;
            object obj;

            do
            {
                if (this.m_ListViewStates.Count == i)
                {
                    this.m_ListViewStates.Add(new ListViewState());
                }
                if (this.m_CachedSelectedIndices.Count == i)
                {
                    this.m_CachedSelectedIndices.Add(-1);
                }
                ListViewState listViewState = this.m_ListViewStates[i];
                listViewState.totalRows = list.Count;
                if (i == 0)
                {
                    GUILayout.BeginVertical(new GUILayoutOption[]
                    {
                        GUILayout.MaxWidth(this.columnWidth)
                    });
                }
                int num = this.m_CachedSelectedIndices[i];
                num = this.DoListColumn(listViewState, list, i, num, (i != 0) ? null : selectedSearchItemFunction, selectedRegularItemFunction, getDataForDraggingFunction);
                if (Event.current.type == EventType.Layout && this.m_ColumnToFocusKeyboard == i)
                {
                    this.m_ColumnToFocusKeyboard = -1;
                    GUIUtility.keyboardControl   = listViewState.ID;
                    if (listViewState.row == -1 && list.Count != 0)
                    {
                        num = (listViewState.row = 0);
                    }
                }
                if (i == 0)
                {
                    if (this.isSearching)
                    {
                        KeyCode keyCode = ColumnView.StealImportantListviewKeys();
                        if (keyCode != KeyCode.None)
                        {
                            ListViewShared.SendKey(this.m_ListViewStates[0], keyCode);
                        }
                    }
                    this.m_SearchText = EditorGUILayout.ToolbarSearchField(this.m_SearchText, new GUILayoutOption[0]);
                    GUILayout.EndVertical();
                }
                if (num >= list.Count)
                {
                    num = -1;
                }
                if (Event.current.type == EventType.Layout && this.m_CachedSelectedIndices[i] != num && this.m_ListViewStates.Count > i + 1)
                {
                    int index = i + 1;
                    int count = this.m_ListViewStates.Count - (i + 1);
                    this.m_ListViewStates.RemoveRange(index, count);
                    this.m_CachedSelectedIndices.RemoveRange(index, count);
                }
                this.m_CachedSelectedIndices[i] = num;
                obj  = ((num <= -1) ? null : list[num].value);
                list = (obj as List <ColumnViewElement>);
                i++;
            }while (list != null);
            while (i < this.minimumNumberOfColumns)
            {
                this.DoDummyColumn();
                i++;
            }
            ColumnView.DoPreviewColumn(obj, previewColumnFunction);
            GUILayout.EndHorizontal();
            GUILayout.EndScrollView();
        }
Пример #13
0
 private void DoSearchItemSelectedEvent(ColumnView.ObjectColumnFunction selectedSearchItemFunction, object value)
 {
     this.m_SearchText = string.Empty;
     ColumnView.DoItemSelectedEvent(selectedSearchItemFunction, value);
 }
Пример #14
0
        private int DoListColumn(ListViewState listView, List <ColumnViewElement> columnViewElements, int columnIndex, int selectedIndex, ColumnView.ObjectColumnFunction selectedSearchItemFunction, ColumnView.ObjectColumnFunction selectedRegularItemFunction, ColumnView.ObjectColumnGetDataFunction getDataForDraggingFunction)
        {
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return && listView.row > -1)
            {
                if (this.isSearching && selectedSearchItemFunction != null)
                {
                    this.DoSearchItemSelectedEvent(selectedSearchItemFunction, columnViewElements[selectedIndex].value);
                }
                if (!this.isSearching && GUIUtility.keyboardControl == listView.ID && selectedRegularItemFunction != null)
                {
                    ColumnView.DoItemSelectedEvent(selectedRegularItemFunction, columnViewElements[selectedIndex].value);
                }
            }
            if (GUIUtility.keyboardControl == listView.ID && Event.current.type == EventType.KeyDown && !this.isSearching)
            {
                KeyCode keyCode = Event.current.keyCode;
                if (keyCode != KeyCode.LeftArrow)
                {
                    if (keyCode == KeyCode.RightArrow)
                    {
                        this.m_ColumnToFocusKeyboard = columnIndex + 1;
                        Event.current.Use();
                    }
                }
                else
                {
                    this.m_ColumnToFocusKeyboard = columnIndex - 1;
                    Event.current.Use();
                }
            }
            IEnumerator enumerator = ListViewGUILayout.ListView(listView, ColumnView.s_Styles.background, new GUILayoutOption[]
            {
                GUILayout.Width(this.columnWidth)
            }).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    ListViewElement   element           = (ListViewElement)enumerator.Current;
                    ColumnViewElement columnViewElement = columnViewElements[element.row];
                    if (element.row == listView.row)
                    {
                        if (Event.current.type == EventType.Repaint)
                        {
                            Rect position = element.position;
                            position.x += 1f;
                            position.y += 1f;
                            ColumnView.s_Styles.selected.Draw(position, false, true, true, GUIUtility.keyboardControl == listView.ID);
                        }
                    }
                    GUILayout.Label(columnViewElement.name, new GUILayoutOption[0]);
                    if (columnViewElement.value is List <ColumnViewElement> )
                    {
                        Rect position2 = element.position;
                        position2.x  = position2.xMax - (float)ColumnView.s_Styles.categoryArrowIcon.width - 5f;
                        position2.y += 2f;
                        GUI.Label(position2, ColumnView.s_Styles.categoryArrowIcon);
                    }
                    this.DoDoubleClick(element, columnViewElement, selectedSearchItemFunction, selectedRegularItemFunction);
                    ColumnView.DoDragAndDrop(listView, element, columnViewElements, getDataForDraggingFunction);
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
            if (Event.current.type == EventType.Layout)
            {
                selectedIndex = listView.row;
            }
            return(selectedIndex);
        }
Пример #15
0
 public void OnGUI(List<ColumnViewElement> elements, ColumnView.ObjectColumnFunction previewColumnFunction)
 {
   this.OnGUI(elements, previewColumnFunction, (ColumnView.ObjectColumnFunction) null, (ColumnView.ObjectColumnFunction) null, (ColumnView.ObjectColumnGetDataFunction) null);
 }
Пример #16
0
		public void OnGUI(List<ColumnViewElement> elements, ColumnView.ObjectColumnFunction previewColumnFunction, ColumnView.ObjectColumnFunction selectedSearchItemFunction, ColumnView.ObjectColumnFunction selectedRegularItemFunction, ColumnView.ObjectColumnGetDataFunction getDataForDraggingFunction)
		{
			ColumnView.InitStyles();
			this.m_ScrollPosition = GUILayout.BeginScrollView(this.m_ScrollPosition, new GUILayoutOption[0]);
			GUILayout.BeginHorizontal(new GUILayoutOption[0]);
			List<ColumnViewElement> list = elements;
			int i = 0;
			object obj;
			do
			{
				if (this.m_ListViewStates.Count == i)
				{
					this.m_ListViewStates.Add(new ListViewState());
				}
				if (this.m_CachedSelectedIndices.Count == i)
				{
					this.m_CachedSelectedIndices.Add(-1);
				}
				ListViewState listViewState = this.m_ListViewStates[i];
				listViewState.totalRows = list.Count;
				if (i == 0)
				{
					GUILayout.BeginVertical(new GUILayoutOption[]
					{
						GUILayout.MaxWidth(this.columnWidth)
					});
				}
				int num = this.m_CachedSelectedIndices[i];
				num = this.DoListColumn(listViewState, list, i, num, (i != 0) ? null : selectedSearchItemFunction, selectedRegularItemFunction, getDataForDraggingFunction);
				if (Event.current.type == EventType.Layout && this.m_ColumnToFocusKeyboard == i)
				{
					this.m_ColumnToFocusKeyboard = -1;
					GUIUtility.keyboardControl = listViewState.ID;
					if (listViewState.row == -1 && list.Count != 0)
					{
						num = (listViewState.row = 0);
					}
				}
				if (i == 0)
				{
					if (this.isSearching)
					{
						KeyCode keyCode = ColumnView.StealImportantListviewKeys();
						if (keyCode != KeyCode.None)
						{
							ListViewShared.SendKey(this.m_ListViewStates[0], keyCode);
						}
					}
					this.m_SearchText = EditorGUILayout.ToolbarSearchField(this.m_SearchText, new GUILayoutOption[0]);
					GUILayout.EndVertical();
				}
				if (num >= list.Count)
				{
					num = -1;
				}
				if (Event.current.type == EventType.Layout && this.m_CachedSelectedIndices[i] != num && this.m_ListViewStates.Count > i + 1)
				{
					int index = i + 1;
					int count = this.m_ListViewStates.Count - (i + 1);
					this.m_ListViewStates.RemoveRange(index, count);
					this.m_CachedSelectedIndices.RemoveRange(index, count);
				}
				this.m_CachedSelectedIndices[i] = num;
				obj = ((num <= -1) ? null : list[num].value);
				list = (obj as List<ColumnViewElement>);
				i++;
			}
			while (list != null);
			while (i < this.minimumNumberOfColumns)
			{
				this.DoDummyColumn();
				i++;
			}
			ColumnView.DoPreviewColumn(obj, previewColumnFunction);
			GUILayout.EndHorizontal();
			GUILayout.EndScrollView();
		}
Пример #17
0
        private int DoListColumn(ListViewState listView, List <ColumnViewElement> columnViewElements, int columnIndex, int selectedIndex, ColumnView.ObjectColumnFunction selectedSearchItemFunction, ColumnView.ObjectColumnFunction selectedRegularItemFunction, ColumnView.ObjectColumnGetDataFunction getDataForDraggingFunction)
        {
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return && listView.row > -1)
            {
                if (this.isSearching && selectedSearchItemFunction != null)
                {
                    this.DoSearchItemSelectedEvent(selectedSearchItemFunction, columnViewElements[selectedIndex].value);
                }
                if (!this.isSearching && GUIUtility.keyboardControl == listView.ID && selectedRegularItemFunction != null)
                {
                    ColumnView.DoItemSelectedEvent(selectedRegularItemFunction, columnViewElements[selectedIndex].value);
                }
            }
            if (GUIUtility.keyboardControl == listView.ID && Event.current.type == EventType.KeyDown && !this.isSearching)
            {
                switch (Event.current.keyCode)
                {
                case KeyCode.RightArrow:
                    this.m_ColumnToFocusKeyboard = columnIndex + 1;
                    Event.current.Use();
                    break;

                case KeyCode.LeftArrow:
                    this.m_ColumnToFocusKeyboard = columnIndex - 1;
                    Event.current.Use();
                    break;
                }
            }
            ListViewState state      = listView;
            GUIStyle      background = ColumnView.s_Styles.background;

            GUILayoutOption[] guiLayoutOptionArray = new GUILayoutOption[1] {
                GUILayout.Width(this.columnWidth)
            };
            foreach (ListViewElement element in ListViewGUILayout.ListView(state, background, guiLayoutOptionArray))
            {
                ColumnViewElement columnViewElement = columnViewElements[element.row];
                if (element.row == listView.row && Event.current.type == EventType.Repaint)
                {
                    Rect position = element.position;
                    ++position.x;
                    ++position.y;
                    ColumnView.s_Styles.selected.Draw(position, false, true, true, GUIUtility.keyboardControl == listView.ID);
                }
                GUILayout.Label(columnViewElement.name);
                if (columnViewElement.value is List <ColumnViewElement> )
                {
                    Rect position = element.position;
                    position.x  = (float)((double)position.xMax - (double)ColumnView.s_Styles.categoryArrowIcon.width - 5.0);
                    position.y += 2f;
                    GUI.Label(position, (Texture)ColumnView.s_Styles.categoryArrowIcon);
                }
                this.DoDoubleClick(element, columnViewElement, selectedSearchItemFunction, selectedRegularItemFunction);
                ColumnView.DoDragAndDrop(listView, element, columnViewElements, getDataForDraggingFunction);
            }
            if (Event.current.type == EventType.Layout)
            {
                selectedIndex = listView.row;
            }
            return(selectedIndex);
        }