diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-10-14 21:37:31 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-10-14 21:37:31 +0300 |
commit | b06e6916d0bbd33d81b4a957b6362f7a0f8ea083 (patch) | |
tree | e163d4231e8ca2a3abc794b5e24e577cb3c28232 /src/gui/widgets/tab.cpp | |
parent | db461ee046e63b7148174c40e05de76c5d7be31a (diff) | |
download | plus-b06e6916d0bbd33d81b4a957b6362f7a0f8ea083.tar.gz plus-b06e6916d0bbd33d81b4a957b6362f7a0f8ea083.tar.bz2 plus-b06e6916d0bbd33d81b4a957b6362f7a0f8ea083.tar.xz plus-b06e6916d0bbd33d81b4a957b6362f7a0f8ea083.zip |
Extend theming in tab control.
Add padding parameter.
Diffstat (limited to 'src/gui/widgets/tab.cpp')
-rw-r--r-- | src/gui/widgets/tab.cpp | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index ab7d5683e..af3a18560 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -60,7 +60,7 @@ static std::string const data[TAB_COUNT] = "tab_unused.xml" }; -ImageRect Tab::tabImg[TAB_COUNT]; +Skin *Tab::tabImg[TAB_COUNT]; Tab::Tab() : gcn::BasicContainer(), @@ -88,9 +88,9 @@ Tab::~Tab() mInstances--; if (mInstances == 0 && Theme::instance()) { - const Theme *const theme = Theme::instance(); + Theme *const theme = Theme::instance(); for (int mode = 0; mode < TAB_COUNT; mode ++) - theme->unloadRect(tabImg[mode]); + theme->unload(tabImg[mode]); } delete mLabel; @@ -119,7 +119,7 @@ void Tab::init() if (theme) { for (int mode = 0; mode < TAB_COUNT; mode ++) - theme->loadRect(tabImg[mode], data[mode], "tab.xml"); + tabImg[mode] = theme->load(data[mode], "tab.xml"); } updateAlpha(); } @@ -140,8 +140,14 @@ void Tab::updateAlpha() { for (int t = 0; t < TAB_COUNT; t++) { - if (tabImg[t].grid[a]) - tabImg[t].grid[a]->setAlpha(mAlpha); + Skin *skin = tabImg[t]; + if (skin) + { + ImageRect &rect = skin->getBorder(); + Image *image = rect.grid[a]; + if (image) + image->setAlpha(mAlpha); + } } } } @@ -184,8 +190,13 @@ void Tab::draw(gcn::Graphics *graphics) } } + const Skin *const skin = tabImg[mode]; + if (!skin) + return; + updateAlpha(); + ImageRect &rect = skin->getBorder(); // draw tab if (mRedraw || mode != mMode || static_cast<Graphics*>(graphics)->getRedraw()) @@ -193,10 +204,10 @@ void Tab::draw(gcn::Graphics *graphics) mMode = mode; mRedraw = false; static_cast<Graphics*>(graphics)->calcWindow(mVertexes, 0, 0, - getWidth(), getHeight(), tabImg[mode]); + getWidth(), getHeight(), rect); } - static_cast<Graphics*>(graphics)->drawImageRect2(mVertexes, tabImg[mode]); + static_cast<Graphics*>(graphics)->drawImageRect2(mVertexes, rect); // static_cast<Graphics*>(graphics)-> // drawImageRect(0, 0, getWidth(), getHeight(), tabImg[mode]); @@ -228,8 +239,13 @@ void Tab::setLabelFont(gcn::Font *const font) void Tab::adjustSize() { - setSize(mLabel->getWidth() + 8, - mLabel->getHeight() + 8); + const Skin *const skin = tabImg[TAB_STANDARD]; + if (!skin) + return; + const int padding = skin->getPadding(); + + setSize(mLabel->getWidth() + 2 * padding, + mLabel->getHeight() + 2 * padding); if (mTabbedArea) mTabbedArea->adjustTabPositions(); |