public void SetFooter(EvasObject?footer, Size size) { bool contentSizeChanged = false; if (IsHorizontal) { if (_footerSize.Width != size.Width) { contentSizeChanged = true; } } else { if (_footerSize.Height != size.Height) { contentSizeChanged = true; } } _footer = footer; _footerSize = size; if (contentSizeChanged) { InitializeMeasureCache(); CollectionView.ContentSizeUpdated(); } UpdateFooterPosition(); }
public void SetHeader(EvasObject?header, Size size) { bool contentSizeChanged = false; if (IsHorizontal) { if (_headerSize.Width != size.Width) { contentSizeChanged = true; } } else { if (_headerSize.Height != size.Height) { contentSizeChanged = true; } } _header = header; _headerSize = size; if (contentSizeChanged) { InitializeMeasureCache(); CollectionView.ContentSizeUpdated(); } var position = CollectionView.ParentPosition; if (_header != null) { var bound = new Rect(position.X, position.Y, _headerSize.Width, _headerSize.Height); if (IsHorizontal) { bound.Height = _allocatedSize.Height; } else { bound.Width = _allocatedSize.Width; } _header.Geometry = bound; } }
public Rect GetItemBound(int index) { int itemSize = 0; int startPoint = 0; if (!_hasUnevenRows) { itemSize = BaseItemSize; startPoint = ItemStartPoint + (itemSize + ItemSpacing) * index; } else if (index >= _itemSizes.Count) { return(new Rect(0, 0, 0, 0)); } else if (_cached[index]) { itemSize = _itemSizes[index]; startPoint = _accumulatedItemSizes[index] - itemSize; } else { var measured = CollectionView.GetItemSize(index, ItemWidthConstraint, ItemHeightConstraint); itemSize = IsHorizontal ? measured.Width : measured.Height; if (itemSize != _itemSizes[index]) { UpdateAccumulatedItemSize(index, itemSize - _itemSizes[index]); _itemSizes[index] = itemSize; CollectionView.ContentSizeUpdated(); } startPoint = _accumulatedItemSizes[index] - itemSize; _cached[index] = true; } return(IsHorizontal ? new Rect(startPoint, 0, itemSize, _allocatedSize.Height) : new Rect(0, startPoint, _allocatedSize.Width, itemSize)); }
public Rect GetItemBound(int index) { int rowIndex = index / Span; int columnIndex = index % Span; var columnSize = ColumnSize; int rowStartPoint = 0; int columnStartPoint = 0; int itemSize = 0; if (!_hasUnevenRows) { itemSize = BaseItemSize; rowStartPoint = ItemStartPoint + rowIndex * (BaseItemSize + ItemSpacing); columnStartPoint = columnIndex * (columnSize + ColumnSpacing); } else if (_cached[index]) { var updatedMaxItemSize = GetMaxItemSize(index); itemSize = _itemSizes[index]; rowStartPoint = _accumulatedItemSizes[rowIndex] - updatedMaxItemSize + (updatedMaxItemSize - itemSize) / 2; columnStartPoint = columnIndex * (columnSize + ColumnSpacing); } else { var oldMaxItemSize = GetMaxItemSize(index); var measured = CollectionView.GetItemSize(index, ItemWidthConstraint, ItemHeightConstraint); itemSize = IsHorizontal ? measured.Width : measured.Height; if (itemSize != _itemSizes[index]) { _itemSizes[index] = itemSize; } var updatedMaxItemSize = GetMaxItemSize(index); if (oldMaxItemSize != updatedMaxItemSize) { UpdateAccumulatedItemSize(rowIndex, updatedMaxItemSize - oldMaxItemSize); int columnStart = (index / Span) * Span; for (int toUpdate = columnStart; toUpdate < index; toUpdate++) { if (_realizedItem.ContainsKey(toUpdate)) { var updated = _realizedItem[toUpdate].View.Geometry; if (IsHorizontal) { updated.X += (updatedMaxItemSize - oldMaxItemSize) / 2; } else { updated.Y += (updatedMaxItemSize - oldMaxItemSize) / 2; } _realizedItem[toUpdate].View.Geometry = updated; } } CollectionView.ContentSizeUpdated(); } rowStartPoint = _accumulatedItemSizes[rowIndex] - updatedMaxItemSize + (updatedMaxItemSize - itemSize) / 2; columnStartPoint = columnIndex * (columnSize + ColumnSpacing); _cached[index] = true; } return(IsHorizontal ? new Rect(rowStartPoint, columnStartPoint, itemSize, columnSize) : new Rect(columnStartPoint, rowStartPoint, columnSize, itemSize)); }