예제 #1
0
        /// <summary>
        /// Calculates the max count of visible items.
        /// </summary>
        protected override void CalculateMaxVisibleItems()
        {
            var spacing_x = GetItemSpacingX();
            var spacing_y = GetItemSpacingY();

            var height = scrollHeight + spacing_y - LayoutBridge.GetFullMarginY();
            var width  = scrollWidth + spacing_x - LayoutBridge.GetFullMarginX();

            if (IsHorizontal())
            {
                ItemsPerRow = Mathf.CeilToInt(width / (itemWidth + spacing_x)) + 1;
                ItemsPerRow = Mathf.Max(2, ItemsPerRow);

                ItemsPerColumn = Mathf.FloorToInt(height / (itemHeight + spacing_y));
                ItemsPerColumn = Mathf.Max(1, ItemsPerColumn);
                ItemsPerColumn = LayoutBridge.ColumnsConstraint(ItemsPerColumn);
            }
            else
            {
                ItemsPerRow = Mathf.FloorToInt(width / (itemWidth + spacing_x));
                ItemsPerRow = Mathf.Max(1, ItemsPerRow);
                ItemsPerRow = LayoutBridge.RowsConstraint(ItemsPerRow);

                ItemsPerColumn = Mathf.CeilToInt(height / (itemHeight + spacing_y)) + 1;
                ItemsPerColumn = Mathf.Max(2, ItemsPerColumn);
            }

            maxVisibleItems = ItemsPerRow * ItemsPerColumn;
        }
예제 #2
0
        /// <summary>
        /// Calculates the max count of visible items.
        /// </summary>
        protected override void CalculateMaxVisibleItems()
        {
            var spacing = LayoutBridge.GetSpacing();

            if (IsHorizontal())
            {
                var height = scrollHeight + spacing - LayoutBridge.GetFullMargin();

                itemsPerRow = Mathf.CeilToInt(scrollWidth / itemWidth) + 1;
                itemsPerRow = Mathf.Max(2, itemsPerRow);

                itemsPerColumn = Mathf.FloorToInt(height / (itemHeight + spacing));
                itemsPerColumn = Mathf.Max(1, itemsPerColumn);
                itemsPerColumn = LayoutBridge.ColumnsConstraint(itemsPerColumn);
            }
            else
            {
                var width = scrollWidth + spacing - LayoutBridge.GetFullMargin();

                itemsPerRow = Mathf.FloorToInt(width / (itemWidth + spacing));
                itemsPerRow = Mathf.Max(1, itemsPerRow);
                itemsPerRow = LayoutBridge.RowsConstraint(itemsPerRow);

                itemsPerColumn = Mathf.CeilToInt(scrollHeight / itemHeight) + 1;
                itemsPerColumn = Mathf.Max(2, itemsPerColumn);
            }

            maxVisibleItems = itemsPerRow * itemsPerColumn;
        }
예제 #3
0
        /// <summary>
        /// Calculates the max count of visible items.
        /// </summary>
        protected override void CalculateMaxVisibleItems()
        {
            CalculateItemsSizes(DataSource, false);

            var lowest_width  = ItemSizes.Count > 0 ? ItemSizes.Values.Min(x => x.x) : 1;
            var lowest_height = ItemSizes.Count > 0 ? ItemSizes.Values.Min(x => x.y) : 1;

            var spacing_x = GetItemSpacingX();
            var spacing_y = GetItemSpacingY();

            var height = scrollHeight + spacing_y - LayoutBridge.GetFullMarginY();
            var width  = scrollWidth + spacing_x - LayoutBridge.GetFullMarginX();

            if (IsHorizontal())
            {
                ItemsPerColumn = Mathf.FloorToInt(height / (lowest_height + spacing_y));
                ItemsPerColumn = Mathf.Max(1, ItemsPerColumn);
                ItemsPerColumn = LayoutBridge.ColumnsConstraint(ItemsPerColumn);

                CalculateBlockSizes(ItemsPerColumn);

                ItemsPerRow = RequiredBlocksCount(width) + 1;
                ItemsPerRow = Mathf.Max(2, ItemsPerRow);
            }
            else
            {
                ItemsPerRow = Mathf.FloorToInt(width / (lowest_width + spacing_x));
                ItemsPerRow = Mathf.Max(1, ItemsPerRow);
                ItemsPerRow = LayoutBridge.RowsConstraint(ItemsPerRow);

                CalculateBlockSizes(ItemsPerRow);

                ItemsPerColumn = RequiredBlocksCount(height) + 1;
                ItemsPerColumn = Mathf.Max(2, ItemsPerColumn);
            }

            maxVisibleItems = ItemsPerRow * ItemsPerColumn;
        }