Mana
Loading...
Searching...
No Matches
progressbar.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include <guichan/widget.hpp>
25
26#include <string>
27
33class ProgressBar : public gcn::Widget
34{
35 public:
39 ProgressBar(float progress = 0.0f,
40 int width = 40, int height = 7,
41 int color = -1);
42
46 void logic() override;
47
51 void draw(gcn::Graphics *graphics) override;
52
56 void setProgress(float progress);
57
61 float getProgress() const { return mProgress; }
62
67 void setProgressPalette(int progressPalette);
68
72 void setColor(const gcn::Color &color);
73
77 const gcn::Color &getColor() const { return mColor; }
78
82 void setText(const std::string &text)
83 { mText = text; }
84
88 const std::string &text() const
89 { return mText; }
90
94 void setSmoothProgress(bool smoothProgress)
95 { mSmoothProgress = smoothProgress; }
96
100 void setSmoothColorChange(bool smoothColorChange)
101 { mSmoothColorChange = smoothColorChange; }
102
103 private:
105 bool mSmoothProgress = true;
106
108 gcn::Color mColor;
109 gcn::Color mColorToGo;
111
112 std::string mText;
113};
A progress bar.
Definition progressbar.h:34
void setSmoothColorChange(bool smoothColorChange)
Set whether the color changing is made smoothly.
void setProgress(float progress)
Sets the current progress.
const std::string & text() const
Returns the text shown on the progress bar.
Definition progressbar.h:88
void setText(const std::string &text)
Sets the text shown on the progress bar.
Definition progressbar.h:82
gcn::Color mColorToGo
float mProgress
std::string mText
float mProgressToGo
void setColor(const gcn::Color &color)
Change the color of the progress bar.
void draw(gcn::Graphics *graphics) override
Draws the progress bar.
const gcn::Color & getColor() const
Returns the color of the progress bar.
Definition progressbar.h:77
void setProgressPalette(int progressPalette)
Change the ProgressPalette for this ProgressBar to follow or -1 to disable this and manage color manu...
void setSmoothProgress(bool smoothProgress)
Set whether the progress is moved smoothly.
Definition progressbar.h:94
void logic() override
Performs progress bar logic (fading colors)
int mProgressPalette
bool mSmoothProgress
float getProgress() const
Returns the current progress.
Definition progressbar.h:61
bool mSmoothColorChange
gcn::Color mColor
< Entry in ProgressPalette or -1 for none.
Graphics * graphics
Definition client.cpp:104