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(); }
Vector2I GUIButtonBase::_getOptimalSize() const { UINT32 imageWidth = 0; UINT32 imageHeight = 0; const HSpriteTexture& activeTex = getActiveTexture(); if(SpriteTexture::checkIsLoaded(activeTex)) { imageWidth = activeTex->getWidth(); imageHeight = activeTex->getHeight(); } Vector2I contentSize = GUIHelper::calcOptimalContentsSize(mContent, *_getStyle(), _getDimensions(), mActiveState); UINT32 contentWidth = std::max(imageWidth, (UINT32)contentSize.x); UINT32 contentHeight = std::max(imageHeight, (UINT32)contentSize.y); return Vector2I(contentWidth, contentHeight); }
void GLClientState::getClientStatePointer(GLenum pname, GLvoid** params) { const GLClientState::VertexAttribState *state = NULL; switch (pname) { case GL_VERTEX_ARRAY_POINTER: { state = getState(GLClientState::VERTEX_LOCATION); break; } case GL_NORMAL_ARRAY_POINTER: { state = getState(GLClientState::NORMAL_LOCATION); break; } case GL_COLOR_ARRAY_POINTER: { state = getState(GLClientState::COLOR_LOCATION); break; } case GL_TEXTURE_COORD_ARRAY_POINTER: { state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION); break; } case GL_POINT_SIZE_ARRAY_POINTER_OES: { state = getState(GLClientState::POINTSIZE_LOCATION); break; } case GL_MATRIX_INDEX_ARRAY_POINTER_OES: { state = getState(GLClientState::MATRIXINDEX_LOCATION); break; } case GL_WEIGHT_ARRAY_POINTER_OES: { state = getState(GLClientState::WEIGHT_LOCATION); break; } } if (state && params) *params = state->data; }