public static Vector2 SlickViewScrollToRow(InternalSlickViewState ilvState, Vector2 currPos, int row) { if (ilvState.invisibleRows < row && ilvState.endRow > row) { return(currPos); } if (row <= ilvState.invisibleRows) { currPos.y = ilvState.state.rowHeight * row; } else { currPos.y = ilvState.state.rowHeight * (row + 1) - ilvState.rectHeight; } if (currPos.y < 0) { currPos.y = 0; } else if (currPos.y > ilvState.state.totalRows * ilvState.state.rowHeight - ilvState.rectHeight) { currPos.y = ilvState.state.totalRows * ilvState.state.rowHeight - ilvState.rectHeight; } return(currPos); }
public SlickViewElementsEnumerator(InternalSlickViewState ilvState, int yFrom, int yTo, string dragTitle, Rect firstRect) { xTo = 0; this.yFrom = yFrom; this.yTo = yTo; this.firstRect = firstRect; rect = firstRect; quiting = ilvState.state.totalRows == 0; this.ilvState = ilvState; Reset(); }
private static bool DoLVPageUpDown(InternalSlickViewState ilvState, ref int selectedRow, ref Vector2 scrollPos, bool up) { var visibleRows = ilvState.endRow - ilvState.invisibleRows; if (up) { if (OSX) { scrollPos.y -= ilvState.state.rowHeight * visibleRows; if (scrollPos.y < 0) { scrollPos.y = 0; } } else { selectedRow -= visibleRows; if (selectedRow < 0) { selectedRow = 0; } return(true); } } else { if (OSX) { scrollPos.y += ilvState.state.rowHeight * visibleRows; //FIXME: does this need an upper bound check? } else { selectedRow += visibleRows; if (selectedRow >= ilvState.state.totalRows) { selectedRow = ilvState.state.totalRows - 1; } return(true); } } return(false); }
public static bool HasMouseDown(InternalSlickViewState ilvState, Rect r, int button) { if (Event.current.type == EventType.MouseDown && Event.current.button == button) { if (r.Contains(Event.current.mousePosition)) { GUIUtility.hotControl = ilvState.state.ID; GUIUtility.keyboardControl = ilvState.state.ID; Event.current.Use(); return(true); } } return(false); }
public static Vector2 SlickViewScrollToRow(InternalSlickViewState ilvState, int row) { return(SlickViewScrollToRow(ilvState, ilvState.state.scrollPos, row)); }
public static bool SendKey(InternalSlickViewState ilvState, KeyCode keyCode, int totalCols) { var state = ilvState.state; var previousRow = state.row; //ilvState.state.row, ref ilvState.state.column, ref ilvState.state.scrollPos switch (keyCode) { case KeyCode.UpArrow: { if (state.row > 0) { state.row--; } // If nothing is selected, upArrow selects the 1st element else if (state.row == -1) { state.row = 0; } break; } case KeyCode.DownArrow: { if (state.row < state.totalRows - 1) { state.row++; } break; } case KeyCode.Home: { state.row = 0; break; } case KeyCode.End: { state.row = state.totalRows - 1; break; } case KeyCode.LeftArrow: if (state.column > 0) { state.column--; } break; case KeyCode.RightArrow: if (state.column < totalCols - 1) { state.column++; } break; case KeyCode.PageUp: { if (!DoLVPageUpDown(ilvState, ref state.row, ref state.scrollPos, true)) { Event.current.Use(); return(false); } break; } case KeyCode.PageDown: { if (!DoLVPageUpDown(ilvState, ref state.row, ref state.scrollPos, false)) { Event.current.Use(); return(false); } break; } case KeyCode.A: // must evade the return false and be handled by MultiSelection if needed break; default: return(false); } state.scrollPos = SlickViewScrollToRow(ilvState, state.scrollPos, state.row); Event.current.Use(); return(true); }
public static bool HasMouseDown(InternalSlickViewState ilvState, Rect r) { return(HasMouseDown(ilvState, r, 0)); }