From ac272bc944b32b2099313b6926dfedf937f76d2b Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 13 Apr 2023 22:43:31 +0200 Subject: [PATCH] Fixed an image positioning issue in GridComponent when using the scaleInwards property --- es-core/src/components/primary/GridComponent.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/es-core/src/components/primary/GridComponent.h b/es-core/src/components/primary/GridComponent.h index 3d8f9f519..6a2806f46 100644 --- a/es-core/src/components/primary/GridComponent.h +++ b/es-core/src/components/primary/GridComponent.h @@ -815,14 +815,18 @@ template void GridComponent::render(const glm::mat4& parentTrans offsetInwards.x = -(mItemSize.x / 2.0f); } + const bool textEntry {mEntries.at(*it).data.imagePath.empty() && + mEntries.at(*it).data.defaultImagePath.empty()}; const glm::vec2 position { calculateOffsetPos(itemPos, originInwards, scale, - (mEntries.at(*it).data.imagePath.empty() && - mEntries.at(*it).data.defaultImagePath.empty() ? - mTextRelativeScale : - mImageRelativeScale))}; - mEntries.at(*it).data.item->setOrigin(0.0f, 0.0f); + (textEntry ? mTextRelativeScale : mImageRelativeScale))}; + const glm::vec2 offset {textEntry ? glm::vec2 {0.0f, 0.0f} : + mItemSize * mImageRelativeScale * scale}; + if (textEntry) + mEntries.at(*it).data.item->setOrigin(0.0f, 0.0f); mEntries.at(*it).data.item->setPosition(position.x, position.y); + mEntries.at(*it).data.item->setPosition(position.x + (offset.x / 2.0f), + position.y + (offset.y / 2.0f)); } if (cursorEntry && mSelectorLayer == SelectorLayer::BOTTOM)