Skip to content

Commit

Permalink
Merge pull request RetroPie#403 from Koerty/grid-display-bottom-row
Browse files Browse the repository at this point in the history
[GRID FIX] Bad tile position when close to the last row and last row is full
  • Loading branch information
jrassa authored Apr 7, 2018
2 parents 2ff3252 + c25eaab commit e82895f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions es-core/src/components/ImageGridComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e82895f

Please sign in to comment.