Merge pull request #403 from Koerty/grid-display-bottom-row

[GRID FIX] Bad tile position when close to the last row and last row is full
This commit is contained in:
John Rassa 2018-04-06 19:18:44 -07:00 committed by GitHub
commit e82895ffca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -221,9 +221,13 @@ void ImageGridComponent<T>::updateImages()
int start = (cursorRow - (gridDimension.y() / 2)) * gridDimension.x();
//if we're at the end put the row as close as we can and no higher
// If we are at the end put the row as close as we can and no higher, using the following formula
// Where E is the nb of entries, X the grid x dim (nb of column), Y the grid y dim (nb of line)
// start = first tile of last row - nb column * (nb line - 1)
// = (E - 1) / X * X - X * (Y - 1)
// = X * ((E - 1) / X - Y + 1)
if(start + (gridDimension.x() * gridDimension.y()) >= (int)mEntries.size())
start = gridDimension.x() * ((int)mEntries.size()/gridDimension.x() - gridDimension.y() + 1);
start = gridDimension.x() * (((int)mEntries.size() - 1) / gridDimension.x() - gridDimension.y() + 1);
if(start < 0)
start = 0;