From c080ffb2c31ab2f85bc6868cdbdffdc59cf5f204 Mon Sep 17 00:00:00 2001 From: Koerty Date: Thu, 10 May 2018 23:43:08 +0200 Subject: [PATCH] NinePatch now position correctly when origin is different from 0 0 --- es-core/src/components/GridTileComponent.cpp | 1 - es-core/src/components/NinePatchComponent.cpp | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/es-core/src/components/GridTileComponent.cpp b/es-core/src/components/GridTileComponent.cpp index 9e4f6f810..e5fa86a6a 100644 --- a/es-core/src/components/GridTileComponent.cpp +++ b/es-core/src/components/GridTileComponent.cpp @@ -144,7 +144,6 @@ void GridTileComponent::resize() mImage->setMaxSize(currentProperties.mSize - currentProperties.mPadding); mBackground.fitTo(currentProperties.mSize - Vector2f(32.0f, 32.0f)); // (32f, 32f) the NinePatchComponent natural padding - mBackground.setPosition(getSize().x() / 2, getSize().y() / 2); } const GridTileProperties& GridTileComponent::getCurrentProperties() const diff --git a/es-core/src/components/NinePatchComponent.cpp b/es-core/src/components/NinePatchComponent.cpp index 5a2e39e11..fedf95115 100644 --- a/es-core/src/components/NinePatchComponent.cpp +++ b/es-core/src/components/NinePatchComponent.cpp @@ -160,7 +160,8 @@ void NinePatchComponent::fitTo(Vector2f size, Vector3f position, Vector2f paddin position[1] -= padding.y() / 2; setSize(size + mCornerSize * 2); - setPosition(-mCornerSize.x() + position.x(), -mCornerSize.y() + position.y()); + setPosition(position.x() + Math::lerp(-mCornerSize.x(), mCornerSize.x(), mOrigin.x()), + position.y() + Math::lerp(-mCornerSize.y(), mCornerSize.y(), mOrigin.y())); } void NinePatchComponent::setImagePath(const std::string& path)