summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-25 18:32:11 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-25 18:32:11 +0300
commit6b8cc23d56d0f46bb8b53bbfb3468adea6a7dd77 (patch)
tree7ec19ec5e70b9ada5faf41fe19ed3db1cf1e9f78 /src/gui/widgets
parent2f8d0391e93f723bd2d5836222aebf61b3962cdf (diff)
downloadmv-6b8cc23d56d0f46bb8b53bbfb3468adea6a7dd77.tar.gz
mv-6b8cc23d56d0f46bb8b53bbfb3468adea6a7dd77.tar.bz2
mv-6b8cc23d56d0f46bb8b53bbfb3468adea6a7dd77.tar.xz
mv-6b8cc23d56d0f46bb8b53bbfb3468adea6a7dd77.zip
Add safeDraw method into tab.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/tabs/tab.cpp135
-rw-r--r--src/gui/widgets/tabs/tab.h2
2 files changed, 103 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")
}
diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h
index 8b26ee3d4..f4644df08 100644
--- a/src/gui/widgets/tabs/tab.h
+++ b/src/gui/widgets/tabs/tab.h
@@ -111,6 +111,8 @@ class Tab notfinal : public BasicContainer,
*/
void draw(Graphics *graphics) override final;
+ void safeDraw(Graphics *graphics) override final;
+
/**
* Set the normal color for the tab's text.
*/