private ItemRow RequestRow(int itemIndex) { ItemRow row = null; if (m_poolRows.Count > 0) { object item = m_itemContainer.GetItem(itemIndex); for (int i = 0; i < m_poolRows.Count; i++) { if (item == m_poolRows[i].item) { row = m_poolRows[i]; m_poolRows.RemoveAt(i); break; } } if (row == null) { row = PopEndRow(m_poolRows); } } else { row = m_funcCreateRow(); } if (row != null) { SetRow(row, itemIndex); } return(row); }
public static ItemRow Create(Transform itemParent, GameObject itemPrefab) { ItemRow row = new ItemRow(); GameObject go = GameObject.Instantiate(itemPrefab) as GameObject; row.rect = go.GetComponent(typeof(RectTransform)) as RectTransform; row.drawer = go.GetComponent(typeof(ItemDrawer)) as ItemDrawer; go.transform.SetParent(itemParent, false); return(row); }
public override void SetLayoutVertical() { int visibleRowCount = m_rowContainer.VisibleRowCount; float rowHeight = GetRowHeight(); float size = GetItemHeight(); for (int i = 0; i < visibleRowCount; i++) { ItemRow row = m_rowContainer.GetVisibleRow(i); float pos = rowHeight * row.itemIndex + padding.top; SetChildAlongAxis(row.rect, 1, pos, size); } }
private static ItemRow PopEndRow(List <ItemRow> rows) { if (rows == null || rows.Count == 0) { return(null); } int index = rows.Count - 1; ItemRow row = rows[index]; rows.RemoveAt(index); return(row); }
private float GetItemHeight() { if (m_itemHeight > 0) { return(m_itemHeight); } m_itemHeight = ItemRow.GetItemHeight(itemPrefab); if (m_itemHeight < 1) { m_itemHeight = 20; } return(m_itemHeight); }
// Invisible items which are in range should be visible. public bool ProcessInvisibleItemsInRange(int beginItemIndex, int endItemIndex) { bool hasOccurred = false; for (int i = beginItemIndex; i < endItemIndex; i++) { if (!IsVisibleItem(i)) { ItemRow row = RequestRow(i); m_visibleRows.Add(row); hasOccurred |= true; } } return(hasOccurred); }
// Visible items which are not in range should be invisible. public bool ProcessVisibleItemsNotInRange(int beginItemIndex, int endItemIndex) { bool hasOccurred = false; for (int i = m_visibleRows.Count - 1; i >= 0; i--) { ItemRow row = m_visibleRows[i]; if ((row.itemIndex < beginItemIndex) || (row.itemIndex >= endItemIndex)) { m_poolRows.Add(row); m_visibleRows.RemoveAt(i); hasOccurred |= true; } } return(hasOccurred); }
private void SetRow(ItemRow row, int itemIndex) { row.itemIndex = itemIndex; row.item = m_itemContainer.GetItem(itemIndex); bool isOddRow = (itemIndex % 2 != 0) ? true : false; bool isSelected = false; object curSelectedItem = m_itemContainer.GetCurSelectedItem(); if ((curSelectedItem != null) && (row.item == curSelectedItem)) { isSelected = true; } row.drawer.Draw(row.item, isOddRow, isSelected); }
private ItemRow CreateRow() { ItemRow row = ItemRow.Create(rectTransform, itemPrefab); return(row); }