From e224a077737739a895fe533c9cce93783621d8e9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 19 May 2015 14:49:19 +0300 Subject: 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. --- src/gui/widgets/tabs/tab.cpp | 57 +++++++++++++++++++++++++++++--------------- src/gui/widgets/tabs/tab.h | 1 + 2 files changed, 39 insertions(+), 19 deletions(-) (limited to 'src/gui/widgets/tabs') 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; + } } } diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index 06b5a3d18..8b26ee3d4 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -228,6 +228,7 @@ class Tab notfinal : public BasicContainer, ImageCollection *mVertexes; Image *mImage; int mMode; + int mLabelMode; protected: bool mHasMouse; -- cgit v1.2.3-60-g2f50