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 35 of file progressindicator.h.

Constructor & Destructor Documentation

◆ ProgressIndicator()

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

Definition at line 35 of file progressindicator.cpp.

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

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

◆ ~ProgressIndicator()

ProgressIndicator::~ProgressIndicator ( )

Definition at line 58 of file progressindicator.cpp.

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

59 {
60  if (gui != nullptr)
61  gui->removeDragged(this);
62 
64 }
Gui * gui
Definition: gui.cpp:110
#define delete2(var)
Definition: delete2.h:24
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1161
SimpleAnimation * mIndicator

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 74 of file progressindicator.cpp.

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

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

◆ 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 66 of file progressindicator.cpp.

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

67 {
68  BLOCK_START("ProgressIndicator::logic")
69  if (mIndicator != nullptr)
70  mIndicator->update(10);
72 }
#define BLOCK_START(name)
Definition: perfomance.h:78
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:79
SimpleAnimation * mIndicator
void update()
Definition: useragent.cpp:31

◆ safeDraw()

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

Implements Widget.

Definition at line 87 of file progressindicator.cpp.

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

88 {
89  BLOCK_START("ProgressIndicator::draw")
90  if (mIndicator != nullptr)
91  {
92  // Draw the indicator centered on the widget
93  const int x = (mDimension.width - 32) / 2;
94  const int y = (mDimension.height - 32) / 2;
95  mIndicator->draw(graphics, x, y);
96  }
97  BLOCK_END("ProgressIndicator::draw")
98 }
int width
Definition: rect.h:218
#define BLOCK_START(name)
Definition: perfomance.h:78
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:79
void draw(Graphics *const graphics, const int posX, const int posY) const
int height
Definition: rect.h:223
SimpleAnimation * mIndicator
Rect mDimension
Definition: widget.h:1100

Field Documentation

◆ mIndicator

SimpleAnimation* ProgressIndicator::mIndicator
private

Definition at line 51 of file progressindicator.h.

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


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