summaryrefslogtreecommitdiff
path: root/src/gui/widgets/tabs/tab.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-19 14:49:19 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-20 00:02:36 +0300
commite224a077737739a895fe533c9cce93783621d8e9 (patch)
tree28194260919ffcc8aa77f52caf45cbf3a1747334 /src/gui/widgets/tabs/tab.cpp
parentfd85f62f2e3003a79e90611e95b09e23710be479 (diff)
downloadplus-e224a077737739a895fe533c9cce93783621d8e9.tar.gz
plus-e224a077737739a895fe533c9cce93783621d8e9.tar.bz2
plus-e224a077737739a895fe533c9cce93783621d8e9.tar.xz
plus-e224a077737739a895fe533c9cce93783621d8e9.zip
Add fast way for draw not changed text strings.
TextChunk with colors and image stored inside draw object. If string or color changed old string image moved to cache. New string image generated or moved from cache. Use new way in drawing string in label.
Diffstat (limited to 'src/gui/widgets/tabs/tab.cpp')
-rw-r--r--src/gui/widgets/tabs/tab.cpp57
1 files changed, 38 insertions, 19 deletions
diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp
index 2f300fb5f..e361c78ff 100644
--- a/src/gui/widgets/tabs/tab.cpp
+++ b/src/gui/widgets/tabs/tab.cpp
@@ -120,6 +120,7 @@ Tab::Tab(const Widget2 *const widget) :
mVertexes(new ImageCollection),
mImage(nullptr),
mMode(0),
+ mLabelMode(-1),
mHasMouse(false)
{
init();
@@ -211,37 +212,55 @@ void Tab::draw(Graphics *graphics)
// check which type of tab to draw
if (mTabbedArea)
{
+ int labelMode = mFlash;
+
if (mTabbedArea->isTabSelected(this))
{
- mLabel->setForegroundColorAll(*mTabSelectedColor,
- *mTabSelectedOutlineColor);
+ labelMode = 3;
mode = TAB_SELECTED;
// if tab is selected, it doesnt need to highlight activity
mFlash = 0;
}
- else if (mHasMouse)
+ else if (!labelMode)
{
- mLabel->setForegroundColorAll(*mTabHighlightedColor,
- *mTabHighlightedOutlineColor);
- mode = TAB_HIGHLIGHTED;
+ if (mHasMouse)
+ {
+ labelMode = 4;
+ mode = TAB_HIGHLIGHTED;
+ }
}
- else
+ else if (mHasMouse)
{
- mLabel->setForegroundColorAll(*mTabColor, *mTabOutlineColor);
+ mode = TAB_HIGHLIGHTED;
}
- switch (mFlash)
+ if (labelMode != mLabelMode)
{
- case 1:
- mLabel->setForegroundColorAll(*mFlashColor,
- *mFlashOutlineColor);
- break;
- case 2:
- mLabel->setForegroundColorAll(*mPlayerFlashColor,
- *mPlayerFlashOutlineColor);
- break;
- default:
- break;
+ 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;
+ }
}
}