diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-12-01 19:20:32 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-12-01 22:58:18 +0300 |
commit | 8b27b94feb7edb3ff821a7f4cf4bcb97dd9f1082 (patch) | |
tree | 964557d875a7d994cb2125f0fd10c30a6fc38b03 /src/gui/widgets | |
parent | 212f1eaecc51ca4a112d0e1e22b4a02faec838f3 (diff) | |
download | manaplus-8b27b94feb7edb3ff821a7f4cf4bcb97dd9f1082.tar.gz manaplus-8b27b94feb7edb3ff821a7f4cf4bcb97dd9f1082.tar.bz2 manaplus-8b27b94feb7edb3ff821a7f4cf4bcb97dd9f1082.tar.xz manaplus-8b27b94feb7edb3ff821a7f4cf4bcb97dd9f1082.zip |
Add batch drawing to window.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/window.cpp | 90 | ||||
-rw-r--r-- | src/gui/widgets/window.h | 5 |
2 files changed, 67 insertions, 28 deletions
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index ecf8f0f99..ba6d982c8 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -70,13 +70,14 @@ Window::Window(const std::string &caption, const bool modal, mMinWinHeight(40), mMaxWinWidth(mainGraphics->mWidth), mMaxWinHeight(mainGraphics->mHeight), - mVertexes(new GraphicsVertexes()), + mVertexes(new ImageCollection), mCaptionOffsetX(7), mCaptionOffsetY(5), mCaptionAlign(gcn::Graphics::LEFT), mTitlePadding(4), mGripPadding(2), mResizeHandles(-1), + mOldResizeHandles(-1), mRedraw(true), mPlayVisibleSound(false), mCaptionFont(getFont()) @@ -190,15 +191,71 @@ void Window::draw(gcn::Graphics *graphics) Graphics *const g = static_cast<Graphics*>(graphics); bool update = false; - if (mRedraw) + if (openGLMode != 2) { - mRedraw = false; - update = true; - g->calcWindow(mVertexes, 0, 0, mDimension.width, - mDimension.height, mSkin->getBorder()); + if (mResizeHandles != mOldResizeHandles) + { + mRedraw = true; + mOldResizeHandles = mResizeHandles; + } + if (mRedraw) + { + mRedraw = false; + update = true; + mVertexes->clear(); + g->calcWindow(mVertexes, 0, 0, mDimension.width, + mDimension.height, mSkin->getBorder()); + + // Draw Close Button + if (mCloseButton) + { + const Image *const button = mSkin->getCloseImage( + mResizeHandles == CLOSE); + if (button) + g->calcTile(mVertexes, button, mCloseRect.x, mCloseRect.y); + } + // Draw Sticky Button + if (mStickyButton) + { + const Image *const button = mSkin->getStickyImage(mSticky); + if (button) + { + g->calcTile(mVertexes, button, + mStickyRect.x, mStickyRect.y); + } + } + + if (mGrip) + g->calcTile(mVertexes, mGrip, mGripRect.x, mGripRect.y); + + } + + g->drawTile(mVertexes); } + else + { + g->drawImageRect(0, 0, mDimension.width, + mDimension.height, mSkin->getBorder()); + + // Draw Close Button + if (mCloseButton) + { + const Image *const button = mSkin->getCloseImage( + mResizeHandles == CLOSE); + if (button) + g->drawImage(button, mCloseRect.x, mCloseRect.y); + } + // Draw Sticky Button + if (mStickyButton) + { + const Image *const button = mSkin->getStickyImage(mSticky); + if (button) + g->drawImage(button, mStickyRect.x, mStickyRect.y); + } - g->drawImageRect2(mVertexes, mSkin->getBorder()); + if (mGrip) + g->drawImage(mGrip, mGripRect.x, mGripRect.y); + } // Draw title if (mShowTitle) @@ -209,25 +266,6 @@ void Window::draw(gcn::Graphics *graphics) static_cast<gcn::Graphics::Alignment>(mCaptionAlign)); } - // Draw Close Button - if (mCloseButton) - { - const Image *const button = mSkin->getCloseImage( - mResizeHandles == CLOSE); - if (button) - g->drawImage(button, mCloseRect.x, mCloseRect.y); - } - // Draw Sticky Button - if (mStickyButton) - { - const Image *const button = mSkin->getStickyImage(mSticky); - if (button) - g->drawImage(button, mStickyRect.x, mStickyRect.y); - } - - if (mGrip) - g->drawImage(mGrip, mGripRect.x, mGripRect.y); - if (update) { g->setRedraw(update); diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 2f70bf763..7b05c65f6 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -33,7 +33,7 @@ #include <guichan/widgets/window.hpp> class ContainerPlacer; -class GraphicsVertexes; +class ImageCollection; class Layout; class LayoutCell; class ResizeGrip; @@ -490,13 +490,14 @@ class Window : public gcn::Window, * where two borders are moved at the same time. */ static const unsigned resizeBorderWidth = 10; - GraphicsVertexes *mVertexes; + ImageCollection *mVertexes; int mCaptionOffsetX; int mCaptionOffsetY; int mCaptionAlign; int mTitlePadding; int mGripPadding; int mResizeHandles; + int mOldResizeHandles; bool mRedraw; bool mPlayVisibleSound; gcn::Font *mCaptionFont; |