diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-26 13:12:21 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-26 13:12:21 +0300 |
commit | 16b5831a6640bcd1f6f7f23c7b282544bea2b47d (patch) | |
tree | 62145775cec07b241ad7509eae91db1e00734aa2 /src/gui/widgets/window.cpp | |
parent | 2b681b167c1d307f550a8dc7b56a94d13886827e (diff) | |
download | manaplus-16b5831a6640bcd1f6f7f23c7b282544bea2b47d.tar.gz manaplus-16b5831a6640bcd1f6f7f23c7b282544bea2b47d.tar.bz2 manaplus-16b5831a6640bcd1f6f7f23c7b282544bea2b47d.tar.xz manaplus-16b5831a6640bcd1f6f7f23c7b282544bea2b47d.zip |
Use local TextChunk in windows for draw caption text.
Diffstat (limited to 'src/gui/widgets/window.cpp')
-rw-r--r-- | src/gui/widgets/window.cpp | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index f45e93362..e781ec548 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -125,6 +125,7 @@ Window::Window(const std::string &caption, mCloseRect(), mStickyRect(), mGripRect(), + mTextChunk(), mWindowName("window"), mMinWinWidth(100), mMinWinHeight(40), @@ -151,7 +152,8 @@ Window::Window(const std::string &caption, mSticky(false), mStickyButtonLock(false), mPlayVisibleSound(false), - mInit(false) + mInit(false), + mTextChanged(true) { logger->log("Window::Window(\"%s\")", caption.c_str()); @@ -359,11 +361,20 @@ void Window::draw(Graphics *graphics) x = mCaptionOffsetX - mCaptionFont->getWidth(mCaption); break; } - mCaptionFont->drawString(graphics, - mForegroundColor, - mForegroundColor2, - mCaption, - x, mCaptionOffsetY); + if (mTextChanged) + { + mTextChunk.textFont = mCaptionFont; + mTextChunk.deleteImage(); + mTextChunk.text = mCaption; + mTextChunk.color = mForegroundColor; + mTextChunk.color2 = mForegroundColor2; + mCaptionFont->generate(mTextChunk); + mTextChanged = false; + } + + const Image *const image = mTextChunk.img; + if (image) + graphics->drawImage(image, x, mCaptionOffsetY); } if (update) @@ -427,11 +438,20 @@ void Window::safeDraw(Graphics *graphics) x = mCaptionOffsetX - mCaptionFont->getWidth(mCaption); break; } - mCaptionFont->drawString(graphics, - mForegroundColor, - mForegroundColor2, - mCaption, - x, mCaptionOffsetY); + if (mTextChanged) + { + mTextChunk.textFont = mCaptionFont; + mTextChunk.deleteImage(); + mTextChunk.text = mCaption; + mTextChunk.color = mForegroundColor; + mTextChunk.color2 = mForegroundColor2; + mCaptionFont->generate(mTextChunk); + mTextChanged = false; + } + + const Image *const image = mTextChunk.img; + if (image) + graphics->drawImage(image, x, mCaptionOffsetY); } safeDrawChildren(graphics); @@ -668,6 +688,9 @@ void Window::widgetMoved(const Event& event A_UNUSED) void Window::widgetHidden(const Event &event A_UNUSED) { + mTextChanged = true; + mTextChunk.deleteImage(); + if (gui) gui->setCursorType(Cursor::CURSOR_POINTER); |