summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-25 21:47:57 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-25 21:47:57 +0300
commit1f4410ab9ac4064ff0cfb0fd31b4e942bee82277 (patch)
tree4b1089f8ba8b33b26fe74911d31ed2ae0f933824 /src/gui/widgets
parentbea613d8ba11a64ccf36a01735f2839894ca9476 (diff)
downloadmanaplus-1f4410ab9ac4064ff0cfb0fd31b4e942bee82277.tar.gz
manaplus-1f4410ab9ac4064ff0cfb0fd31b4e942bee82277.tar.bz2
manaplus-1f4410ab9ac4064ff0cfb0fd31b4e942bee82277.tar.xz
manaplus-1f4410ab9ac4064ff0cfb0fd31b4e942bee82277.zip
Add method safeDrawChildren for safe OpenGL renderer.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/basiccontainer.cpp45
-rw-r--r--src/gui/widgets/basiccontainer.h2
-rw-r--r--src/gui/widgets/basiccontainer2.cpp10
-rw-r--r--src/gui/widgets/popup.cpp2
-rw-r--r--src/gui/widgets/scrollarea.cpp12
-rw-r--r--src/gui/widgets/tabbedarea.cpp2
-rw-r--r--src/gui/widgets/tabs/tab.cpp2
-rw-r--r--src/gui/widgets/window.cpp2
8 files changed, 57 insertions, 20 deletions
diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp
index 6d09cb64b..cd1dac0a2 100644
--- a/src/gui/widgets/basiccontainer.cpp
+++ b/src/gui/widgets/basiccontainer.cpp
@@ -324,10 +324,47 @@ void BasicContainer::drawChildren(Graphics* graphics)
graphics->pushClipArea(widget->mDimension);
BLOCK_START("BasicContainer::drawChildren 2")
- if (isBatchDrawRenders(openGLMode))
- widget->draw(graphics);
- else
- widget->safeDraw(graphics);
+ widget->draw(graphics);
+ BLOCK_END("BasicContainer::drawChildren 2")
+ graphics->popClipArea();
+ }
+ }
+
+ graphics->popClipArea();
+ BLOCK_END("BasicContainer::drawChildren")
+}
+
+void BasicContainer::safeDrawChildren(Graphics* graphics)
+{
+ BLOCK_START("BasicContainer::drawChildren")
+ graphics->pushClipArea(getChildrenArea());
+
+ FOR_EACH (WidgetListConstIterator, iter, mWidgets)
+ {
+ Widget *const widget = *iter;
+ if (widget->isVisibleLocal())
+ {
+ // If the widget has a frame,
+ // draw it before drawing the widget
+ if (widget->mFrameSize > 0)
+ {
+ Rect rec = widget->mDimension;
+ const int frame = widget->mFrameSize;
+ const int frame2 = frame * 2;
+ rec.x -= frame;
+ rec.y -= frame;
+ rec.width += frame2;
+ rec.height += frame2;
+ graphics->pushClipArea(rec);
+ BLOCK_START("BasicContainer::drawChildren 1")
+ widget->drawFrame(graphics);
+ BLOCK_END("BasicContainer::drawChildren 1")
+ graphics->popClipArea();
+ }
+
+ graphics->pushClipArea(widget->mDimension);
+ BLOCK_START("BasicContainer::drawChildren 2")
+ widget->safeDraw(graphics);
BLOCK_END("BasicContainer::drawChildren 2")
graphics->popClipArea();
}
diff --git a/src/gui/widgets/basiccontainer.h b/src/gui/widgets/basiccontainer.h
index 2888950b8..ecc79cba2 100644
--- a/src/gui/widgets/basiccontainer.h
+++ b/src/gui/widgets/basiccontainer.h
@@ -164,6 +164,8 @@ class BasicContainer notfinal : public Widget,
*/
virtual void drawChildren(Graphics* graphics);
+ virtual void safeDrawChildren(Graphics* graphics);
+
/**
* Calls logic for the children widgets of the basic
* container.
diff --git a/src/gui/widgets/basiccontainer2.cpp b/src/gui/widgets/basiccontainer2.cpp
index 4a4184f2c..11fca50b3 100644
--- a/src/gui/widgets/basiccontainer2.cpp
+++ b/src/gui/widgets/basiccontainer2.cpp
@@ -94,7 +94,15 @@ void BasicContainer2::draw(Graphics* graphics)
void BasicContainer2::safeDraw(Graphics* graphics)
{
- BasicContainer2::draw(graphics);
+ BLOCK_START("BasicContainer2::draw")
+ if (isOpaque())
+ {
+ graphics->setColor(getBaseColor());
+ graphics->fillRectangle(Rect(0, 0, getWidth(), getHeight()));
+ }
+
+ safeDrawChildren(graphics);
+ BLOCK_END("BasicContainer2::draw")
}
void BasicContainer2::setOpaque(bool opaque)
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 2e9b3b99b..1f064329d 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -137,7 +137,7 @@ void Popup::safeDraw(Graphics *graphics)
mSkin->getBorder());
}
- drawChildren(graphics);
+ safeDrawChildren(graphics);
BLOCK_END("Popup::safeDraw")
}
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 3da38aaeb..481e4365d 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -394,17 +394,7 @@ void ScrollArea::safeDraw(Graphics *graphics)
updateAlpha();
- if (mRedraw)
- {
- const bool redraw = graphics->getRedraw();
- graphics->setRedraw(true);
- drawChildren(graphics);
- graphics->setRedraw(redraw);
- }
- else
- {
- drawChildren(graphics);
- }
+ safeDrawChildren(graphics);
mRedraw = false;
BLOCK_END("ScrollArea::draw")
}
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 0afa71033..eb70c8012 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -198,7 +198,7 @@ void TabbedArea::safeDraw(Graphics *graphics)
return;
}
- drawChildren(graphics);
+ safeDrawChildren(graphics);
BLOCK_END("TabbedArea::draw")
}
diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp
index 5be8f55dc..ed9d70e30 100644
--- a/src/gui/widgets/tabs/tab.cpp
+++ b/src/gui/widgets/tabs/tab.cpp
@@ -387,7 +387,7 @@ void Tab::safeDraw(Graphics *graphics)
}
}
- drawChildren(graphics);
+ safeDrawChildren(graphics);
BLOCK_END("Tab::draw")
}
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index ec51c3bd8..f45e93362 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -434,7 +434,7 @@ void Window::safeDraw(Graphics *graphics)
x, mCaptionOffsetY);
}
- drawChildren(graphics);
+ safeDrawChildren(graphics);
BLOCK_END("Window::safeDraw")
}