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(); }
void GUIScrollBar::updateRenderElementsInternal() { IMAGE_SPRITE_DESC desc; if(_getStyle()->normal.texture != nullptr && _getStyle()->normal.texture.isLoaded()) desc.texture = _getStyle()->normal.texture.getInternalPtr(); desc.width = mLayoutData.area.width; desc.height = mLayoutData.area.height; desc.color = getTint(); mImageSprite->update(desc, (UINT64)_getParentWidget()); GUIElement::updateRenderElementsInternal(); }
TEXT_SPRITE_DESC GUIButtonBase::getTextDesc() const { TEXT_SPRITE_DESC textDesc; textDesc.text = mContent.getText(); textDesc.font = _getStyle()->font; textDesc.fontSize = _getStyle()->fontSize; textDesc.color = getTint() * getActiveTextColor(); Rect2I textBounds = getCachedContentBounds(); textDesc.width = textBounds.width; textDesc.height = textBounds.height; textDesc.horzAlign = _getStyle()->textHorzAlign; textDesc.vertAlign = _getStyle()->textVertAlign; return textDesc; }
void GUIColor::updateRenderElementsInternal() { Color color = mValue * getTint(); mColorImageDesc.color = color; mColorImageDesc.color.a = 1.0f; mAlphaImageDesc.color = Color::White * color.a; mAlphaImageDesc.color.a = 1.0f; mColorImageDesc.width = (UINT32)(mLayoutData.area.width * ALPHA_SPLIT_POSITION); mColorImageDesc.height = mLayoutData.area.height; mAlphaImageDesc.width = mLayoutData.area.width - mColorImageDesc.width; mAlphaImageDesc.height = mLayoutData.area.height; mColorSprite->update(mColorImageDesc, (UINT64)_getParentWidget()); mAlphaSprite->update(mAlphaImageDesc, (UINT64)_getParentWidget()); GUIElement::updateRenderElementsInternal(); }