diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-25 18:32:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-25 18:32:11 +0300 |
commit | 6b8cc23d56d0f46bb8b53bbfb3468adea6a7dd77 (patch) | |
tree | 7ec19ec5e70b9ada5faf41fe19ed3db1cf1e9f78 /src/gui/widgets/tabs/tab.cpp | |
parent | 2f8d0391e93f723bd2d5836222aebf61b3962cdf (diff) | |
download | ManaVerse-6b8cc23d56d0f46bb8b53bbfb3468adea6a7dd77.tar.gz ManaVerse-6b8cc23d56d0f46bb8b53bbfb3468adea6a7dd77.tar.bz2 ManaVerse-6b8cc23d56d0f46bb8b53bbfb3468adea6a7dd77.tar.xz ManaVerse-6b8cc23d56d0f46bb8b53bbfb3468adea6a7dd77.zip |
Add safeDraw method into tab.
Diffstat (limited to 'src/gui/widgets/tabs/tab.cpp')
-rw-r--r-- | src/gui/widgets/tabs/tab.cpp | 135 |
1 files changed, 101 insertions, 34 deletions
diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index 21b51d79a..5be8f55dc 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -273,53 +273,120 @@ void Tab::draw(Graphics *graphics) updateAlpha(); - // draw tab - if (isBatchDrawRenders(openGLMode)) + const ImageRect &rect = skin->getBorder(); + if (mRedraw || mode != mMode || graphics->getRedraw()) { - const ImageRect &rect = skin->getBorder(); - if (mRedraw || mode != mMode || graphics->getRedraw()) + mMode = mode; + mRedraw = false; + mVertexes->clear(); + graphics->calcWindow(mVertexes, + 0, 0, + mDimension.width, mDimension.height, + rect); + + if (mImage) { - mMode = mode; - mRedraw = false; - mVertexes->clear(); - graphics->calcWindow(mVertexes, - 0, 0, - mDimension.width, mDimension.height, - rect); - - if (mImage) + const Skin *const skin1 = tabImg[TAB_STANDARD]; + if (skin1) { - const Skin *const skin1 = tabImg[TAB_STANDARD]; - if (skin1) - { - const int padding = skin1->getPadding(); - graphics->calcTileCollection(mVertexes, - mImage, - padding, - padding); - } + const int padding = skin1->getPadding(); + graphics->calcTileCollection(mVertexes, + mImage, + padding, + padding); } - graphics->finalize(mVertexes); } - - graphics->drawTileCollection(mVertexes); + graphics->finalize(mVertexes); } - else + + graphics->drawTileCollection(mVertexes); + + drawChildren(graphics); + BLOCK_END("Tab::draw") +} + +void Tab::safeDraw(Graphics *graphics) +{ + BLOCK_START("Tab::draw") + int mode = TAB_STANDARD; + + // check which type of tab to draw + if (mTabbedArea) { - graphics->drawImageRect(0, 0, - mDimension.width, mDimension.height, - skin->getBorder()); - if (mImage) + int labelMode = mFlash; + + if (mTabbedArea->isTabSelected(this)) { - const Skin *const skin1 = tabImg[TAB_STANDARD]; - if (skin1) + labelMode = 3; + mode = TAB_SELECTED; + // if tab is selected, it doesnt need to highlight activity + mFlash = 0; + } + else if (!labelMode) + { + if (mHasMouse) { - const int padding = skin1->getPadding(); - graphics->drawImage(mImage, padding, padding); + labelMode = 4; + mode = TAB_HIGHLIGHTED; + } + } + else if (mHasMouse) + { + mode = TAB_HIGHLIGHTED; + } + + if (labelMode != mLabelMode) + { + mLabelMode = labelMode; + switch (labelMode) + { + case 0: // default state + default: + mLabel->setForegroundColorAll(*mTabColor, + *mTabOutlineColor); + break; + case 1: // mFlash == 1 + mLabel->setForegroundColorAll(*mFlashColor, + *mFlashOutlineColor); + break; + case 2: // mFlash == 2 + mLabel->setForegroundColorAll(*mPlayerFlashColor, + *mPlayerFlashOutlineColor); + break; + case 3: // mTabbedArea->isTabSelected(this) + mLabel->setForegroundColorAll(*mTabSelectedColor, + *mTabSelectedOutlineColor); + break; + case 4: // mHasMouse + mLabel->setForegroundColorAll(*mTabHighlightedColor, + *mTabHighlightedOutlineColor); + break; } } } + const Skin *const skin = tabImg[mode]; + if (!skin) + { + BLOCK_END("Tab::draw") + return; + } + + updateAlpha(); + + graphics->drawImageRect(0, 0, + mDimension.width, mDimension.height, + skin->getBorder()); + if (mImage) + { + const Skin *const skin1 = tabImg[TAB_STANDARD]; + if (skin1) + { + const int padding = skin1->getPadding(); + graphics->drawImage(mImage, padding, padding); + } + } + drawChildren(graphics); BLOCK_END("Tab::draw") } |