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 | |
parent | db461ee046e63b7148174c40e05de76c5d7be31a (diff) | |
download | manaplus-b06e6916d0bbd33d81b4a957b6362f7a0f8ea083.tar.gz manaplus-b06e6916d0bbd33d81b4a957b6362f7a0f8ea083.tar.bz2 manaplus-b06e6916d0bbd33d81b4a957b6362f7a0f8ea083.tar.xz manaplus-b06e6916d0bbd33d81b4a957b6362f7a0f8ea083.zip |
Extend theming in tab control.
Add padding parameter.
-rw-r--r-- | data/graphics/gui/tab.xml | 2 | ||||
-rw-r--r-- | src/gui/widgets/tab.cpp | 36 | ||||
-rw-r--r-- | src/gui/widgets/tab.h | 6 |
3 files changed, 32 insertions, 12 deletions
diff --git a/data/graphics/gui/tab.xml b/data/graphics/gui/tab.xml index e00f7f907..be2301661 100644 --- a/data/graphics/gui/tab.xml +++ b/data/graphics/gui/tab.xml @@ -1,5 +1,7 @@ <skinset name="Default" image="window.png"> <widget type="Window" xpos="68" ypos="0"> + <option name="padding" value="4" /> + <!-- Top Row --> <part type="top-left-corner" xpos="0" ypos="0" width="10" height="5" /> <part type="top-edge" xpos="9" ypos="0" width="8" height="5" /> 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(); diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h index 8c6e7d115..199eefbb3 100644 --- a/src/gui/widgets/tab.h +++ b/src/gui/widgets/tab.h @@ -33,7 +33,9 @@ class GraphicsVertexes; class ImageRect; class Label; +class Skin; class TabbedArea; +class Theme; /** * A tab, the same as the Guichan tab in 0.8, but extended to allow @@ -138,8 +140,8 @@ class Tab : public gcn::BasicContainer, /** Load images if no other instances exist yet */ void init(); - static ImageRect tabImg[4]; /**< Tab state graphics */ - static int mInstances; /**< Number of tab instances */ + static Skin *tabImg[4]; /**< Tab state graphics */ + static int mInstances; /**< Number of tab instances */ static float mAlpha; const gcn::Color *mTabColor; |