From cdb069409c514a1cec196c2e90ec2f97a5b6753f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 1 Jan 2013 15:08:30 +0300 Subject: Add support for theming in bars in top left corner. New theme options in ministatus.xml: padding - border padding spacing - space between buttons iconPadding - padding for icons iconSpacing - space between icons --- src/gui/ministatuswindow.cpp | 20 ++++++++++++-------- src/gui/ministatuswindow.h | 4 ++++ src/gui/widgets/popup.h | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) (limited to 'src/gui') diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index 835c0b250..64da94389 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -51,6 +51,9 @@ extern volatile int tick_time; MiniStatusWindow::MiniStatusWindow() : Popup("MiniStatus", "ministatus.xml"), InventoryListener(), + mSpacing(mSkin ? mSkin->getOption("spacing", 3) : 3), + mIconPadding(mSkin ? mSkin->getOption("iconPadding", 3) : 3), + mIconSpacing(mSkin ? mSkin->getOption("iconSpacing", 2) : 2), mHpBar(createBar(0, 100, 0, Theme::PROG_HP, "hp bar", _("health bar"))), mMpBar(Net::getGameHandler()->canUseMagicBar() ? createBar(0, 100, 0, Net::getPlayerHandler()->canUseMagic() @@ -149,7 +152,7 @@ ProgressBar *MiniStatusWindow::createBar(const float progress, void MiniStatusWindow::updateBars() { - int x = 0; + int x = mPadding; const ProgressBar *lastBar = nullptr; for (std::vector ::const_iterator it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) @@ -164,17 +167,18 @@ void MiniStatusWindow::updateBars() continue; if (bar->isVisible()) { - bar->setPosition(x, 3); + bar->setPosition(x, mPadding); add(bar); - x += bar->getWidth() + 3; + x += bar->getWidth() + mSpacing; lastBar = bar; } } if (lastBar) { - setContentSize(lastBar->getX() + lastBar->getWidth(), - lastBar->getY() + lastBar->getHeight()); + const int pad2 = 2 * mPadding; + setContentSize(lastBar->getX() + lastBar->getWidth() + pad2, + lastBar->getY() + lastBar->getHeight() + pad2); } } @@ -200,13 +204,13 @@ void MiniStatusWindow::eraseIcon(const int index) void MiniStatusWindow::drawIcons(Graphics *const graphics) { // Draw icons - int icon_x = mStatusBar->getX() + mStatusBar->getWidth() + 4; + int icon_x = mStatusBar->getX() + mStatusBar->getWidth() + mIconPadding; for (size_t i = 0, sz = mIcons.size(); i < sz; i ++) { if (mIcons[i]) { - mIcons[i]->draw(graphics, icon_x, 3); - icon_x += 2 + mIcons[i]->getWidth(); + mIcons[i]->draw(graphics, icon_x, mIconPadding); + icon_x += mIconSpacing + mIcons[i]->getWidth(); } } } diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h index 16d010669..feae1e1df 100644 --- a/src/gui/ministatuswindow.h +++ b/src/gui/ministatuswindow.h @@ -105,6 +105,10 @@ class MiniStatusWindow final : public Popup, std::map mBarNames; std::vector mIcons; + int mSpacing; + int mIconPadding; + int mIconSpacing; + /* * Mini Status Bars */ diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 410e14059..e4ff5ed4b 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -170,6 +170,7 @@ class Popup : public Container, public gcn::MouseListener, protected: int mPadding; /**< Holds the padding of the popup. */ + Skin *mSkin; /**< Skin in use by this popup */ private: std::string mPopupName; /**< Name of the popup */ @@ -178,7 +179,6 @@ class Popup : public Container, public gcn::MouseListener, int mMaxWidth; /**< Maximum popup width */ int mMaxHeight; /**< Maximum popup height */ - Skin *mSkin; /**< Skin in use by this popup */ ImageCollection *mVertexes; bool mRedraw; }; -- cgit v1.2.3-70-g09d2