mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 14:03:26 +02:00
optimizations
This commit is contained in:
@@ -72,7 +72,7 @@ void UIWidget::draw(const Rect& visibleRect)
|
||||
void UIWidget::drawSelf()
|
||||
{
|
||||
// draw style components in order
|
||||
if(m_backgroundColor.aF() != 0.0f) {
|
||||
if(m_backgroundColor.aF() > Fw::MIN_ALPHA) {
|
||||
Rect backgroundDestRect = m_rect;
|
||||
backgroundDestRect.expand(-m_borderWidth.top, -m_borderWidth.right, -m_borderWidth.bottom, -m_borderWidth.left);
|
||||
drawBackground(m_rect);
|
||||
@@ -89,7 +89,7 @@ void UIWidget::drawChildren(const Rect& visibleRect)
|
||||
// draw children
|
||||
for(const UIWidgetPtr& child : m_children) {
|
||||
// render only visible children with a valid rect inside parent rect
|
||||
if(!child->isExplicitlyVisible() || !child->getRect().isValid() || child->getOpacity() == 0.0f)
|
||||
if(!child->isExplicitlyVisible() || !child->getRect().isValid() || child->getOpacity() < Fw::MIN_ALPHA)
|
||||
continue;
|
||||
|
||||
Rect childVisibleRect = visibleRect.intersection(child->getRect());
|
||||
|
@@ -314,7 +314,7 @@ void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode)
|
||||
|
||||
void UIWidget::drawBackground(const Rect& screenCoords)
|
||||
{
|
||||
if(m_backgroundColor.aF() != 0.0f) {
|
||||
if(m_backgroundColor.aF() > 0.0f) {
|
||||
Rect drawRect = screenCoords;
|
||||
drawRect.translate(m_backgroundRect.topLeft());
|
||||
if(m_backgroundRect.isValid())
|
||||
@@ -327,28 +327,28 @@ void UIWidget::drawBackground(const Rect& screenCoords)
|
||||
void UIWidget::drawBorder(const Rect& screenCoords)
|
||||
{
|
||||
// top
|
||||
if(m_borderWidth.top > 0 && m_borderColor.top.aF() != 0.0f) {
|
||||
if(m_borderWidth.top > 0) {
|
||||
g_painter.setColor(m_borderColor.top);
|
||||
|
||||
Rect borderRect(screenCoords.topLeft(), screenCoords.width(), m_borderWidth.top);
|
||||
g_painter.drawFilledRect(borderRect);
|
||||
}
|
||||
// right
|
||||
if(m_borderWidth.right > 0 && m_borderColor.right.aF() != 0.0f) {
|
||||
if(m_borderWidth.right > 0) {
|
||||
g_painter.setColor(m_borderColor.right);
|
||||
|
||||
Rect borderRect(screenCoords.topRight() - Point(m_borderWidth.right - 1, 0), m_borderWidth.right, screenCoords.height());
|
||||
g_painter.drawFilledRect(borderRect);
|
||||
}
|
||||
// bottom
|
||||
if(m_borderWidth.bottom > 0 && m_borderColor.bottom.aF() != 0.0f) {
|
||||
if(m_borderWidth.bottom > 0) {
|
||||
g_painter.setColor(m_borderColor.bottom);
|
||||
|
||||
Rect borderRect(screenCoords.bottomLeft() - Point(0, m_borderWidth.bottom - 1), screenCoords.width(), m_borderWidth.bottom);
|
||||
g_painter.drawFilledRect(borderRect);
|
||||
}
|
||||
// left
|
||||
if(m_borderWidth.left > 0 && m_borderColor.left.aF() != 0.0f) {
|
||||
if(m_borderWidth.left > 0) {
|
||||
g_painter.setColor(m_borderColor.left);
|
||||
|
||||
Rect borderRect(screenCoords.topLeft(), m_borderWidth.left, screenCoords.height());
|
||||
@@ -358,7 +358,7 @@ void UIWidget::drawBorder(const Rect& screenCoords)
|
||||
|
||||
void UIWidget::drawIcon(const Rect& screenCoords)
|
||||
{
|
||||
if(m_icon && m_iconColor.aF() != 0.0f) {
|
||||
if(m_icon) {
|
||||
Rect drawRect;
|
||||
if(m_iconRect.isValid()) {
|
||||
drawRect = screenCoords;
|
||||
|
@@ -76,7 +76,7 @@ void UIWidget::parseImageStyle(const OTMLNodePtr& styleNode)
|
||||
|
||||
void UIWidget::drawImage(const Rect& screenCoords)
|
||||
{
|
||||
if(!m_imageTexture || m_imageColor.aF() == 0.0f || !screenCoords.isValid())
|
||||
if(!m_imageTexture || !screenCoords.isValid())
|
||||
return;
|
||||
|
||||
// cache vertex buffers
|
||||
|
Reference in New Issue
Block a user