summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-25 18:20:16 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-25 18:20:16 +0300
commit5fac4d3253874fc9b5cb21d9269981926c97debf (patch)
tree891cbbd45ccaff24eacff4cf68fccdf94742a25b /src
parent004f4e8ad24087051cafd5b79e9abfafa577f24d (diff)
downloadmv-5fac4d3253874fc9b5cb21d9269981926c97debf.tar.gz
mv-5fac4d3253874fc9b5cb21d9269981926c97debf.tar.bz2
mv-5fac4d3253874fc9b5cb21d9269981926c97debf.tar.xz
mv-5fac4d3253874fc9b5cb21d9269981926c97debf.zip
Add safeDraw method into window.
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/window.cpp157
-rw-r--r--src/gui/widgets/window.h2
2 files changed, 96 insertions, 63 deletions
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 0898549ec..ec51c3bd8 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -284,69 +284,19 @@ void Window::draw(Graphics *graphics)
BLOCK_START("Window::draw")
bool update = false;
- if (isBatchDrawRenders(openGLMode))
+ if (mResizeHandles != mOldResizeHandles)
{
- if (mResizeHandles != mOldResizeHandles)
- {
- mRedraw = true;
- mOldResizeHandles = mResizeHandles;
- }
- if (mRedraw)
- {
- mLastRedraw = true;
- mRedraw = false;
- update = true;
- mVertexes->clear();
- graphics->calcWindow(mVertexes,
- 0, 0,
- mDimension.width,
- mDimension.height,
- mSkin->getBorder());
-
- // Draw Close Button
- if (mCloseWindowButton)
- {
- const Image *const button = mSkin->getCloseImage(
- mResizeHandles == CLOSE);
- if (button)
- {
- graphics->calcTileCollection(mVertexes,
- button,
- mCloseRect.x,
- mCloseRect.y);
- }
- }
- // Draw Sticky Button
- if (mStickyButton)
- {
- const Image *const button = mSkin->getStickyImage(mSticky);
- if (button)
- {
- graphics->calcTileCollection(mVertexes,
- button,
- mStickyRect.x,
- mStickyRect.y);
- }
- }
-
- if (mGrip)
- {
- graphics->calcTileCollection(mVertexes,
- mGrip,
- mGripRect.x,
- mGripRect.y);
- }
- graphics->finalize(mVertexes);
- }
- else
- {
- mLastRedraw = false;
- }
- graphics->drawTileCollection(mVertexes);
+ mRedraw = true;
+ mOldResizeHandles = mResizeHandles;
}
- else
+ if (mRedraw)
{
- graphics->drawImageRect(0, 0,
+ mLastRedraw = true;
+ mRedraw = false;
+ update = true;
+ mVertexes->clear();
+ graphics->calcWindow(mVertexes,
+ 0, 0,
mDimension.width,
mDimension.height,
mSkin->getBorder());
@@ -357,19 +307,40 @@ void Window::draw(Graphics *graphics)
const Image *const button = mSkin->getCloseImage(
mResizeHandles == CLOSE);
if (button)
- graphics->drawImage(button, mCloseRect.x, mCloseRect.y);
+ {
+ graphics->calcTileCollection(mVertexes,
+ button,
+ mCloseRect.x,
+ mCloseRect.y);
+ }
}
// Draw Sticky Button
if (mStickyButton)
{
const Image *const button = mSkin->getStickyImage(mSticky);
if (button)
- graphics->drawImage(button, mStickyRect.x, mStickyRect.y);
+ {
+ graphics->calcTileCollection(mVertexes,
+ button,
+ mStickyRect.x,
+ mStickyRect.y);
+ }
}
if (mGrip)
- graphics->drawImage(mGrip, mGripRect.x, mGripRect.y);
+ {
+ graphics->calcTileCollection(mVertexes,
+ mGrip,
+ mGripRect.x,
+ mGripRect.y);
+ }
+ graphics->finalize(mVertexes);
}
+ else
+ {
+ mLastRedraw = false;
+ }
+ graphics->drawTileCollection(mVertexes);
// Draw title
if (mShowTitle)
@@ -408,6 +379,66 @@ void Window::draw(Graphics *graphics)
BLOCK_END("Window::draw")
}
+void Window::safeDraw(Graphics *graphics)
+{
+ if (!mSkin)
+ return;
+
+ BLOCK_START("Window::safeDraw")
+
+ graphics->drawImageRect(0, 0,
+ mDimension.width,
+ mDimension.height,
+ mSkin->getBorder());
+
+ // Draw Close Button
+ if (mCloseWindowButton)
+ {
+ const Image *const button = mSkin->getCloseImage(
+ mResizeHandles == CLOSE);
+ if (button)
+ graphics->drawImage(button, mCloseRect.x, mCloseRect.y);
+ }
+ // Draw Sticky Button
+ if (mStickyButton)
+ {
+ const Image *const button = mSkin->getStickyImage(mSticky);
+ if (button)
+ graphics->drawImage(button, mStickyRect.x, mStickyRect.y);
+ }
+
+ if (mGrip)
+ graphics->drawImage(mGrip, mGripRect.x, mGripRect.y);
+
+ // Draw title
+ if (mShowTitle)
+ {
+ int x;
+ switch (mCaptionAlign)
+ {
+ case Graphics::LEFT:
+ default:
+ x = mCaptionOffsetX;
+ break;
+ case Graphics::CENTER:
+ x = mCaptionOffsetX - mCaptionFont->getWidth(mCaption) / 2;
+ break;
+ case Graphics::RIGHT:
+ x = mCaptionOffsetX - mCaptionFont->getWidth(mCaption);
+ break;
+ }
+ mCaptionFont->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor2,
+ mCaption,
+ x, mCaptionOffsetY);
+ }
+
+ drawChildren(graphics);
+
+ BLOCK_END("Window::safeDraw")
+}
+
void Window::setContentSize(int width, int height)
{
width = width + 2 * mPadding;
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index 77eac4a5d..2c174aeae 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -128,6 +128,8 @@ class Window notfinal : public BasicContainer2,
*/
void draw(Graphics *graphics) override;
+ void safeDraw(Graphics *graphics) override;
+
/**
* Sets the size of this window.
*/