Ejemplo n.º 1
0
        private static bool DoLVPageUpDown(ListViewShared.InternalListViewState ilvState, ref int selectedRow, ref Vector2 scrollPos, bool up)
        {
            int num = ilvState.endRow - ilvState.invisibleRows;

            if (up)
            {
                if (!ListViewShared.OSX)
                {
                    selectedRow -= num;
                    if (selectedRow < 0)
                    {
                        selectedRow = 0;
                    }
                    return(true);
                }
                scrollPos.y -= (float)(ilvState.state.rowHeight * num);
                if (scrollPos.y < 0f)
                {
                    scrollPos.y = 0f;
                }
            }
            else
            {
                if (!ListViewShared.OSX)
                {
                    selectedRow += num;
                    if (selectedRow >= ilvState.state.totalRows)
                    {
                        selectedRow = ilvState.state.totalRows - 1;
                    }
                    return(true);
                }
                scrollPos.y += (float)(ilvState.state.rowHeight * num);
            }
            return(false);
        }
Ejemplo n.º 2
0
 internal static int ListViewScrollToRow(ListViewShared.InternalListViewState ilvState, int currPosY, int row)
 {
     return((int)ListViewShared.ListViewScrollToRow(ilvState, new Vector2(0f, (float)currPosY), row).y);
 }
Ejemplo n.º 3
0
 internal static Vector2 ListViewScrollToRow(ListViewShared.InternalListViewState ilvState, int row)
 {
     return(ListViewShared.ListViewScrollToRow(ilvState, ilvState.state.scrollPos, row));
 }
Ejemplo n.º 4
0
        internal static bool MultiSelection(ListViewShared.InternalListViewState ilvState, int prevSelected, int currSelected, ref int initialSelected, ref bool[] selectedItems)
        {
            bool shift     = Event.current.shift;
            bool actionKey = EditorGUI.actionKey;
            bool result    = false;

            if ((shift || actionKey) && initialSelected == -1)
            {
                initialSelected = prevSelected;
            }
            if (shift)
            {
                int num  = Math.Min(initialSelected, currSelected);
                int num2 = Math.Max(initialSelected, currSelected);
                if (!actionKey)
                {
                    for (int i = 0; i < num; i++)
                    {
                        if (selectedItems[i])
                        {
                            result = true;
                        }
                        selectedItems[i] = false;
                    }
                    for (int j = num2 + 1; j < selectedItems.Length; j++)
                    {
                        if (selectedItems[j])
                        {
                            result = true;
                        }
                        selectedItems[j] = false;
                    }
                }
                if (num < 0)
                {
                    num = num2;
                }
                for (int k = num; k <= num2; k++)
                {
                    if (!selectedItems[k])
                    {
                        result = true;
                    }
                    selectedItems[k] = true;
                }
            }
            else
            {
                if (actionKey)
                {
                    selectedItems[currSelected] = !selectedItems[currSelected];
                    initialSelected             = currSelected;
                    result = true;
                }
                else
                {
                    if (!selectedItems[currSelected])
                    {
                        result = true;
                    }
                    for (int l = 0; l < selectedItems.Length; l++)
                    {
                        if (selectedItems[l] && currSelected != l)
                        {
                            result = true;
                        }
                        selectedItems[l] = false;
                    }
                    initialSelected             = -1;
                    selectedItems[currSelected] = true;
                }
            }
            if (ilvState != null)
            {
                ilvState.state.scrollPos = ListViewShared.ListViewScrollToRow(ilvState, currSelected);
            }
            return(result);
        }
Ejemplo n.º 5
0
 internal static bool HasMouseUp(ListViewShared.InternalListViewState ilvState, Rect r)
 {
     return(ListViewShared.HasMouseUp(ilvState, r, 0));
 }
Ejemplo n.º 6
0
        internal static bool SendKey(ListViewShared.InternalListViewState ilvState, KeyCode keyCode, int totalCols)
        {
            ListViewState state = ilvState.state;

            switch (keyCode)
            {
            case KeyCode.UpArrow:
                if (state.row > 0)
                {
                    state.row--;
                }
                goto IL_136;

            case KeyCode.DownArrow:
                if (state.row < state.totalRows - 1)
                {
                    state.row++;
                }
                goto IL_136;

            case KeyCode.RightArrow:
                if (state.column < totalCols - 1)
                {
                    state.column++;
                }
                goto IL_136;

            case KeyCode.LeftArrow:
                if (state.column > 0)
                {
                    state.column--;
                }
                goto IL_136;

            case KeyCode.Home:
                state.row = 0;
                goto IL_136;

            case KeyCode.End:
                state.row = state.totalRows - 1;
                goto IL_136;

            case KeyCode.PageUp:
                if (!ListViewShared.DoLVPageUpDown(ilvState, ref state.row, ref state.scrollPos, true))
                {
                    Event.current.Use();
                    return(false);
                }
                goto IL_136;

            case KeyCode.PageDown:
                if (!ListViewShared.DoLVPageUpDown(ilvState, ref state.row, ref state.scrollPos, false))
                {
                    Event.current.Use();
                    return(false);
                }
                goto IL_136;
            }
            return(false);

IL_136:
            state.scrollPos = ListViewShared.ListViewScrollToRow(ilvState, state.scrollPos, state.row);
            Event.current.Use();
            return(true);
        }
Ejemplo n.º 7
0
        internal static bool ListViewKeyboard(ListViewShared.InternalListViewState ilvState, int totalCols)
        {
            int totalRows = ilvState.state.totalRows;

            return(Event.current.type == EventType.KeyDown && totalRows != 0 && GUIUtility.keyboardControl == ilvState.state.ID && Event.current.GetTypeForControl(ilvState.state.ID) == EventType.KeyDown && ListViewShared.SendKey(ilvState, Event.current.keyCode, totalCols));
        }