Merge pull request #440 from Koerty/grid-fix-horizontal-mod

Fix horizontal scrolling grid bugs
This commit is contained in:
John Rassa 2018-06-06 16:06:36 -07:00 committed by GitHub
commit df60750ec9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -313,7 +313,9 @@ void ImageGridComponent<T>::buildTiles()
calcGridDimension(); calcGridDimension();
Vector2f tileDistance = mTileSize + mMargin; Vector2f tileDistance = mTileSize + mMargin;
Vector2f startPosition = mTileSize / 2 - Vector2f(0, tileDistance.y() * texBuffersForward[3]); Vector2f bufferSize = Vector2f(mScrollDirection == SCROLL_HORIZONTALLY ? tileDistance.x() * texBuffersForward[3] : 0,
mScrollDirection == SCROLL_VERTICALLY ? tileDistance.y() * texBuffersForward[3] : 0);
Vector2f startPosition = mTileSize / 2 - bufferSize;
int X, Y; int X, Y;
@ -456,15 +458,15 @@ void ImageGridComponent<T>::calcGridDimension()
// <=> COLUMNS = (GRID_SIZE + MARGIN) / (TILE_SIZE + MARGIN) // <=> COLUMNS = (GRID_SIZE + MARGIN) / (TILE_SIZE + MARGIN)
Vector2f gridDimension = (mSize + mMargin) / (mTileSize + mMargin); Vector2f gridDimension = (mSize + mMargin) / (mTileSize + mMargin);
// Invert dimensions for horizontally scrolling grid
if (mScrollDirection == SCROLL_HORIZONTALLY)
gridDimension = Vector2f(gridDimension.y(), gridDimension.x());
mLastRowPartial = Math::floorf(gridDimension.y()) != gridDimension.y(); mLastRowPartial = Math::floorf(gridDimension.y()) != gridDimension.y();
// Ceil y dim so we can display partial last row // Ceil y dim so we can display partial last row
mGridDimension = Vector2i(gridDimension.x(), Math::ceilf(gridDimension.y())); mGridDimension = Vector2i(gridDimension.x(), Math::ceilf(gridDimension.y()));
// Invert dimensions for horizontally scrolling grid
if (mScrollDirection == SCROLL_HORIZONTALLY)
mGridDimension = Vector2i(mGridDimension.y(), mGridDimension.x());
// Grid dimension validation // Grid dimension validation
if (mGridDimension.x() < 1) if (mGridDimension.x() < 1)
LOG(LogError) << "Theme defined grid X dimension below 1"; LOG(LogError) << "Theme defined grid X dimension below 1";