UINT32 ScriptSpriteTexture::internal_GetHeight(ScriptSpriteTexture* thisPtr)
	{
		HSpriteTexture spriteTexture = thisPtr->getHandle();
		if (!spriteTexture.isLoaded())
			return 0;

		return spriteTexture->getHeight();
	}
	void GUIButtonBase::updateRenderElementsInternal()
	{		
		mImageDesc.width = mLayoutData.area.width;
		mImageDesc.height = mLayoutData.area.height;

		const HSpriteTexture& activeTex = getActiveTexture();
		if (SpriteTexture::checkIsLoaded(activeTex))
			mImageDesc.texture = activeTex.getInternalPtr();
		else
			mImageDesc.texture = nullptr;

		mImageDesc.borderLeft = _getStyle()->border.left;
		mImageDesc.borderRight = _getStyle()->border.right;
		mImageDesc.borderTop = _getStyle()->border.top;
		mImageDesc.borderBottom = _getStyle()->border.bottom;
		mImageDesc.color = getTint();

		mImageSprite->update(mImageDesc, (UINT64)_getParentWidget());

		mTextSprite->update(getTextDesc(), (UINT64)_getParentWidget());

		if(mContentImageSprite != nullptr)
		{
			Rect2I contentBounds = getCachedContentBounds();

			HSpriteTexture image = mContent.getImage(mActiveState);
			UINT32 contentWidth = image->getWidth();
			UINT32 contentHeight = image->getHeight();

			UINT32 contentMaxWidth = std::min((UINT32)contentBounds.width, contentWidth);
			UINT32 contentMaxHeight = std::min((UINT32)contentBounds.height, contentHeight);

			float horzRatio = contentMaxWidth / (float)contentWidth;
			float vertRatio = contentMaxHeight / (float)contentHeight;

			if (horzRatio < vertRatio)
			{
				contentWidth = Math::roundToInt(contentWidth * horzRatio);
				contentHeight = Math::roundToInt(contentHeight * horzRatio);
			}
			else
			{
				contentWidth = Math::roundToInt(contentWidth * vertRatio);
				contentHeight = Math::roundToInt(contentHeight * vertRatio);
			}

			IMAGE_SPRITE_DESC contentImgDesc;
			contentImgDesc.texture = image.getInternalPtr();
			contentImgDesc.width = contentWidth;
			contentImgDesc.height = contentHeight;
			contentImgDesc.color = getTint();

			mContentImageSprite->update(contentImgDesc, (UINT64)_getParentWidget());
		}

		GUIElement::updateRenderElementsInternal();
	}