Example #1
0
 public void OnBeginDrag(PointerEventData evt)
 {
     //IL_0007: Unknown result type (might be due to invalid IL or missing references)
     //IL_003f: Unknown result type (might be due to invalid IL or missing references)
     if (RectTransformUtility.RectangleContainsScreenPoint(m_rectTransform, evt.get_position(), evt.get_pressEventCamera()))
     {
         foreach (KeyValuePair <int, CellRenderer> item in m_elementsByItem)
         {
             CellRenderer value = item.Value;
             if (RectTransformUtility.RectangleContainsScreenPoint(value.rectTransform, evt.get_position(), evt.get_pressEventCamera()))
             {
                 if (m_items.IndexOf(value.value) != -1)
                 {
                     ItemDragNDropListener.instance.OnBeginDrag(evt, value);
                 }
                 break;
             }
         }
     }
 }
Example #2
0
        protected CellRenderer GetFromPool()
        {
            //IL_002e: Unknown result type (might be due to invalid IL or missing references)
            //IL_0033: Unknown result type (might be due to invalid IL or missing references)
            if (m_elementPool.Count == 0)
            {
                CellRenderer  cellRenderer = Object.Instantiate <CellRenderer>(m_cellRenderer);
                RectTransform component    = cellRenderer.GetComponent <RectTransform>();
                component.SetParent(this.get_transform(), false);
                component.set_sizeDelta(Vector2Int.op_Implicit(m_cellSize));
                SetCellRectTransformAnchors(component);
                cellRenderer.dragNDropClient = this;
                return(cellRenderer);
            }
            CellRenderer cellRenderer2 = m_elementPool[m_elementPool.Count - 1];

            m_elementPool.RemoveAt(m_elementPool.Count - 1);
            cellRenderer2.get_gameObject().SetActive(true);
            return(cellRenderer2);
        }
Example #3
0
 public bool OnDrop(CellRenderer cellRenderer, PointerEventData evt)
 {
     if (!m_enableDragAndDrop)
     {
         return(true);
     }
     if (m_dragNDropValidator != null && !m_dragNDropValidator.IsValidDrop(m_value))
     {
         return(true);
     }
     if (m_insertOnDrop)
     {
         if (Object.op_Implicit(m_cellRendererInstance.get_gameObject()))
         {
             Object.Destroy(m_cellRendererInstance.get_gameObject());
         }
         m_cellRendererInstance = cellRenderer;
         ConfigureCellRenderer(cellRenderer, instant: false, andUpdate: true);
         SetValue(cellRenderer.value);
         return(false);
     }
     return(true);
 }
Example #4
0
        private void Update()
        {
            //IL_02bf: Unknown result type (might be due to invalid IL or missing references)
            //IL_0368: Unknown result type (might be due to invalid IL or missing references)
            int num  = ToIndex(base.scrollPercentage);
            int num2 = Mathf.Clamp(num, 0, m_items.Count);
            int num3 = num + m_rows * m_columns - 1;

            if (m_needFullReLayout)
            {
                foreach (KeyValuePair <int, CellRenderer> item in m_elementsByItem)
                {
                    ReturnToPool(item.Value);
                }
                m_elementsByItem.Clear();
                for (int i = num2; i <= num3; i++)
                {
                    object       value    = (i < m_items.Count) ? m_items[i] : null;
                    CellRenderer fromPool = GetFromPool();
                    m_elementsByItem[i] = fromPool;
                    fromPool.SetValue(value);
                }
                m_needFullReLayout = false;
            }
            else
            {
                for (int j = m_previousFirstCellIndex; j < Math.Min(num2, m_previousLastCellIndex + 1); j++)
                {
                    if (m_elementsByItem.TryGetValue(j, out CellRenderer value2))
                    {
                        ReturnToPool(value2);
                        m_elementsByItem.Remove(j);
                    }
                }
                for (int num4 = m_previousLastCellIndex; num4 > Math.Max(num3, m_previousFirstCellIndex - 1); num4--)
                {
                    if (m_elementsByItem.TryGetValue(num4, out CellRenderer value3))
                    {
                        ReturnToPool(value3);
                        m_elementsByItem.Remove(num4);
                    }
                }
                for (int k = num2; k < Math.Min(m_previousFirstCellIndex, num3 + 1); k++)
                {
                    object       value4    = (k < m_items.Count) ? m_items[k] : null;
                    CellRenderer fromPool2 = GetFromPool();
                    m_elementsByItem[k] = fromPool2;
                    fromPool2.SetValue(value4);
                }
                for (int l = Math.Max(num2, m_previousLastCellIndex + 1); l <= num3; l++)
                {
                    object       value5    = (l < m_items.Count) ? m_items[l] : null;
                    CellRenderer fromPool3 = GetFromPool();
                    m_elementsByItem[l] = fromPool3;
                    fromPool3.SetValue(value5);
                }
            }
            float num5 = ToRowIndex(base.scrollPercentage);

            if (m_horizontal)
            {
                float num6 = num5 * (float)m_cellSize.get_x() % (float)m_cellSize.get_x();
                int   num7 = num2;
                for (int m = 0; m < m_columns; m++)
                {
                    float num8 = (float)(m_cellSize.get_x() * m) - num6;
                    for (int n = 0; n < m_rows; n++)
                    {
                        int num9 = m_totalHeight - m_cellSize.get_y() * (n + 1);
                        if (m_elementsByItem.TryGetValue(num7++, out CellRenderer value6))
                        {
                            value6.GetComponent <RectTransform>().set_anchoredPosition(new Vector2(num8, (float)num9));
                        }
                    }
                }
            }
            else
            {
                float num11 = num5 * (float)m_cellSize.get_y() % (float)m_cellSize.get_y();
                int   num12 = num2;
                for (int num13 = 0; num13 < m_rows; num13++)
                {
                    float num14 = (float)m_totalHeight - ((float)(m_cellSize.get_y() * (num13 + 1)) - num11);
                    for (int num15 = 0; num15 < m_columns; num15++)
                    {
                        int num16 = m_cellSize.get_x() * num15;
                        if (m_elementsByItem.TryGetValue(num12++, out CellRenderer value7))
                        {
                            value7.GetComponent <RectTransform>().set_anchoredPosition(new Vector2((float)num16, num14));
                        }
                    }
                }
            }
            m_previousFirstCellIndex = num2;
            m_previousLastCellIndex  = num3;
        }
Example #5
0
        public bool OnDropOut(CellRenderer cellRenderer, PointerEventData evt)
        {
            bool enableDragAndDrop = m_enableDragAndDrop;

            return(true);
        }
Example #6
0
 public void OnDragOver(CellRenderer cellRenderer, PointerEventData evt)
 {
 }
Example #7
0
        private void Update()
        {
            //IL_02ca: Unknown result type (might be due to invalid IL or missing references)
            //IL_035d: Unknown result type (might be due to invalid IL or missing references)
            int num  = ToIndex(base.scrollPercentage, normalize: false) - m_rows / 2;
            int num2 = num + m_rows;

            if (m_needFullReLayout)
            {
                foreach (KeyValuePair <int, CellRenderer> item in m_elementsByItem)
                {
                    ReturnToPool(item.Value);
                }
                m_elementsByItem.Clear();
                for (int i = num; i <= num2; i++)
                {
                    int          num3     = NormalizeItemIndex(i, m_items.Count);
                    object       value    = (num3 >= 0) ? m_items[num3] : null;
                    CellRenderer fromPool = GetFromPool();
                    m_elementsByItem[i] = fromPool;
                    fromPool.SetValue(value);
                }
                m_needFullReLayout = false;
            }
            else
            {
                for (int j = m_previousFirstCellIndex; j < Math.Min(num, m_previousLastCellIndex + 1); j++)
                {
                    if (m_elementsByItem.TryGetValue(j, out CellRenderer value2))
                    {
                        ReturnToPool(value2);
                        m_elementsByItem.Remove(j);
                    }
                }
                for (int num4 = m_previousLastCellIndex; num4 > Math.Max(num2, m_previousFirstCellIndex - 1); num4--)
                {
                    if (m_elementsByItem.TryGetValue(num4, out CellRenderer value3))
                    {
                        ReturnToPool(value3);
                        m_elementsByItem.Remove(num4);
                    }
                }
                for (int k = num; k < Math.Min(m_previousFirstCellIndex, num2 + 1); k++)
                {
                    int          num5      = NormalizeItemIndex(k, m_items.Count);
                    object       value4    = (num5 >= 0) ? m_items[num5] : null;
                    CellRenderer fromPool2 = GetFromPool();
                    m_elementsByItem[k] = fromPool2;
                    fromPool2.SetValue(value4);
                }
                for (int l = Math.Max(num, m_previousLastCellIndex + 1); l <= num2; l++)
                {
                    int          num6      = NormalizeItemIndex(l, m_items.Count);
                    object       value5    = (num6 >= 0) ? m_items[num6] : null;
                    CellRenderer fromPool3 = GetFromPool();
                    m_elementsByItem[l] = fromPool3;
                    fromPool3.SetValue(value5);
                }
            }
            float num7 = ToRowIndex(base.scrollPercentage, normalize: false);

            if (m_horizontal)
            {
                float num8 = num7 * (float)m_cellSize.get_x() % (float)m_cellSize.get_x();
                int   num9 = num;
                for (int m = 0; m <= m_rows; m++)
                {
                    float num10 = (float)(-(m_rows / 2) * m_cellSize.get_x()) - num8 + (float)(m_cellSize.get_x() * m);
                    int   num11 = 0;
                    if (m_elementsByItem.TryGetValue(num9++, out CellRenderer value6))
                    {
                        value6.GetComponent <RectTransform>().set_anchoredPosition(new Vector2(num10, (float)num11));
                    }
                }
            }
            else
            {
                float num13 = num7 * (float)m_cellSize.get_y() % (float)m_cellSize.get_y();
                int   num14 = num;
                for (int n = 0; n <= m_rows; n++)
                {
                    float num15 = (float)(m_rows / 2 * m_cellSize.get_y()) + num13 - (float)(m_cellSize.get_y() * n);
                    int   num16 = 0;
                    if (m_elementsByItem.TryGetValue(num14++, out CellRenderer value7))
                    {
                        value7.GetComponent <RectTransform>().set_anchoredPosition(new Vector2((float)num16, num15));
                    }
                }
            }
            m_previousFirstCellIndex = num;
            m_previousLastCellIndex  = num2;
        }
Example #8
0
 public bool OnDrop(CellRenderer cellRenderer, PointerEventData evt)
 {
     return(true);
 }