DoDragAndDrop() private static method

private static DoDragAndDrop ( ListViewState listView, ListViewElement element, List columnViewElements, ObjectColumnGetDataFunction getDataForDraggingFunction ) : void
listView ListViewState
element ListViewElement
columnViewElements List
getDataForDraggingFunction ObjectColumnGetDataFunction
return void
Example #1
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);
 }
Example #2
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);
        }