ManaPlus
Public Member Functions | Private Attributes | Static Private Attributes
ProgressBar Class Reference

#include <progressbar.h>

Inheritance diagram for ProgressBar:
Widget WidgetListener Widget2

Public Member Functions

 ProgressBar (const Widget2 *const widget, float progress, const int width, const int height, const ProgressColorIdT backColor, const std::string &skin, const std::string &skinFill)
 
 ~ProgressBar ()
 
void logic ()
 
void updateAlpha ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void setProgress (const float progress)
 
float getProgress () const
 
void setProgressPalette (const ProgressColorIdT progressPalette)
 
void setBackgroundColor (const Color &color)
 
void setColor (const Color &color1, const Color &color2)
 
const ColorgetBackgroundColor () const
 
void setText (const std::string &str)
 
const std::string & text () const
 
void setSmoothProgress (bool smoothProgress)
 
void setSmoothColorChange (bool smoothColorChange)
 
void widgetResized (const Event &event)
 
void widgetMoved (const Event &event)
 
void widgetHidden (const Event &event)
 
void setPadding (unsigned int padding)
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
virtual void setFocusHandler (FocusHandler *const focusHandler)
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
virtual void setParent (Widget *parent)
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
virtual WidgetgetWidgetAt (int x, int y)
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual Rect getChildrenArea ()
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
virtual void moveToTop (Widget *widget)
 
virtual void moveToBottom (Widget *widget)
 
virtual void focusNext ()
 
virtual void focusPrevious ()
 
virtual void showWidgetPart (Widget *const widget, const Rect &area)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
virtual void postInit ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetShown (const Event &event)
 

Private Attributes

ImageRect mFillRect
 
TextChunk mTextChunk
 
SkinmSkin
 
float mProgress
 
float mProgressToGo
 
Color mBackgroundColorToGo
 
std::string mText
 
ImageCollectionmVertexes
 
ProgressColorIdT mProgressPalette
 
unsigned int mPadding
 
unsigned int mFillPadding
 
bool mFillImage
 
bool mSmoothProgress
 
bool mSmoothColorChange
 
bool mTextChanged
 

Static Private Attributes

static int mInstances = 0
 
static float mAlpha = 1.0
 

Additional Inherited Members

- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 
- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

A progress bar.

Definition at line 45 of file progressbar.h.

Constructor & Destructor Documentation

◆ ProgressBar()

ProgressBar::ProgressBar ( const Widget2 *const  widget,
float  progress,
const int  width,
const int  height,
const ProgressColorIdT  backColor,
const std::string &  skin,
const std::string &  skinFill 
)

Constructor, initializes the progress with the given value.

Definition at line 44 of file progressbar.cpp.

50  :
51  Widget(widget),
53  mFillRect(),
54  mTextChunk(),
55  mSkin(nullptr),
56  mProgress(progress),
57  mProgressToGo(progress),
59  mText(),
61  mProgressPalette(backColor),
62  mPadding(2),
63  mFillPadding(3),
64  mFillImage(false),
65  mSmoothProgress(true),
66  mSmoothColorChange(true),
67  mTextChanged(true)
68 {
70  backColor >= ProgressColorId::PROG_HP
71  ? backColor : ProgressColorId::PROG_HP,
72  mProgress);
74  mForegroundColor2 = getThemeColor(ThemeColorId::PROGRESS_BAR_OUTLINE,
75  255U);
76 
77  // The progress value is directly set at load time:
78  if (mProgress > 1.0F || mProgress < 0.0F)
79  mProgress = 1.0F;
80 
81  mForegroundColor = getThemeColor(ThemeColorId::PROGRESS_BAR, 255U);
82  addWidgetListener(this);
83  setSize(width, height);
84 
85  if (theme != nullptr)
86  {
87  mSkin = theme->load(skin,
88  "progressbar.xml",
89  true,
91  if (mSkin != nullptr)
92  {
94  mFillPadding = mSkin->getOption("fillPadding");
95  mFillImage = mSkin->getOption("fillImage") != 0;
96  if (mFillImage)
97  {
99  skinFill,
100  "progressbar_fill.xml",
101  0,
102  8);
103  }
104  }
105  setHeight(2 * mPadding + getFont()->getHeight() + 2);
106  }
107 
108  mInstances++;
109 }
unsigned int mFillPadding
Definition: progressbar.h:156
bool mTextChanged
Definition: progressbar.h:164
Skin * mSkin
Definition: progressbar.h:146
void setPadding(unsigned int padding)
Definition: progressbar.h:140
float mProgress
Definition: progressbar.h:147
static int mInstances
Definition: progressbar.h:158
std::string mText
Definition: progressbar.h:152
float mProgressToGo
Definition: progressbar.h:148
bool mSmoothProgress
Definition: progressbar.h:162
ImageCollection * mVertexes
Definition: progressbar.h:153
bool mSmoothColorChange
Definition: progressbar.h:163
TextChunk mTextChunk
Definition: progressbar.h:145
Color mBackgroundColorToGo
Definition: progressbar.h:150
unsigned int mPadding
Definition: progressbar.h:155
bool mFillImage
Definition: progressbar.h:161
ImageRect mFillRect
Definition: progressbar.h:144
ProgressColorIdT mProgressPalette
Definition: progressbar.h:154
int getOption(const std::string &name) const
Definition: skin.h:106
int getPadding() const
Definition: skin.h:100
static std::string getThemePath()
Definition: theme.h:67
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:179
void loadRect(ImageRect &image, const std::string &name, const std::string &name2, const int start, const int end)
Definition: theme.cpp:883
static Color getProgressColor(const ProgressColorIdT type, const float progress)
Definition: theme.cpp:155
Color mForegroundColor2
Definition: widget2.h:113
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:45
Color mForegroundColor
Definition: widget.h:1086
void setSize(const int width, const int height)
Definition: widget.cpp:367
Widget(const Widget2 *const widget)
Definition: widget.cpp:85
Color mBackgroundColor
Definition: widget.h:1091
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:302
void setHeight(const int height)
Definition: widget.cpp:140
Font * getFont() const
Definition: widget.cpp:331
int getHeight() const
Definition: widget.h:240
Theme * theme
Definition: theme.cpp:62

References Widget::addWidgetListener(), Widget::getFont(), Widget::getHeight(), Skin::getOption(), Skin::getPadding(), Theme::getProgressColor(), Widget2::getThemeColor(), Theme::getThemePath(), Theme::load(), Theme::loadRect(), Widget::mBackgroundColor, mBackgroundColorToGo, mFillImage, mFillPadding, mFillRect, Widget::mForegroundColor, Widget2::mForegroundColor2, mInstances, mPadding, mProgress, mSkin, ProgressColorId::PROG_HP, Widget::setHeight(), setPadding(), Widget::setSize(), and theme.

◆ ~ProgressBar()

ProgressBar::~ProgressBar ( )

Definition at line 111 of file progressbar.cpp.

112 {
113  if (gui != nullptr)
114  gui->removeDragged(this);
115 
116  mInstances--;
117  if (mSkin != nullptr)
118  {
119  if (theme != nullptr)
120  theme->unload(mSkin);
121  mSkin = nullptr;
122  }
126 }
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1162
void deleteImage()
Definition: textchunk.cpp:193
void unload(Skin *const skin)
Definition: theme.cpp:250
static void unloadRect(const ImageRect &rect, const int start, const int end)
Definition: theme.cpp:915
#define delete2(var)
Definition: delete2.h:25
Gui * gui
Definition: gui.cpp:111

References delete2, TextChunk::deleteImage(), gui, mFillRect, mInstances, mSkin, mTextChunk, mVertexes, Gui::removeDragged(), theme, Theme::unload(), and Theme::unloadRect().

Member Function Documentation

◆ draw()

void ProgressBar::draw ( Graphics *const  graphics)
virtual

Draws the progress bar.

Implements Widget.

Definition at line 168 of file progressbar.cpp.

169 {
170  BLOCK_START("ProgressBar::draw")
171  if (mSkin == nullptr)
172  {
173  BLOCK_END("ProgressBar::draw")
174  return;
175  }
176 
177  updateAlpha();
178  mBackgroundColor.a = CAST_U32(mAlpha * 255);
179 
180  if (mRedraw || graphics->getRedraw())
181  {
182  mRedraw = false;
183  mVertexes->clear();
184  graphics->calcWindow(mVertexes, 0, 0,
186  if (mFillImage)
187  {
188  const unsigned int pad = 2 * mFillPadding;
189  const int maxWidth = mDimension.width - pad;
190  int width = CAST_S32(mProgress
191  * static_cast<float>(maxWidth));
192  if (width > 0)
193  {
194  if (width > maxWidth)
195  width = maxWidth;
197  width, mDimension.height - pad, mFillRect);
198  }
199  }
200  graphics->finalize(mVertexes);
201  }
202 
203  graphics->drawTileCollection(mVertexes);
204 
205  // The bar
206  if (!mFillImage && mProgress > 0)
207  {
208  graphics->setColor(mBackgroundColor);
209  const unsigned int pad = 2 * mFillPadding;
210  const int maxWidth = mDimension.width - pad;
211  int width = CAST_S32(mProgress * static_cast<float>(maxWidth));
212  if (width > 0)
213  {
214  if (width > maxWidth)
215  width = maxWidth;
217  width, mDimension.height - pad));
218  }
219  }
220 
221  // The label
222  if (!mText.empty())
223  {
224  Font *const font = gui->getFont();
225  if (mTextChanged)
226  {
227  mTextChunk.textFont = font;
232  font->generate(mTextChunk);
233  mTextChanged = false;
234  }
235 
236  const Image *const image = mTextChunk.img;
237  if (image != nullptr)
238  {
239  const int textX = (mDimension.width - font->getWidth(mText)) / 2;
240  const int textY = (mDimension.height - font->getHeight()) / 2;
241  graphics->drawImage(image, textX, textY);
242  }
243  }
244  BLOCK_END("ProgressBar::draw")
245 }
#define CAST_S32
Definition: cast.h:30
#define CAST_U32
Definition: cast.h:31
Definition: font.h:90
int getHeight() const
Definition: font.cpp:362
void generate(TextChunk &chunk)
Definition: font.cpp:430
int getWidth(const std::string &text) const
Definition: font.cpp:334
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
virtual void fillRectangle(const Rect &rectangle)=0
virtual void setColor(const Color &color)
Definition: graphics.h:320
virtual void finalize(ImageCollection *const col)
Definition: graphics.h:465
virtual void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
Font * getFont() const
Definition: gui.h:160
static float mAlpha
Definition: progressbar.h:159
void updateAlpha()
Definition: rect.h:74
int width
Definition: rect.h:219
int height
Definition: rect.h:224
const ImageRect & getBorder() const
Definition: skin.h:68
Font * textFont
Definition: textchunk.h:64
Image * img
Definition: textchunk.h:63
Color color
Definition: textchunk.h:66
Color color2
Definition: textchunk.h:67
std::string text
Definition: textchunk.h:65
Rect mDimension
Definition: widget.h:1101
bool mRedraw
Definition: widget.h:1164
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

References Color::a, BLOCK_END, BLOCK_START, Graphics::calcWindow(), CAST_S32, CAST_U32, ImageCollection::clear(), TextChunk::color, TextChunk::color2, TextChunk::deleteImage(), Graphics::drawImage(), Graphics::drawTileCollection(), Graphics::fillRectangle(), Graphics::finalize(), Font::generate(), Skin::getBorder(), Gui::getFont(), Font::getHeight(), Graphics::getRedraw(), Font::getWidth(), gui, Rect::height, TextChunk::img, mAlpha, Widget::mBackgroundColor, Widget::mDimension, mFillImage, mFillPadding, mFillRect, Widget::mForegroundColor, Widget2::mForegroundColor2, mProgress, Widget::mRedraw, mSkin, mText, mTextChanged, mTextChunk, mVertexes, Graphics::setColor(), TextChunk::text, TextChunk::textFont, updateAlpha(), and Rect::width.

◆ getBackgroundColor()

const Color& ProgressBar::getBackgroundColor ( ) const
inline

Returns the color of the progress bar.

Definition at line 108 of file progressbar.h.

109  { return mBackgroundColor; }

References Widget::mBackgroundColor.

◆ getProgress()

float ProgressBar::getProgress ( ) const
inline

Returns the current progress.

Definition at line 89 of file progressbar.h.

90  { return mProgress; }

References mProgress.

◆ logic()

void ProgressBar::logic ( )
virtual

Performs progress bar logic (fading colors)

Reimplemented from Widget.

Definition at line 128 of file progressbar.cpp.

129 {
130  BLOCK_START("ProgressBar::logic")
132  {
133  // Smoothly changing the color for a nicer effect.
146  mRedraw = true;
147  }
148 
150  {
151  // Smoothly showing the progressbar changes.
152  if (mProgressToGo > mProgress)
153  mProgress = std::min(1.0F, mProgress + 0.005F);
154  if (mProgressToGo < mProgress)
155  mProgress = std::max(0.0F, mProgress - 0.005F);
156  mRedraw = true;
157  }
158  BLOCK_END("ProgressBar::logic")
159 }
unsigned int b
Definition: color.h:245
unsigned int r
Definition: color.h:235
unsigned int g
Definition: color.h:240

References Color::b, BLOCK_END, BLOCK_START, Color::g, Widget::mBackgroundColor, mBackgroundColorToGo, mProgress, mProgressToGo, Widget::mRedraw, mSmoothColorChange, mSmoothProgress, and Color::r.

◆ safeDraw()

void ProgressBar::safeDraw ( Graphics *const  graphics)
virtual

Implements Widget.

Definition at line 247 of file progressbar.cpp.

248 {
249  BLOCK_START("ProgressBar::safeDraw")
250  if (mSkin == nullptr)
251  {
252  BLOCK_END("ProgressBar::safeDraw")
253  return;
254  }
255 
256  updateAlpha();
257  mBackgroundColor.a = CAST_U32(mAlpha * 255);
258 
259  graphics->drawImageRect(0, 0, mDimension.width, mDimension.height,
260  mSkin->getBorder());
261  if (mFillImage)
262  {
263  const unsigned int pad = 2 * mFillPadding;
264  const int maxWidth = mDimension.width - pad;
265  int width = CAST_S32(mProgress
266  * static_cast<float>(maxWidth));
267  if (width > 0)
268  {
269  if (width > maxWidth)
270  width = maxWidth;
272  width, mDimension.height - pad, mFillRect);
273  }
274  }
275 
276  // The bar
277  if (!mFillImage && mProgress > 0)
278  {
279  graphics->setColor(mBackgroundColor);
280  const unsigned int pad = 2 * mFillPadding;
281  const int maxWidth = mDimension.width - pad;
282  int width = CAST_S32(mProgress * static_cast<float>(maxWidth));
283  if (width > 0)
284  {
285  if (width > maxWidth)
286  width = maxWidth;
288  width, mDimension.height - pad));
289  }
290  }
291 
292  // The label
293  if (!mText.empty())
294  {
295  Font *const font = gui->getFont();
296  if (mTextChanged)
297  {
298  mTextChunk.textFont = font;
303  font->generate(mTextChunk);
304  mTextChanged = false;
305  }
306 
307  const Image *const image = mTextChunk.img;
308  if (image != nullptr)
309  {
310  const int textX = (mDimension.width - font->getWidth(mText)) / 2;
311  const int textY = (mDimension.height - font->getHeight()) / 2;
312  graphics->drawImage(image, textX, textY);
313  }
314  }
315  BLOCK_END("ProgressBar::safeDraw")
316 }
virtual void drawImageRect(const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
void drawImageRect(int x, int y, int w, int h, const ImageRect &restrict imgRect) restrict2 override final

References Color::a, BLOCK_END, BLOCK_START, CAST_S32, CAST_U32, TextChunk::color, TextChunk::color2, TextChunk::deleteImage(), Graphics::drawImage(), Graphics::drawImageRect(), Graphics::fillRectangle(), Font::generate(), Skin::getBorder(), Gui::getFont(), Font::getHeight(), Font::getWidth(), gui, Rect::height, TextChunk::img, mAlpha, Widget::mBackgroundColor, Widget::mDimension, mFillImage, mFillPadding, mFillRect, Widget::mForegroundColor, Widget2::mForegroundColor2, mProgress, mSkin, mText, mTextChanged, mTextChunk, Graphics::setColor(), TextChunk::text, TextChunk::textFont, updateAlpha(), and Rect::width.

◆ setBackgroundColor()

void ProgressBar::setBackgroundColor ( const Color color)

Change the color of the progress bar.

Definition at line 348 of file progressbar.cpp.

349 {
350  mRedraw = true;
351  mBackgroundColorToGo = color;
352 
353  if (!mSmoothColorChange)
354  mBackgroundColor = color;
355 }

References Widget::mBackgroundColor, mBackgroundColorToGo, Widget::mRedraw, and mSmoothColorChange.

Referenced by StatusWindow::updateStatusBar().

◆ setColor()

void ProgressBar::setColor ( const Color color1,
const Color color2 
)

◆ setPadding()

void ProgressBar::setPadding ( unsigned int  padding)
inline

Definition at line 140 of file progressbar.h.

141  { mPadding = padding; }

References mPadding.

Referenced by ProgressBar().

◆ setProgress()

void ProgressBar::setProgress ( const float  progress)

◆ setProgressPalette()

void ProgressBar::setProgressPalette ( const ProgressColorIdT  progressPalette)

Change the ProgressPalette for this ProgressBar to follow or -1 to disable this and manage color manually.

Definition at line 334 of file progressbar.cpp.

335 {
336  const ProgressColorIdT oldPalette = mProgressPalette;
337  mProgressPalette = progressPalette;
338  mRedraw = true;
339 
340  if (mProgressPalette != oldPalette &&
342  {
345  }
346 }
ProgressColorId ::T ProgressColorIdT

References Theme::getProgressColor(), mBackgroundColorToGo, mProgressPalette, mProgressToGo, Widget::mRedraw, and ProgressColorId::PROG_HP.

Referenced by StatusWindow::updateMPBar().

◆ setSmoothColorChange()

void ProgressBar::setSmoothColorChange ( bool  smoothColorChange)
inline

Set whether the color changing is made smoothly.

Definition at line 131 of file progressbar.h.

132  { mSmoothColorChange = smoothColorChange; }

References mSmoothColorChange.

◆ setSmoothProgress()

void ProgressBar::setSmoothProgress ( bool  smoothProgress)
inline

Set whether the progress is moved smoothly.

Definition at line 125 of file progressbar.h.

126  { mSmoothProgress = smoothProgress; }

References mSmoothProgress.

Referenced by UpdaterWindow::UpdaterWindow().

◆ setText()

void ProgressBar::setText ( const std::string &  str)

◆ text()

const std::string& ProgressBar::text ( ) const
inline

Returns the text shown on the progress bar.

Definition at line 119 of file progressbar.h.

120  { return mText; }

References mText.

Referenced by PopupMenu::showPopup().

◆ updateAlpha()

void ProgressBar::updateAlpha ( )

Update the alpha value to the graphic components.

Definition at line 161 of file progressbar.cpp.

162 {
163  const float alpha = std::max(settings.guiAlpha,
165  mAlpha = alpha;
166 }
float guiAlpha
Definition: settings.h:131
float getMinimumOpacity() const
Definition: theme.h:124
Settings settings
Definition: settings.cpp:32

References Theme::getMinimumOpacity(), Settings::guiAlpha, mAlpha, settings, and theme.

Referenced by draw(), and safeDraw().

◆ widgetHidden()

void ProgressBar::widgetHidden ( const Event event)
virtual

Invoked when a widget is hidden, i.e it's set to be not visible.

Parameters
eventDescribes the event.

Reimplemented from WidgetListener.

Definition at line 383 of file progressbar.cpp.

384 {
385  mTextChanged = true;
387 }

References TextChunk::deleteImage(), mTextChanged, and mTextChunk.

◆ widgetMoved()

void ProgressBar::widgetMoved ( const Event event)
virtual

Invoked when a widget is moved.

Parameters
eventDescribes the event.

Reimplemented from WidgetListener.

Definition at line 369 of file progressbar.cpp.

370 {
371  mRedraw = true;
372 }

References Widget::mRedraw.

◆ widgetResized()

void ProgressBar::widgetResized ( const Event event)
virtual

Invoked when a widget changes its size.

Parameters
eventDescribes the event.

Reimplemented from WidgetListener.

Definition at line 364 of file progressbar.cpp.

365 {
366  mRedraw = true;
367 }

References Widget::mRedraw.

Field Documentation

◆ mAlpha

float ProgressBar::mAlpha = 1.0
staticprivate

Definition at line 159 of file progressbar.h.

Referenced by draw(), safeDraw(), and updateAlpha().

◆ mBackgroundColorToGo

Color ProgressBar::mBackgroundColorToGo
private

◆ mFillImage

bool ProgressBar::mFillImage
private

Definition at line 161 of file progressbar.h.

Referenced by draw(), ProgressBar(), and safeDraw().

◆ mFillPadding

unsigned int ProgressBar::mFillPadding
private

Definition at line 156 of file progressbar.h.

Referenced by draw(), ProgressBar(), and safeDraw().

◆ mFillRect

ImageRect ProgressBar::mFillRect
private

Definition at line 144 of file progressbar.h.

Referenced by draw(), ProgressBar(), safeDraw(), and ~ProgressBar().

◆ mInstances

int ProgressBar::mInstances = 0
staticprivate

Definition at line 158 of file progressbar.h.

Referenced by ProgressBar(), and ~ProgressBar().

◆ mPadding

unsigned int ProgressBar::mPadding
private

Definition at line 155 of file progressbar.h.

Referenced by ProgressBar(), and setPadding().

◆ mProgress

float ProgressBar::mProgress
private

Definition at line 147 of file progressbar.h.

Referenced by draw(), getProgress(), logic(), ProgressBar(), safeDraw(), and setProgress().

◆ mProgressPalette

ProgressColorIdT ProgressBar::mProgressPalette
private

Definition at line 154 of file progressbar.h.

Referenced by setProgress(), and setProgressPalette().

◆ mProgressToGo

float ProgressBar::mProgressToGo
private

Definition at line 148 of file progressbar.h.

Referenced by logic(), setProgress(), and setProgressPalette().

◆ mSkin

Skin* ProgressBar::mSkin
private

Definition at line 146 of file progressbar.h.

Referenced by draw(), ProgressBar(), safeDraw(), and ~ProgressBar().

◆ mSmoothColorChange

bool ProgressBar::mSmoothColorChange
private

Definition at line 163 of file progressbar.h.

Referenced by logic(), setBackgroundColor(), and setSmoothColorChange().

◆ mSmoothProgress

bool ProgressBar::mSmoothProgress
private

Definition at line 162 of file progressbar.h.

Referenced by logic(), setProgress(), and setSmoothProgress().

◆ mText

std::string ProgressBar::mText
private

Definition at line 152 of file progressbar.h.

Referenced by draw(), safeDraw(), setText(), and text().

◆ mTextChanged

bool ProgressBar::mTextChanged
private

Definition at line 164 of file progressbar.h.

Referenced by draw(), safeDraw(), setColor(), setText(), and widgetHidden().

◆ mTextChunk

TextChunk ProgressBar::mTextChunk
private

Definition at line 145 of file progressbar.h.

Referenced by draw(), safeDraw(), widgetHidden(), and ~ProgressBar().

◆ mVertexes

ImageCollection* ProgressBar::mVertexes
private

Definition at line 153 of file progressbar.h.

Referenced by draw(), and ~ProgressBar().


The documentation for this class was generated from the following files: