diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-25 21:47:57 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-25 21:47:57 +0300 |
commit | 1f4410ab9ac4064ff0cfb0fd31b4e942bee82277 (patch) | |
tree | 4b1089f8ba8b33b26fe74911d31ed2ae0f933824 /src | |
parent | bea613d8ba11a64ccf36a01735f2839894ca9476 (diff) | |
download | manaverse-1f4410ab9ac4064ff0cfb0fd31b4e942bee82277.tar.gz manaverse-1f4410ab9ac4064ff0cfb0fd31b4e942bee82277.tar.bz2 manaverse-1f4410ab9ac4064ff0cfb0fd31b4e942bee82277.tar.xz manaverse-1f4410ab9ac4064ff0cfb0fd31b4e942bee82277.zip |
Add method safeDrawChildren for safe OpenGL renderer.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/basiccontainer.cpp | 45 | ||||
-rw-r--r-- | src/gui/widgets/basiccontainer.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/basiccontainer2.cpp | 10 | ||||
-rw-r--r-- | src/gui/widgets/popup.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 12 | ||||
-rw-r--r-- | src/gui/widgets/tabbedarea.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/tabs/tab.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/window.cpp | 2 | ||||
-rw-r--r-- | src/gui/windowmenu.cpp | 9 | ||||
-rw-r--r-- | src/gui/windowmenu.h | 2 | ||||
-rw-r--r-- | src/gui/windows/connectiondialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/ministatuswindow.cpp | 2 |
12 files changed, 70 insertions, 22 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") } diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 4cf0a6b2b..1e1f236df 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -426,6 +426,15 @@ void WindowMenu::drawChildren(Graphics* graphics) } } +void WindowMenu::safeDrawChildren(Graphics* graphics) +{ + if (mHaveMouse || !mAutoHide || (mAutoHide == 1 + && mainGraphics && (mSmallWindow || mainGraphics->mWidth > 800))) + { + Container::safeDrawChildren(graphics); + } +} + void WindowMenu::optionChanged(const std::string &name) { if (name == "autohideButtons") diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index e68665aac..9a26ae603 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -87,6 +87,8 @@ class WindowMenu final : public Container, protected: void drawChildren(Graphics* graphics) override final; + void safeDrawChildren(Graphics* graphics) override final; + private: inline void addButton(const char *const text, const std::string &description, diff --git a/src/gui/windows/connectiondialog.cpp b/src/gui/windows/connectiondialog.cpp index a01d7e353..d7d099d38 100644 --- a/src/gui/windows/connectiondialog.cpp +++ b/src/gui/windows/connectiondialog.cpp @@ -85,6 +85,6 @@ void ConnectionDialog::safeDraw(Graphics *graphics) { BLOCK_START("ConnectionDialog::draw") // Don't draw the window background, only draw the children - drawChildren(graphics); + safeDrawChildren(graphics); BLOCK_END("ConnectionDialog::draw") } diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index 7341094aa..b7e8e6430 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -322,7 +322,7 @@ void MiniStatusWindow::draw(Graphics *graphics) void MiniStatusWindow::safeDraw(Graphics *graphics) { BLOCK_START("MiniStatusWindow::draw") - drawChildren(graphics); + safeDrawChildren(graphics); BLOCK_END("MiniStatusWindow::draw") } |