FifeGUI 0.2.0
A C++ GUI library designed for games.
fcn::IconProgressBar Class Reference

#include <iconprogressbar.hpp>

Inheritance diagram for fcn::IconProgressBar:
fcn::Widget

Public Types

enum class  Orientation : uint8_t { Horizontal = 0 , Vertical }
Public Types inherited from fcn::Widget
enum class  SelectionMode : uint8_t { None = 0 , Border = 1 , Background = 2 }

Public Member Functions

void adjustSize () override
void advance ()
void draw (Graphics *graphics) override
int getIconCount () const
Image const * getImage () const
int getMaxIcons () const
Orientation getOrientation () const
 IconProgressBar ()
 IconProgressBar (IconProgressBar &&)=delete
 IconProgressBar (IconProgressBar const &)=delete
 IconProgressBar (Image *image, int maxIcons)
 IconProgressBar (std::string const &filename, int maxIcons)
bool isOpaque () const
IconProgressBaroperator= (IconProgressBar &&)=delete
IconProgressBaroperator= (IconProgressBar const &)=delete
void reset ()
void resizeToContent ()
void resizeToContent (bool recursion) override
void setIconCount (int icons)
void setImage (Image *image)
void setMaxIcons (int maxIcons)
void setOpaque (bool opaque)
void setOrientation (Orientation orientation)
Public Member Functions inherited from fcn::Widget
virtual void _draw (Graphics *graphics)
virtual FocusHandler_getFocusHandler ()
virtual std::list< FocusListener * > const & _getFocusListeners ()
virtual FocusHandler_getInternalFocusHandler ()
virtual std::list< KeyListener * > const & _getKeyListeners ()
virtual std::list< MouseListener * > const & _getMouseListeners ()
virtual void _logic ()
virtual void _setFocusHandler (FocusHandler *focusHandler)
virtual void _setParent (Widget *parent)
void adaptLayout ()
virtual void adaptLayout (bool top)
void addActionListener (ActionListener *actionListener)
void addDeathListener (DeathListener *deathListener)
void addFocusListener (FocusListener *focusListener)
void addKeyListener (KeyListener *keyListener)
void addMouseListener (MouseListener *mouseListener)
void addWidgetListener (WidgetListener *widgetListener)
virtual void drawBorder (Graphics *graphics)
virtual void drawOutline (Graphics *graphics)
virtual void drawSelectionFrame (Graphics *graphics)
void expandContent ()
virtual void expandContent (bool recursion)
virtual void focusNext ()
virtual void focusPrevious ()
virtual void fontChanged ()
virtual void getAbsolutePosition (int &x, int &y) const
std::string const & getActionEventId () const
Color const & getBackgroundColor () const
Color const & getBaseColor () const
Color const & getBorderColor () const
unsigned int getBorderSize () const
virtual Rectangle getChildrenArea ()
unsigned int getChildrenCount () const
Rectangle const & getDimension () const
Size const & getFixedSize () const
FontgetFont () const
Color const & getForegroundColor () const
int getHeight () const
std::string const & getId () const
void getLastPosition (int &x, int &y) const
int getMarginBottom () const
int getMarginLeft () const
int getMarginRight () const
int getMarginTop () const
Size const & getMaxSize () const
Size const & getMinSize () const
Color const & getOutlineColor () const
unsigned int getOutlineSize () const
unsigned int getPaddingBottom () const
unsigned int getPaddingLeft () const
unsigned int getPaddingRight () const
unsigned int getPaddingTop () const
virtual WidgetgetParent () const
Color const & getSelectionColor () const
SelectionMode getSelectionMode () const
virtual WidgetgetTop () const
unsigned int getVisibleChildrenCount () const
WidgetgetWidgetAt (int x, int y)
virtual WidgetgetWidgetAt (int x, int y, Widget *exclude)
std::list< Widget * > getWidgetsIn (Rectangle const &area)
virtual std::list< Widget * > getWidgetsIn (Rectangle const &area, Widget *ignore)
int getWidth () const
int getX () const
int getY () const
bool isEnabled () const
bool isFixedSize () const
bool isFocusable () const
virtual bool isFocused () const
bool isHorizontalExpand () const
bool isLastPositionSet () const
virtual bool isLayouted ()
virtual bool isModalFocusable () const
virtual bool isModalFocused () const
virtual bool isModalMouseInputFocusable () const
virtual bool isModalMouseInputFocused () const
bool isSetVisible () const
bool isTabInEnabled () const
bool isTabOutEnabled () const
bool isVerticalExpand () const
bool isVisible () const
virtual void logic ()
virtual void moveToBottom (Widget *widget)
virtual void moveToTop (Widget *widget)
Widgetoperator= (Widget &&)=delete
Widgetoperator= (Widget const &)=delete
virtual void releaseModalFocus ()
virtual void releaseModalMouseInputFocus ()
void removeActionListener (ActionListener *actionListener)
void removeDeathListener (DeathListener *deathListener)
void removeFocusListener (FocusListener *focusListener)
void removeKeyListener (KeyListener *keyListener)
void removeMouseListener (MouseListener *mouseListener)
void removeWidgetListener (WidgetListener *widgetListener)
virtual void requestFocus ()
virtual void requestModalFocus ()
virtual void requestModalMouseInputFocus ()
virtual void requestMoveToBottom ()
virtual void requestMoveToTop ()
void resizeToContent ()
void setActionEventId (std::string const &actionEventId)
virtual void setBackgroundColor (Color const &color)
virtual void setBaseColor (Color const &color)
virtual void setBorderColor (Color const &color)
void setBorderSize (unsigned int size)
void setDimension (Rectangle const &dimension)
void setEnabled (bool enabled)
void setFixedSize (Size const &size)
void setFocusable (bool focusable)
virtual void setFont (Font *font)
virtual void setForegroundColor (Color const &color)
void setHeight (int height)
void setHorizontalExpand (bool expand)
void setId (std::string const &id)
void setInternalFocusHandler (FocusHandler *internalFocusHandler)
void setLastPosition (int x, int y)
void setMargin (int margin)
void setMarginBottom (int margin)
void setMarginLeft (int margin)
void setMarginRight (int margin)
void setMarginTop (int margin)
void setMaxSize (Size const &size)
void setMinSize (Size const &size)
virtual void setOutlineColor (Color const &color)
void setOutlineSize (unsigned int size)
void setPadding (unsigned int padding)
void setPaddingBottom (unsigned int padding)
void setPaddingLeft (unsigned int padding)
void setPaddingRight (unsigned int padding)
void setPaddingTop (unsigned int padding)
void setPosition (int x, int y)
virtual void setSelectionColor (Color const &color)
virtual void setSelectionMode (SelectionMode mode)
void setSize (int width, int height)
void setTabInEnabled (bool enabled)
void setTabOutEnabled (bool enabled)
void setVerticalExpand (bool expand)
void setVisible (bool visible)
void setWidth (int width)
void setX (int x)
void setY (int y)
virtual void showPart (Rectangle rectangle)
virtual void showWidgetPart (Widget *widget, Rectangle area)
 Widget ()
 Widget (Widget &&)=delete
 Widget (Widget const &)=delete

Protected Member Functions

void adjustSizeImpl ()
Protected Member Functions inherited from fcn::Widget
void add (Widget *widget)
void calculateSize ()
void distributeActionEvent ()
void distributeAncestorHiddenEvent (Widget *ancestor)
void distributeAncestorMovedEvent (Widget *ancestor)
void distributeAncestorShownEvent (Widget *ancestor)
void distributeHiddenEvent ()
void distributeMovedEvent ()
void distributeResizedEvent ()
void distributeShownEvent ()
virtual WidgetfindWidgetById (std::string const &id)
std::list< Widget * > const & getChildren () const
virtual void remove (Widget *widget)
virtual void removeAllChildren ()
void resizeToChildren ()

Protected Attributes

int mIconCounter {0}
Image const * mImage
bool mInternalImage {false}
int mMaxIcons {0}
bool mOpaque {true}
Orientation mOrientation {Orientation::Horizontal}
Protected Attributes inherited from fcn::Widget
std::string mActionEventId
std::list< ActionListener * > mActionListeners
Color mBackgroundColor {0xf9fafb}
Color mBaseColor {0xe5e7eb}
Color mBorderColor {0xd1d5db}
unsigned int mBorderSize {0}
std::list< Widget * > mChildren
FontmCurrentFont {nullptr}
std::list< DeathListener * > mDeathListeners
Rectangle mDimension
bool mEnabled {true}
Size mFixedSize {-1, -1}
bool mFixedSizeUsed {false}
bool mFocusable {false}
FocusHandlermFocusHandler {nullptr}
std::list< FocusListener * > mFocusListeners
Color mForegroundColor {0x1f2933}
bool mHExpand {false}
std::string mId
FocusHandlermInternalFocusHandler {nullptr}
std::list< KeyListener * > mKeyListeners
int mLastX {0}
int mLastY {0}
int mMarginBottom {0}
int mMarginLeft {0}
int mMarginRight {0}
int mMarginTop {0}
Size mMaxSize {std::numeric_limits<int>::max(), std::numeric_limits<int>::max()}
Size mMinSize {0, 0}
std::list< MouseListener * > mMouseListeners
Rectangle mOffsetRect
Color mOutlineColor {0x9ca3af}
unsigned int mOutlineSize {0}
unsigned int mPaddingBottom {0}
unsigned int mPaddingLeft {0}
unsigned int mPaddingRight {0}
unsigned int mPaddingTop {0}
WidgetmParent {nullptr}
Color mSelectionColor {0x3b82f6}
SelectionMode mSelectionMode {SelectionMode::None}
bool mTabIn {true}
bool mTabOut {true}
bool mVExpand {false}
bool mVisible {true}
std::list< WidgetListener * > mWidgetListeners

Additional Inherited Members

Static Public Member Functions inherited from fcn::Widget
static DeathListener_getGuiDeathListener ()
static VisibilityEventHandler_getVisibilityEventHandler ()
static void _setGuiDeathListener (DeathListener *deathListener)
static void _setVisibilityEventHandler (VisibilityEventHandler *visibilityEventHandler)
static void setGlobalFont (Font *font)
static bool widgetExists (Widget const *widget)
Static Protected Attributes inherited from fcn::Widget
static DefaultFont mDefaultFont
static FontmGlobalFont = nullptr
static DeathListenermGuiDeathListener = nullptr
static VisibilityEventHandlermVisibilityEventHandler = nullptr
static std::list< Widget * > mWidgetInstances

Detailed Description

Displays progress using a sequence of icons.

Definition at line 23 of file iconprogressbar.hpp.

Member Enumeration Documentation

◆ Orientation

enum class fcn::IconProgressBar::Orientation : uint8_t
strong

Orientation of the IconProgressBar (horizontal or vertical).

Definition at line 27 of file iconprogressbar.hpp.

Constructor & Destructor Documentation

◆ IconProgressBar() [1/3]

fcn::IconProgressBar::IconProgressBar ( )

Default constructor.

Definition at line 15 of file iconprogressbar.cpp.

References mImage.

◆ IconProgressBar() [2/3]

fcn::IconProgressBar::IconProgressBar ( Image * image,
int maxIcons )

Constructor.

The image passed is not owned by this object.

Parameters
imageImage used by the progress bar's icons.
maxIconsCount of icons when the progress bar is full.

Definition at line 17 of file iconprogressbar.cpp.

References adjustSizeImpl(), mImage, and mMaxIcons.

◆ IconProgressBar() [3/3]

fcn::IconProgressBar::IconProgressBar ( std::string const & filename,
int maxIcons )

Constructor.

The image indicated by filename is opened and it's owned by this object.

Parameters
filenameFilename of the image to be used by the progress bar's icons.
maxIconsCount of icons when the progress bar is full.

Definition at line 22 of file iconprogressbar.cpp.

References adjustSizeImpl(), mImage, mInternalImage, and mMaxIcons.

◆ ~IconProgressBar()

fcn::IconProgressBar::~IconProgressBar ( )
override

Definition at line 28 of file iconprogressbar.cpp.

Member Function Documentation

◆ adjustSize()

void fcn::IconProgressBar::adjustSize ( )
overridevirtual

Resizes the widget's size to fit the content exactly.

Reimplemented from fcn::Widget.

Definition at line 161 of file iconprogressbar.cpp.

References adjustSizeImpl().

◆ adjustSizeImpl()

void fcn::IconProgressBar::adjustSizeImpl ( )
protected

Adjusts the size of the IconProgressBar to fit the icons.

The public adjustSize() method serves as a virtual entry point for polymorphism, while this adjustSizeImpl() method contains the concrete implementation of the resizing logic.

See also
adjustSize (virtual entry point for polymorphism)

Definition at line 166 of file iconprogressbar.cpp.

References fcn::Widget::getBorderSize(), fcn::Widget::getPaddingBottom(), fcn::Widget::getPaddingLeft(), fcn::Widget::getPaddingRight(), fcn::Widget::getPaddingTop(), mImage, mMaxIcons, mOrientation, and fcn::Widget::setSize().

Referenced by adjustSize(), IconProgressBar(), IconProgressBar(), resizeToContent(), setImage(), setMaxIcons(), and setOrientation().

◆ advance()

void fcn::IconProgressBar::advance ( )

Advances the progress bar to use one more icon.

If there can be no advancement (maxIcons is reached), then the counter is reset to 0, useful if client wishes to make the IconProgressBar looping.

Definition at line 135 of file iconprogressbar.cpp.

References mIconCounter, and mMaxIcons.

◆ draw()

◆ getIconCount()

int fcn::IconProgressBar::getIconCount ( ) const
Returns
Current count of icons for this IconProgressBar.

Definition at line 150 of file iconprogressbar.cpp.

References mIconCounter.

◆ getImage()

Image const * fcn::IconProgressBar::getImage ( ) const
Returns
The image used by this IconProgressBar.

Definition at line 102 of file iconprogressbar.cpp.

References mImage.

◆ getMaxIcons()

int fcn::IconProgressBar::getMaxIcons ( ) const
Returns
Maximum count of icons for this IconProgressBar.

Definition at line 113 of file iconprogressbar.cpp.

References mMaxIcons.

◆ getOrientation()

IconProgressBar::Orientation fcn::IconProgressBar::getOrientation ( ) const
Returns
Orientation of this IconProgressBar.

Definition at line 130 of file iconprogressbar.cpp.

References mOrientation.

◆ isOpaque()

bool fcn::IconProgressBar::isOpaque ( ) const
Returns
Whether this IconProgressBar is opaque or not.

Definition at line 85 of file iconprogressbar.cpp.

References mOpaque.

Referenced by draw().

◆ reset()

void fcn::IconProgressBar::reset ( )

Resets the progress bar.

Definition at line 140 of file iconprogressbar.cpp.

References mIconCounter.

◆ resizeToContent() [1/2]

Resizes the widget's size to fit the content exactly, calls recursively all childs.

This is a convenience wrapper that calls resizeToContent(true).

Definition at line 1417 of file widget.hpp.

◆ resizeToContent() [2/2]

void fcn::IconProgressBar::resizeToContent ( bool recursion)
overridevirtual

Resize this widget to fit its content.

Parameters
recursionIf true, perform the resize operation recursively on children.

Reimplemented from fcn::Widget.

Definition at line 155 of file iconprogressbar.cpp.

References adjustSizeImpl().

◆ setIconCount()

void fcn::IconProgressBar::setIconCount ( int icons)

Sets count of icons.

Parameters
iconsThe count of the active icons.

Definition at line 145 of file iconprogressbar.cpp.

References mIconCounter, and mMaxIcons.

◆ setImage()

void fcn::IconProgressBar::setImage ( Image * image)

Sets the IconProgressBar's image.

The image passed is not owned by this object.

Parameters
imageImage used by the progress bar's icons.
See also
setMaxIcons

Definition at line 90 of file iconprogressbar.cpp.

References adjustSizeImpl(), mImage, and mInternalImage.

◆ setMaxIcons()

void fcn::IconProgressBar::setMaxIcons ( int maxIcons)

Sets count of icons when the progress bar is full.

Also creates enough icons to represent that.

Parameters
maxIconsdesired maximum count of icons.

Definition at line 107 of file iconprogressbar.cpp.

References adjustSizeImpl(), and mMaxIcons.

◆ setOpaque()

void fcn::IconProgressBar::setOpaque ( bool opaque)

Sets the opacity of the IconProgressBar.

Parameters
opaqueTrue if opaque, false otherwise.

Definition at line 80 of file iconprogressbar.cpp.

References mOpaque.

◆ setOrientation()

void fcn::IconProgressBar::setOrientation ( Orientation orientation)

Sets the IconProgressBar's orientation.

Parameters
orientationDesired orientation.

Definition at line 118 of file iconprogressbar.cpp.

References adjustSizeImpl(), and mOrientation.

Member Data Documentation

◆ mIconCounter

int fcn::IconProgressBar::mIconCounter {0}
protected

Holds how many icons are currently displayed.

Definition at line 180 of file iconprogressbar.hpp.

Referenced by advance(), draw(), getIconCount(), reset(), and setIconCount().

◆ mImage

Image const* fcn::IconProgressBar::mImage
protected

Image used by the progress bar.

Definition at line 163 of file iconprogressbar.hpp.

Referenced by adjustSizeImpl(), draw(), getImage(), IconProgressBar(), IconProgressBar(), IconProgressBar(), and setImage().

◆ mInternalImage

bool fcn::IconProgressBar::mInternalImage {false}
protected

True if the image has been loaded internally, false otherwise.

An image not loaded internally should not be deleted in the destructor.

Definition at line 170 of file iconprogressbar.hpp.

Referenced by IconProgressBar(), and setImage().

◆ mMaxIcons

int fcn::IconProgressBar::mMaxIcons {0}
protected

Count of icons when progress bar is full.

Definition at line 175 of file iconprogressbar.hpp.

Referenced by adjustSizeImpl(), advance(), getMaxIcons(), IconProgressBar(), IconProgressBar(), setIconCount(), and setMaxIcons().

◆ mOpaque

bool fcn::IconProgressBar::mOpaque {true}
protected

True if the widget is opaque, false otherwise.

Definition at line 190 of file iconprogressbar.hpp.

Referenced by isOpaque(), and setOpaque().

◆ mOrientation

Orientation fcn::IconProgressBar::mOrientation {Orientation::Horizontal}
protected

IconProgressBar's orientation.

Definition at line 185 of file iconprogressbar.hpp.

Referenced by adjustSizeImpl(), draw(), getOrientation(), and setOrientation().


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