From c25eaab7fb5dc9168caa3deb1c24965f1977ec15 Mon Sep 17 00:00:00 2001 From: Koerty Date: Mon, 2 Apr 2018 15:28:33 +0200 Subject: [PATCH] Fix bad tile position when close to the last row and last row is full --- es-core/src/components/ImageGridComponent.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/es-core/src/components/ImageGridComponent.h b/es-core/src/components/ImageGridComponent.h index 95aed4bbf..7cab9990e 100644 --- a/es-core/src/components/ImageGridComponent.h +++ b/es-core/src/components/ImageGridComponent.h @@ -221,9 +221,13 @@ void ImageGridComponent::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;