ManaPlus
progressbar.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef GUI_WIDGETS_PROGRESSBAR_H
25 #define GUI_WIDGETS_PROGRESSBAR_H
26 
27 #include "gui/fonts/textchunk.h"
28 
29 #include "gui/widgets/widget.h"
30 
32 
33 #include "resources/imagerect.h"
34 
35 #include "localconsts.h"
36 
37 class ImageCollection;
38 class Skin;
39 
45 class ProgressBar final : public Widget,
46  public WidgetListener
47 {
48  public:
52  ProgressBar(const Widget2 *const widget,
53  float progress,
54  const int width,
55  const int height,
56  const ProgressColorIdT backColor,
57  const std::string &skin,
58  const std::string &skinFill);
59 
61 
62  ~ProgressBar() override final;
63 
67  void logic() override final;
68 
72  void updateAlpha();
73 
77  void draw(Graphics *const graphics) override final A_NONNULL(2);
78 
79  void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
80 
84  void setProgress(const float progress);
85 
90  { return mProgress; }
91 
96  void setProgressPalette(const ProgressColorIdT progressPalette);
97 
101  void setBackgroundColor(const Color &color);
102 
103  void setColor(const Color &color1, const Color &color2);
104 
109  { return mBackgroundColor; }
110 
114  void setText(const std::string &str);
115 
119  const std::string &text() const noexcept2 A_WARN_UNUSED
120  { return mText; }
121 
125  void setSmoothProgress(bool smoothProgress) noexcept2
126  { mSmoothProgress = smoothProgress; }
127 
131  void setSmoothColorChange(bool smoothColorChange) noexcept2
132  { mSmoothColorChange = smoothColorChange; }
133 
134  void widgetResized(const Event &event) override final;
135 
136  void widgetMoved(const Event &event) override final;
137 
138  void widgetHidden(const Event &event) override final;
139 
140  void setPadding(unsigned int padding) noexcept2
141  { mPadding = padding; }
142 
143  private:
147  float mProgress;
149 
151 
152  std::string mText;
155  unsigned int mPadding;
156  unsigned int mFillPadding;
157 
158  static int mInstances;
159  static float mAlpha;
160 
165 };
166 
167 #endif // GUI_WIDGETS_PROGRESSBAR_H
Definition: color.h:76
Definition: event.h:79
unsigned int mFillPadding
Definition: progressbar.h:156
void widgetMoved(const Event &event)
void draw(Graphics *const graphics)
void setProgress(const float progress)
void setSmoothColorChange(bool smoothColorChange)
Definition: progressbar.h:131
bool mTextChanged
Definition: progressbar.h:164
static float mAlpha
Definition: progressbar.h:159
Skin * mSkin
Definition: progressbar.h:146
void setPadding(unsigned int padding)
Definition: progressbar.h:140
float mProgress
Definition: progressbar.h:147
const Color & getBackgroundColor() const
Definition: progressbar.h:108
void setColor(const Color &color1, const Color &color2)
const std::string & text() const
Definition: progressbar.h:119
void widgetHidden(const Event &event)
static int mInstances
Definition: progressbar.h:158
std::string mText
Definition: progressbar.h:152
float mProgressToGo
Definition: progressbar.h:148
void setSmoothProgress(bool smoothProgress)
Definition: progressbar.h:125
void setBackgroundColor(const Color &color)
void setProgressPalette(const ProgressColorIdT progressPalette)
ProgressBar(const Widget2 *const widget, float progress, const int width, const int height, const ProgressColorIdT backColor, const std::string &skin, const std::string &skinFill)
Definition: progressbar.cpp:44
bool mSmoothProgress
Definition: progressbar.h:162
float getProgress() const
Definition: progressbar.h:89
ImageCollection * mVertexes
Definition: progressbar.h:153
void widgetResized(const Event &event)
bool mSmoothColorChange
Definition: progressbar.h:163
TextChunk mTextChunk
Definition: progressbar.h:145
Color mBackgroundColorToGo
Definition: progressbar.h:150
void safeDraw(Graphics *const graphics)
unsigned int mPadding
Definition: progressbar.h:155
void updateAlpha()
void setText(const std::string &str)
bool mFillImage
Definition: progressbar.h:161
ImageRect mFillRect
Definition: progressbar.h:144
ProgressColorIdT mProgressPalette
Definition: progressbar.h:154
Definition: skin.h:37
Definition: widget.h:99
Color mBackgroundColor
Definition: widget.h:1091
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define A_NONNULL(...)
Definition: localconsts.h:168
#define A_NONNULLPOINTER
Definition: localconsts.h:266
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
ProgressColorId ::T ProgressColorIdT