Esempio n. 1
0
 /// <summary>
 /// Gets the item position bottom.
 /// </summary>
 /// <returns>The item position bottom.</returns>
 /// <param name="index">Index.</param>
 public override float GetItemPositionBottom(int index)
 {
     return(GetItemPosition(index) + GetItemHeight(DataSource[index]) + LayoutBridge.GetFullMargin() - GetScrollSize());
 }
Esempio n. 2
0
        /// <summary>
        /// Scrolls the update.
        /// </summary>
        protected override void ScrollUpdate()
        {
            var oldTopHiddenItems = topHiddenItems;

            topHiddenItems = GetFirstVisibleIndex();
            if (topHiddenItems > (DataSource.Count - 1))
            {
                topHiddenItems = Mathf.Max(0, DataSource.Count - 2);
            }

            if (oldTopHiddenItems == topHiddenItems)
            {
                return;
            }

            if ((CanOptimize()) && (DataSource.Count > 0))
            {
                visibleItems = (maxVisibleItems < DataSource.Count) ? maxVisibleItems : DataSource.Count;
            }
            else
            {
                visibleItems = DataSource.Count;
            }
            if ((topHiddenItems + visibleItems) > DataSource.Count)
            {
                visibleItems = DataSource.Count - topHiddenItems;
                if (visibleItems < ItemsPerBlock())
                {
                    visibleItems   = Mathf.Min(DataSource.Count, visibleItems + ItemsPerBlock());
                    topHiddenItems = DataSource.Count - visibleItems;
                }
            }

            RemoveCallbacks();

            UpdateComponentsCount();

            bottomHiddenItems = Mathf.Max(0, DataSource.Count - visibleItems - topHiddenItems);

            var new_visible_range     = Enumerable.Range(topHiddenItems, visibleItems).ToList();
            var current_visible_range = components.Convert <TComponent, int>(GetComponentIndex);

            var new_indicies_to_change = new_visible_range.Except(current_visible_range).ToList();
            var components_to_change   = new Stack <TComponent>(components.Where(x => !new_visible_range.Contains(x.Index)));

            new_indicies_to_change.ForEach(index => {
                var component = components_to_change.Pop();

                component.Index = index;
                SetData(component, DataSource[index]);
                Coloring(component as ListViewItem);
            });

            components.Sort(ComponentsComparer);
            components.ForEach(SetComponentAsLastSibling);

            AddCallbacks();

            if (LayoutBridge != null)
            {
                LayoutBridge.SetFiller(CalculateTopFillerSize(), CalculateBottomFillerSize());
                LayoutBridge.UpdateLayout();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the index of the nearest item.
        /// </summary>
        /// <returns>The nearest item index.</returns>
        /// <param name="point">Point.</param>
        public override int GetNearestIndex(Vector2 point)
        {
            if (IsSortEnabled())
            {
                return(-1);
            }

            // block index
            var pos_block = IsHorizontal() ? point.x : -point.y;
            var block     = Mathf.RoundToInt(pos_block / GetItemSize());

            // item index in block
            var pos_elem = IsHorizontal() ? -point.y : point.x;
            var size     = (IsHorizontal()) ? itemHeight + LayoutBridge.GetSpacing() : itemWidth + LayoutBridge.GetSpacing();
            var k        = Mathf.FloorToInt(pos_elem / size);

            return(block * GetItemsPerBlock() + k);
        }
        /// <summary>
        /// Total height of items before and with specified index.
        /// </summary>
        /// <returns>The <see cref="System.Single"/>.</returns>
        /// <param name="index">Index.</param>
        float ItemEndAt(int index)
        {
            var height = DataSource.GetRange(0, index + 1).SumFloat(GetItemHeight);

            return(height + (LayoutBridge.GetSpacing() * index));
        }
 /// <summary>
 /// Gets the item position bottom.
 /// </summary>
 /// <returns>The item position bottom.</returns>
 /// <param name="index">Index.</param>
 public override float GetItemPositionBottom(int index)
 {
     return(GetItemPosition(index) + DataSource[index].Height - LayoutBridge.GetSpacing() + LayoutBridge.GetMargin() - GetScrollSize());
 }
 /// <summary>
 /// Gets the item position.
 /// </summary>
 /// <returns>The item position.</returns>
 /// <param name="index">Index.</param>
 public override float GetItemPosition(int index)
 {
     return(Mathf.Max(0, DataSource.GetRange(0, index).SumFloat(GetItemHeight) + (LayoutBridge.GetSpacing() * (index - 1))));
 }
Esempio n. 7
0
        /// <summary>
        /// Gets the item position bottom.
        /// </summary>
        /// <returns>The item position bottom.</returns>
        /// <param name="index">Index.</param>
        public override float GetItemPositionBottom(int index)
        {
            var block = Mathf.Min(GetBlockIndex(index) + 1, BlockSizes.Count);

            return(BlockSizes.GetRange(0, block).SumFloat() + (LayoutBridge.GetSpacing() * (block - 1)) + LayoutBridge.GetMargin() - GetScrollSize());
        }
Esempio n. 8
0
        /// <summary>
        /// Gets the item position.
        /// </summary>
        /// <returns>The item position.</returns>
        /// <param name="index">Index.</param>
        public override float GetItemPosition(int index)
        {
            var block = GetBlockIndex(index);

            return(BlockSizes.GetRange(0, block).SumFloat() + (LayoutBridge.GetSpacing() * block));
        }