summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-04 17:00:40 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-04 17:30:17 +0300
commit7a7f5905cf19f6a773dcf9bab762b54c16e325f2 (patch)
tree4c891cfaa2eadeecd0685782d8cf561c2a79dbf8
parent0c7a1466e8c2c2dd6e15779368c87b62b2da601f (diff)
downloadmanaverse-7a7f5905cf19f6a773dcf9bab762b54c16e325f2.tar.gz
manaverse-7a7f5905cf19f6a773dcf9bab762b54c16e325f2.tar.bz2
manaverse-7a7f5905cf19f6a773dcf9bab762b54c16e325f2.tar.xz
manaverse-7a7f5905cf19f6a773dcf9bab762b54c16e325f2.zip
Add support for padding in progress bars.
Also fixed progress bars size. New progress bar attributes: fillPadding - padding for will rectangle padding - normal padding for bar
-rw-r--r--data/graphics/gui/progressbar.xml2
-rw-r--r--data/themes/enchilado/CMakeLists.txt1
-rw-r--r--data/themes/enchilado/Makefile.am1
-rw-r--r--data/themes/enchilado/progressbar.xml25
-rw-r--r--data/themes/pink/CMakeLists.txt1
-rw-r--r--data/themes/pink/Makefile.am1
-rw-r--r--data/themes/pink/progressbar.xml25
-rw-r--r--data/themes/unity/CMakeLists.txt1
-rw-r--r--data/themes/unity/Makefile.am1
-rw-r--r--data/themes/unity/progressbar.xml25
-rw-r--r--data/themes/wood/CMakeLists.txt1
-rw-r--r--data/themes/wood/Makefile.am1
-rw-r--r--data/themes/wood/progressbar.xml25
-rw-r--r--src/gui/inventorywindow.cpp4
-rw-r--r--src/gui/ministatuswindow.cpp18
-rw-r--r--src/gui/skilldialog.cpp7
-rw-r--r--src/gui/specialswindow.cpp2
-rw-r--r--src/gui/statuswindow.cpp8
-rw-r--r--src/gui/updaterwindow.cpp2
-rw-r--r--src/gui/widgets/progressbar.cpp113
-rw-r--r--src/gui/widgets/progressbar.h20
21 files changed, 178 insertions, 106 deletions
diff --git a/data/graphics/gui/progressbar.xml b/data/graphics/gui/progressbar.xml
index b425025bb..dab818416 100644
--- a/data/graphics/gui/progressbar.xml
+++ b/data/graphics/gui/progressbar.xml
@@ -1,5 +1,7 @@
<skinset name="Default" image="window.png">
<widget type="Window" xpos="73" ypos="164">
+ <option name="padding" value="1" />
+ <option name="fillPadding" value="3" />
<!-- Top Row -->
<part type="top-left-corner" xpos="0" ypos="0" width="4" height="4" />
<part type="top-edge" xpos="4" ypos="0" width="3" height="4" />
diff --git a/data/themes/enchilado/CMakeLists.txt b/data/themes/enchilado/CMakeLists.txt
index 80fdfdb85..a008e8f86 100644
--- a/data/themes/enchilado/CMakeLists.txt
+++ b/data/themes/enchilado/CMakeLists.txt
@@ -3,6 +3,7 @@ SET (FILES
colors.xml
inventory.xml
popup.xml
+ progressbar.xml
quests.xml
sell.xml
server.xml
diff --git a/data/themes/enchilado/Makefile.am b/data/themes/enchilado/Makefile.am
index 65dbcc21c..041c1aaf8 100644
--- a/data/themes/enchilado/Makefile.am
+++ b/data/themes/enchilado/Makefile.am
@@ -6,6 +6,7 @@ gui_DATA = \
colors.xml \
inventory.xml \
popup.xml \
+ progressbar.xml \
quests.xml \
sell.xml \
server.xml \
diff --git a/data/themes/enchilado/progressbar.xml b/data/themes/enchilado/progressbar.xml
new file mode 100644
index 000000000..2ffd0966e
--- /dev/null
+++ b/data/themes/enchilado/progressbar.xml
@@ -0,0 +1,25 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window" xpos="190" ypos="30">
+ <option name="padding" value="1" />
+ <option name="fillPadding" value="3" />
+
+ <!-- Top Row -->
+ <part type="top-left-corner" xpos="0" ypos="0" width="10" height="10" />
+ <part type="top-edge" xpos="11" ypos="0" width="127" height="10" />
+ <part type="top-right-corner" xpos="139" ypos="0" width="12" height="10" />
+
+ <!-- Middle Row -->
+ <part type="left-edge" xpos="0" ypos="11" width="10" height="81" />
+ <part type="bg-quad" xpos="11" ypos="11" width="127" height="81" />
+ <part type="right-edge" xpos="139" ypos="11" width="12" height="81" />
+
+ <!-- Bottom Row -->
+ <part type="bottom-left-corner" xpos="0" ypos="93" width="10" height="12" />
+ <part type="bottom-edge" xpos="11" ypos="93" width="127" height="12" />
+ <part type="bottom-right-corner" xpos="139" ypos="93" width="12" height="12" />
+
+ <part type="closeImage" xpos="-60" ypos="-30" width="15" height="15" />
+ <part type="stickyImageUp" xpos="-60" ypos="21" width="15" height="15" />
+ <part type="stickyImageDown" xpos="-45" ypos="21" width="15" height="15" />
+ </widget>
+</skinset>
diff --git a/data/themes/pink/CMakeLists.txt b/data/themes/pink/CMakeLists.txt
index 061d9a1e9..04e036ffa 100644
--- a/data/themes/pink/CMakeLists.txt
+++ b/data/themes/pink/CMakeLists.txt
@@ -5,6 +5,7 @@ SET (FILES
inventory.xml
popup.xml
progress-indicator.png
+ progressbar.xml
quests.xml
sell.xml
server.xml
diff --git a/data/themes/pink/Makefile.am b/data/themes/pink/Makefile.am
index 69e1d6b4e..025b043bd 100644
--- a/data/themes/pink/Makefile.am
+++ b/data/themes/pink/Makefile.am
@@ -8,6 +8,7 @@ gui_DATA = \
inventory.xml \
popup.xml \
progress-indicator.png \
+ progressbar.xml \
quests.xml \
sell.xml \
server.xml \
diff --git a/data/themes/pink/progressbar.xml b/data/themes/pink/progressbar.xml
new file mode 100644
index 000000000..f8d3563e2
--- /dev/null
+++ b/data/themes/pink/progressbar.xml
@@ -0,0 +1,25 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window" xpos="250" ypos="0">
+ <option name="padding" value="1" />
+ <option name="fillPadding" value="3" />
+
+ <!-- Top Row -->
+ <part type="top-left-corner" xpos="0" ypos="0" width="10" height="10" />
+ <part type="top-edge" xpos="0" ypos="10" width="10" height="10" />
+ <part type="top-right-corner" xpos="0" ypos="20" width="10" height="10" />
+
+ <!-- Middle Row -->
+ <part type="left-edge" xpos="0" ypos="30" width="10" height="10" />
+ <part type="bg-quad" xpos="0" ypos="40" width="10" height="10" />
+ <part type="right-edge" xpos="0" ypos="50" width="10" height="10" />
+
+ <!-- Bottom Row -->
+ <part type="bottom-left-corner" xpos="0" ypos="60" width="10" height="10" />
+ <part type="bottom-edge" xpos="0" ypos="70" width="10" height="10" />
+ <part type="bottom-right-corner" xpos="10" ypos="0" width="132" height="134" />
+
+ <part type="closeImage" xpos="-120" ypos="0" width="15" height="15" />
+ <part type="stickyImageUp" xpos="-120" ypos="51" width="15" height="15" />
+ <part type="stickyImageDown" xpos="-105" ypos="51" width="15" height="15" />
+ </widget>
+</skinset>
diff --git a/data/themes/unity/CMakeLists.txt b/data/themes/unity/CMakeLists.txt
index 3572a7dc1..c54c64723 100644
--- a/data/themes/unity/CMakeLists.txt
+++ b/data/themes/unity/CMakeLists.txt
@@ -5,6 +5,7 @@ SET (FILES
inventory.xml
npc.xml
popup.xml
+ progressbar.xml
quests.xml
sell.xml
server.xml
diff --git a/data/themes/unity/Makefile.am b/data/themes/unity/Makefile.am
index a27e3741b..735028301 100644
--- a/data/themes/unity/Makefile.am
+++ b/data/themes/unity/Makefile.am
@@ -8,6 +8,7 @@ gui_DATA = \
inventory.xml \
npc.xml \
popup.xml \
+ progressbar.xml \
quests.xml \
sell.xml \
server.xml \
diff --git a/data/themes/unity/progressbar.xml b/data/themes/unity/progressbar.xml
new file mode 100644
index 000000000..44d1e58f7
--- /dev/null
+++ b/data/themes/unity/progressbar.xml
@@ -0,0 +1,25 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window" xpos="260" ypos="0">
+ <option name="padding" value="7" />
+ <option name="fillPadding" value="9" />
+
+ <!-- Top Row -->
+ <part type="top-left-corner" xpos="0" ypos="0" width="10" height="10" />
+ <part type="top-edge" xpos="11" ypos="0" width="127" height="10" />
+ <part type="top-right-corner" xpos="139" ypos="0" width="12" height="10" />
+
+ <!-- Middle Row -->
+ <part type="left-edge" xpos="0" ypos="11" width="10" height="81" />
+ <part type="bg-quad" xpos="11" ypos="11" width="127" height="81" />
+ <part type="right-edge" xpos="139" ypos="11" width="12" height="81" />
+
+ <!-- Bottom Row -->
+ <part type="bottom-left-corner" xpos="0" ypos="93" width="10" height="12" />
+ <part type="bottom-edge" xpos="11" ypos="93" width="127" height="12" />
+ <part type="bottom-right-corner" xpos="139" ypos="93" width="12" height="12" />
+
+ <part type="closeImage" xpos="-130" ypos="0" width="15" height="15" />
+ <part type="stickyImageUp" xpos="-130" ypos="51" width="15" height="15" />
+ <part type="stickyImageDown" xpos="-115" ypos="51" width="15" height="15" />
+ </widget>
+</skinset>
diff --git a/data/themes/wood/CMakeLists.txt b/data/themes/wood/CMakeLists.txt
index 8c984dba7..c62b25d47 100644
--- a/data/themes/wood/CMakeLists.txt
+++ b/data/themes/wood/CMakeLists.txt
@@ -5,6 +5,7 @@ SET (FILES
item_shortcut_bgr.png
mouse.png
popup.xml
+ progressbar.xml
quests.xml
sell.xml
server.xml
diff --git a/data/themes/wood/Makefile.am b/data/themes/wood/Makefile.am
index b2ada3479..11af7c229 100644
--- a/data/themes/wood/Makefile.am
+++ b/data/themes/wood/Makefile.am
@@ -8,6 +8,7 @@ gui_DATA = \
item_shortcut_bgr.png \
mouse.png \
popup.xml \
+ progressbar.xml \
quests.xml \
sell.xml \
server.xml \
diff --git a/data/themes/wood/progressbar.xml b/data/themes/wood/progressbar.xml
new file mode 100644
index 000000000..5a0113287
--- /dev/null
+++ b/data/themes/wood/progressbar.xml
@@ -0,0 +1,25 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window" xpos="260" ypos="0">
+ <option name="padding" value="1" />
+ <option name="fillPadding" value="3" />
+
+ <!-- Top Row -->
+ <part type="top-left-corner" width="10" height="10" />
+ <part type="top-edge" xpos="11" ypos="0" width="127" height="10" />
+ <part type="top-right-corner" xpos="139" ypos="0" width="12" height="10" />
+
+ <!-- Middle Row -->
+ <part type="left-edge" xpos="0" ypos="11" width="10" height="81" />
+ <part type="bg-quad" xpos="11" ypos="11" width="127" height="81" />
+ <part type="right-edge" xpos="139" ypos="11" width="12" height="81" />
+
+ <!-- Bottom Row -->
+ <part type="bottom-left-corner" xpos="0" ypos="93" width="10" height="12" />
+ <part type="bottom-edge" xpos="11" ypos="93" width="127" height="12" />
+ <part type="bottom-right-corner" xpos="139" ypos="93" width="12" height="12" />
+
+ <part type="closeImage" xpos="-130" ypos="0" width="15" height="15" />
+ <part type="stickyImageUp" xpos="-130" ypos="51" width="15" height="15" />
+ <part type="stickyImageDown" xpos="-115" ypos="51" width="15" height="15" />
+ </widget>
+</skinset>
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index ffa1f29d8..fd85b0d85 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -106,7 +106,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory):
mRetrieveButton(nullptr),
mCloseButton(nullptr),
mWeightBar(nullptr),
- mSlotsBar(new ProgressBar(0.0f, 100, 20, Theme::PROG_INVY_SLOTS)),
+ mSlotsBar(new ProgressBar(0.0f, 100, 0, Theme::PROG_INVY_SLOTS)),
mFilter(nullptr),
mSortModel(new SortListModel()),
mSortDropDown(new DropDown(mSortModel, this, "sort")),
@@ -183,7 +183,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory):
mOutfitButton = new Button(_("Outfits"), "outfit", this);
mShopButton = new Button(_("Shop"), "shop", this);
mEquipmentButton = new Button(_("Equipment"), "equipment", this);
- mWeightBar = new ProgressBar(0.0f, 100, 20, Theme::PROG_WEIGHT);
+ mWeightBar = new ProgressBar(0.0f, 100, 0, Theme::PROG_WEIGHT);
place(0, 0, mWeightBar, 4);
mSlotsBarCell = &place(4, 0, mSlotsBar, 5);
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp
index b219d23c7..5aa22800b 100644
--- a/src/gui/ministatuswindow.cpp
+++ b/src/gui/ministatuswindow.cpp
@@ -53,22 +53,22 @@ extern volatile int tick_time;
MiniStatusWindow::MiniStatusWindow() :
Popup("MiniStatus", "ministatus.xml"),
InventoryListener(),
- mHpBar(createBar(0, 100, 20, Theme::PROG_HP, "hp bar", _("health bar"))),
+ mHpBar(createBar(0, 100, 0, Theme::PROG_HP, "hp bar", _("health bar"))),
mMpBar(Net::getGameHandler()->canUseMagicBar()
- ? createBar(0, 100, 20, Net::getPlayerHandler()->canUseMagic()
+ ? createBar(0, 100, 0, Net::getPlayerHandler()->canUseMagic()
? Theme::PROG_MP : Theme::PROG_NO_MP, "mp bar", _("mana bar"))
: nullptr),
- mXpBar(createBar(0, 100, 20, Theme::PROG_EXP,
+ mXpBar(createBar(0, 100, 0, Theme::PROG_EXP,
"xp bar", _("experience bar"))),
- mWeightBar(createBar(0, 140, 20, Theme::PROG_WEIGHT,
+ mWeightBar(createBar(0, 140, 0, Theme::PROG_WEIGHT,
"weight bar", _("weight bar"))),
- mInvSlotsBar(createBar(0, 45, 20, Theme::PROG_INVY_SLOTS,
+ mInvSlotsBar(createBar(0, 45, 0, Theme::PROG_INVY_SLOTS,
"inventory slots bar", _("inventory slots bar"))),
- mMoneyBar(createBar(0, 130, 20, Theme::PROG_INVY_SLOTS,
+ mMoneyBar(createBar(0, 130, 0, Theme::PROG_INVY_SLOTS,
"money bar", _("money bar"))),
- mArrowsBar(createBar(0, 50, 20, Theme::PROG_INVY_SLOTS,
+ mArrowsBar(createBar(0, 50, 0, Theme::PROG_INVY_SLOTS,
"arrows bar", _("arrows bar"))),
- mStatusBar(createBar(100, 165, 20, Theme::PROG_EXP,
+ mStatusBar(createBar(100, 165, 0, Theme::PROG_EXP,
"status bar", _("status bar"))),
mTextPopup(new TextPopup),
mStatusPopup(new StatusPopup)
@@ -87,7 +87,7 @@ MiniStatusWindow::MiniStatusWindow() :
if (job)
{
- mJobBar = createBar(0, 100, 20, Theme::PROG_JOB, "job bar",
+ mJobBar = createBar(0, 100, 0, Theme::PROG_JOB, "job bar",
_("job bar"));
StatusWindow::updateJobBar(mJobBar);
}
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index e3316486f..78282ec46 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -629,13 +629,6 @@ void SkillInfo::draw(Graphics *const graphics, const int y, const int width)
}
graphics->drawText(skillLevel, width - skillLevelWidth, y);
-
- if (!skillExp.empty())
- {
- gcn::Rectangle rect(33, y + 15, width - 33, 17);
-
- ProgressBar::render(graphics, rect, color, progress, skillExp);
- }
}
SkillInfo* SkillDialog::getSkill(int id)
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index eaeefcf78..0fed5da50 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -237,7 +237,7 @@ SpecialEntry::SpecialEntry(SpecialInfo *info) :
progress = static_cast<float>(info->rechargeCurrent)
/ static_cast<float>(info->rechargeNeeded);
}
- mRechargeBar = new ProgressBar(progress, 100, 10, Theme::PROG_MP);
+ mRechargeBar = new ProgressBar(progress, 100, 0, Theme::PROG_MP);
mRechargeBar->setSmoothProgress(false);
mRechargeBar->setPosition(0, 13);
add(mRechargeBar);
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 2a8c39240..08efc3efa 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -165,13 +165,13 @@ StatusWindow::StatusWindow() :
mHpBar = new ProgressBar(max ?
static_cast<float>(PlayerInfo::getAttribute(PlayerInfo::HP))
/ static_cast<float>(max):
- static_cast<float>(0), 80, 15, Theme::PROG_HP);
+ static_cast<float>(0), 80, 0, Theme::PROG_HP);
max = PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED);
mXpBar = new ProgressBar(max ?
static_cast<float>(PlayerInfo::getAttribute(PlayerInfo::EXP))
/ static_cast<float>(max):
- static_cast<float>(0), 80, 15, Theme::PROG_EXP);
+ static_cast<float>(0), 80, 0, Theme::PROG_EXP);
const bool magicBar = Net::getGameHandler()->canUseMagicBar();
const int job = Net::getPlayerHandler()->getJobLocation()
@@ -184,7 +184,7 @@ StatusWindow::StatusWindow() :
mMpBar = new ProgressBar(max ? static_cast<float>(
PlayerInfo::getAttribute(PlayerInfo::MAX_MP))
/ static_cast<float>(max) : static_cast<float>(0),
- 80, 15, Net::getPlayerHandler()->canUseMagic() ?
+ 80, 0, Net::getPlayerHandler()->canUseMagic() ?
Theme::PROG_MP : Theme::PROG_NO_MP);
}
else
@@ -214,7 +214,7 @@ StatusWindow::StatusWindow() :
{
mJobLvlLabel = new Label(strprintf(_("Job: %d"), 0));
mJobLabel = new Label(_("Job:"));
- mJobBar = new ProgressBar(0.0f, 80, 15, Theme::PROG_JOB);
+ mJobBar = new ProgressBar(0.0f, 80, 0, Theme::PROG_JOB);
place(5, 0, mJobLvlLabel, 3);
place(5, 2, mJobLabel).setPadding(3);
diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp
index 83b0756c9..23c51c109 100644
--- a/src/gui/updaterwindow.cpp
+++ b/src/gui/updaterwindow.cpp
@@ -159,7 +159,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost,
mLabel(new Label(_("Connecting..."))),
mCancelButton(new Button(_("Cancel"), "cancel", this)),
mPlayButton(new Button(_("Play"), "play", this)),
- mProgressBar(new ProgressBar(0.0, 310, 20)),
+ mProgressBar(new ProgressBar(0.0, 310, 0)),
mBrowserBox(new BrowserBox),
mScrollArea(new ScrollArea(mBrowserBox, true, "update_background.xml")),
mUpdateServerPath(mUpdateHost)
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index c85eb6220..6dc6346b8 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -37,7 +37,6 @@
#include "debug.h"
-ImageRect ProgressBar::mBorder;
int ProgressBar::mInstances = 0;
float ProgressBar::mAlpha = 1.0;
@@ -52,7 +51,9 @@ ProgressBar::ProgressBar(float progress,
mProgressPalette(color),
mSmoothColorChange(true),
mVertexes(new GraphicsVertexes()),
- mRedraw(true)
+ mRedraw(true),
+ mPadding(2),
+ mFillPadding(3)
{
// The progress value is directly set at load time:
if (progress > 1.0f || progress < 0.0f)
@@ -63,13 +64,12 @@ ProgressBar::ProgressBar(float progress,
addWidgetListener(this);
setSize(width, height);
- if (mInstances == 0)
+ if (Theme::instance())
{
- for (int f = 0; f < 9; f ++)
- mBorder.grid[f] = nullptr;
-
- if (Theme::instance())
- Theme::instance()->loadRect(mBorder, "progressbar.xml", "");
+ mSkin = Theme::instance()->load("progressbar.xml", "");
+ setPadding(mSkin->getPadding());
+ mFillPadding = mSkin->getOption("fillPadding");
+ setHeight(2 * mPadding + getFont()->getHeight() + 2);
}
mInstances++;
@@ -78,9 +78,11 @@ ProgressBar::ProgressBar(float progress,
ProgressBar::~ProgressBar()
{
mInstances--;
- if (mInstances == 0 && Theme::instance())
+ if (mSkin)
{
- Theme::instance()->unloadRect(mBorder);
+ if (Theme::instance())
+ Theme::instance()->unload(mSkin);
+ mSkin = nullptr;
}
delete mVertexes;
mVertexes = nullptr;
@@ -123,11 +125,14 @@ void ProgressBar::updateAlpha()
if (mAlpha != alpha)
{
mAlpha = alpha;
+/*
+ ImageRect &rect = mSkin->getBorder();
for (int i = 0; i < 9; i++)
{
- if (mBorder.grid[i])
- mBorder.grid[i]->setAlpha(mAlpha);
+ if (rect.grid[i])
+ rect.grid[i]->setAlpha(mAlpha);
}
+*/
}
}
@@ -138,12 +143,7 @@ void ProgressBar::draw(gcn::Graphics *graphics)
mColor.a = static_cast<int>(mAlpha * 255);
- gcn::Rectangle rect = getDimension();
- rect.x = 0;
- rect.y = 0;
-
- render(static_cast<Graphics*>(graphics), rect, mColor,
- mProgress, mText, mVertexes, &mRedraw);
+ render(static_cast<Graphics*>(graphics));
}
void ProgressBar::setProgress(const float progress)
@@ -175,73 +175,46 @@ void ProgressBar::setColor(const gcn::Color &color)
mColor = color;
}
-void ProgressBar::render(Graphics *graphics, const gcn::Rectangle &area,
- const gcn::Color &color, const float progress,
- const std::string &text, GraphicsVertexes *const vert,
- bool *const redraw)
+void ProgressBar::render(Graphics *graphics)
{
+ if (!mSkin)
+ return;
+
gcn::Font *const oldFont = graphics->getFont();
const gcn::Color oldColor = graphics->getColor();
- if (*redraw || graphics->getRedraw())
+ if (mRedraw || graphics->getRedraw())
{
- *redraw = false;
- graphics->calcWindow(vert, area.x, area.y,
- area.width, area.height, mBorder);
+ mRedraw = false;
+ graphics->calcWindow(mVertexes, 0, 0,
+ mDimension.width, mDimension.height, mSkin->getBorder());
}
- graphics->drawImageRect2(vert, mBorder);
+ graphics->drawImageRect2(mVertexes, mSkin->getBorder());
// The bar
- if (progress > 0)
+ if (mProgress > 0)
{
- graphics->setColor(color);
- graphics->fillRectangle(gcn::Rectangle(area.x + 4, area.y + 4,
- static_cast<int>(progress * static_cast<float>(area.width - 8)),
- area.height - 8));
- }
-
- // The label
- if (!text.empty())
- {
- const int textX = area.x + area.width / 2;
- const int textY = area.y + (area.height - boldFont->getHeight()) / 2;
-
- TextRenderer::renderText(graphics, text, textX, textY,
- gcn::Graphics::CENTER,
- Theme::getThemeColor(Theme::PROGRESS_BAR),
- gui->getFont(), true, false);
- }
-
- graphics->setFont(oldFont);
- graphics->setColor(oldColor);
-}
-
-void ProgressBar::render(Graphics *graphics, const gcn::Rectangle &area,
- const gcn::Color &color, const float progress,
- const std::string &text)
-{
- gcn::Font *const oldFont = graphics->getFont();
- const gcn::Color oldColor = graphics->getColor();
-
- graphics->drawImageRect(area, mBorder);
-
- // The bar
- if (progress > 0)
- {
- graphics->setColor(color);
- graphics->fillRectangle(gcn::Rectangle(area.x + 4, area.y + 4,
- static_cast<int>(progress * static_cast<float>(area.width - 8)),
- area.height - 8));
+ graphics->setColor(mColor);
+ const unsigned int pad = 2 * mFillPadding;
+ const int maxWidth = mDimension.width - pad;
+ int width = static_cast<int>(mProgress * static_cast<float>(maxWidth));
+ if (width > 0)
+ {
+ if (width > maxWidth)
+ width = maxWidth;
+ graphics->fillRectangle(gcn::Rectangle(mFillPadding, mFillPadding,
+ width, mDimension.height - pad));
+ }
}
// The label
- if (!text.empty())
+ if (!mText.empty())
{
- const int textX = area.x + area.width / 2;
- const int textY = area.y + (area.height - boldFont->getHeight()) / 2;
+ const int textX = mDimension.width / 2;
+ const int textY = (mDimension.height - boldFont->getHeight()) / 2;
- TextRenderer::renderText(graphics, text, textX, textY,
+ TextRenderer::renderText(graphics, mText, textX, textY,
gcn::Graphics::CENTER,
Theme::getThemeColor(Theme::PROGRESS_BAR),
gui->getFont(), true, false);
diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h
index e163fe66c..3b8b976cf 100644
--- a/src/gui/widgets/progressbar.h
+++ b/src/gui/widgets/progressbar.h
@@ -32,6 +32,7 @@
class Graphics;
class GraphicsVertexes;
class ImageRect;
+class Skin;
/**
* A progress bar.
@@ -120,23 +121,17 @@ class ProgressBar final : public gcn::Widget, public gcn::WidgetListener
/**
* Renders a progressbar with the given properties.
*/
- static void render(Graphics *graphics, const gcn::Rectangle &area,
- const gcn::Color &color, const float progress,
- const std::string &text,
- GraphicsVertexes *const vert, bool *const redraw);
-
- /**
- * Renders a progressbar with the given properties.
- */
- static void render(Graphics *graphics, const gcn::Rectangle &area,
- const gcn::Color &color, const float progress,
- const std::string &text = "");
+ void render(Graphics *graphics);
void widgetResized(const gcn::Event &event) override;
void widgetMoved(const gcn::Event &event) override;
+ void setPadding(unsigned int padding)
+ { mPadding = padding; }
+
private:
+ Skin *mSkin;
float mProgress;
float mProgressToGo;
bool mSmoothProgress;
@@ -149,8 +144,9 @@ class ProgressBar final : public gcn::Widget, public gcn::WidgetListener
std::string mText;
GraphicsVertexes *mVertexes;
bool mRedraw;
+ unsigned int mPadding;
+ unsigned int mFillPadding;
- static ImageRect mBorder;
static int mInstances;
static float mAlpha;