ManaPlus
Public Member Functions | Private Attributes
ProgressIndicator Class Reference

#include <progressindicator.h>

Inheritance diagram for ProgressIndicator:
Widget Widget2

Public Member Functions

 ProgressIndicator (const Widget2 *const widget)
 
 ~ProgressIndicator ()
 
void logic ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
- 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)
 

Private Attributes

SimpleAnimationmIndicator
 

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 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 widget that indicates progress. Suitable to use instead of a progress bar in cases where it is unknown how long something is going to take.

Definition at line 36 of file progressindicator.h.

Constructor & Destructor Documentation

◆ ProgressIndicator()

ProgressIndicator::ProgressIndicator ( const Widget2 *const  widget)
explicit

Definition at line 36 of file progressindicator.cpp.

36  :
37  Widget(widget),
38  mIndicator(nullptr)
39 {
40  ImageSet *const images = Theme::getImageSetFromTheme(
41  "progress-indicator.png", 32, 32);
42 
43  if (images != nullptr)
44  {
45  Animation *const anim = new Animation("progress indicator");
46  for (ImageSet::size_type i = 0, fsz = images->size();
47  i < fsz;
48  ++i)
49  {
50  anim->addFrame(images->get(i), 100, 0, 0, 100);
51  }
52  mIndicator = new SimpleAnimation(anim);
53  images->decRef();
54  }
55 
56  setSize(32, 32);
57 }
void addFrame(Image *const image, const int delay, const int offsetX, const int offsetY, const int rand)
Definition: animation.cpp:46
Image * get(const size_type i) const
Definition: imageset.cpp:67
size_type size() const
Definition: imageset.h:73
std::vector< Image * >::size_type size_type
Definition: imageset.h:69
SimpleAnimation * mIndicator
virtual void decRef()
Definition: resource.cpp:50
static ImageSet * getImageSetFromTheme(const std::string &path, const int w, const int h)
Definition: theme.cpp:660
void setSize(const int width, const int height)
Definition: widget.cpp:367
Widget(const Widget2 *const widget)
Definition: widget.cpp:85

References Animation::addFrame(), ParticleType::Animation, Resource::decRef(), ImageSet::get(), Theme::getImageSetFromTheme(), mIndicator, Widget::setSize(), and ImageSet::size().

◆ ~ProgressIndicator()

ProgressIndicator::~ProgressIndicator ( )

Definition at line 59 of file progressindicator.cpp.

60 {
61  if (gui != nullptr)
62  gui->removeDragged(this);
63 
65 }
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1162
#define delete2(var)
Definition: delete2.h:25
Gui * gui
Definition: gui.cpp:111

References delete2, gui, mIndicator, and Gui::removeDragged().

Member Function Documentation

◆ draw()

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

Draws the widget. It is called by the parent widget when it is time for the widget to draw itself. The graphics object is set up so that all drawing is relative to the widget, i.e coordinate (0,0) is the top left corner of the widget. It is not possible to draw outside of a widget's dimension.

Parameters
graphicsaA graphics object to draw with.

Implements Widget.

Definition at line 75 of file progressindicator.cpp.

76 {
77  BLOCK_START("ProgressIndicator::draw")
78  if (mIndicator != nullptr)
79  {
80  // Draw the indicator centered on the widget
81  const int x = (mDimension.width - 32) / 2;
82  const int y = (mDimension.height - 32) / 2;
83  mIndicator->draw(graphics, x, y);
84  }
85  BLOCK_END("ProgressIndicator::draw")
86 }
int width
Definition: rect.h:219
int height
Definition: rect.h:224
void draw(Graphics *const graphics, const int posX, const int posY) const
Rect mDimension
Definition: widget.h:1101
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

References BLOCK_END, BLOCK_START, SimpleAnimation::draw(), Rect::height, Widget::mDimension, mIndicator, Rect::width, x, and y.

◆ logic()

void ProgressIndicator::logic ( )
virtual

Called for all widgets in the gui each time Gui::logic is called. You can do logic stuff here like playing an animation.

See also
Gui::logic

Reimplemented from Widget.

Definition at line 67 of file progressindicator.cpp.

68 {
69  BLOCK_START("ProgressIndicator::logic")
70  if (mIndicator != nullptr)
71  mIndicator->update(10);
73 }
void update()
Definition: useragent.cpp:32

References BLOCK_END, BLOCK_START, mIndicator, and SimpleAnimation::update().

◆ safeDraw()

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

Implements Widget.

Definition at line 88 of file progressindicator.cpp.

89 {
90  BLOCK_START("ProgressIndicator::draw")
91  if (mIndicator != nullptr)
92  {
93  // Draw the indicator centered on the widget
94  const int x = (mDimension.width - 32) / 2;
95  const int y = (mDimension.height - 32) / 2;
96  mIndicator->draw(graphics, x, y);
97  }
98  BLOCK_END("ProgressIndicator::draw")
99 }

References BLOCK_END, BLOCK_START, SimpleAnimation::draw(), Rect::height, Widget::mDimension, mIndicator, Rect::width, x, and y.

Field Documentation

◆ mIndicator

SimpleAnimation* ProgressIndicator::mIndicator
private

Definition at line 52 of file progressindicator.h.

Referenced by draw(), logic(), ProgressIndicator(), safeDraw(), and ~ProgressIndicator().


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