FifeGUI 0.3.0
A C++ GUI library designed for games.
iconprogressbar.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5#ifndef INCLUDE_FIFECHAN_WIDGETS_ICONPROGRESSBAR_HPP_
6#define INCLUDE_FIFECHAN_WIDGETS_ICONPROGRESSBAR_HPP_
7
8// Standard library includes
9#include <string>
10#include <vector>
11
12// Project headers (subdirs before local)
13#include <fifechan/widget.hpp>
14
15namespace fcn
16{
17 class Graphics;
18 class Image;
19
25 class FIFEGUI_API IconProgressBar : public Widget
26 {
27 public:
31 enum class Orientation : uint8_t
32 {
33 Horizontal = 0,
34 Vertical
35 };
36
41
50 IconProgressBar(Image* image, int maxIcons);
51
61 IconProgressBar(std::string const & filename, int maxIcons);
62
63 ~IconProgressBar() override;
64
65 IconProgressBar(IconProgressBar const &) = delete;
66 IconProgressBar& operator=(IconProgressBar const &) = delete;
68 IconProgressBar& operator=(IconProgressBar&&) = delete;
69
73 void draw(Graphics* graphics) override;
74
80 void setOpaque(bool opaque);
81
85 bool isOpaque() const;
86
95 void setImage(Image* image);
96
100 Image const * getImage() const;
101
108 void setMaxIcons(int maxIcons);
109
113 int getMaxIcons() const;
114
120 void setOrientation(Orientation orientation);
121
125 Orientation getOrientation() const;
126
133 void advance();
134
138 void reset();
139
144 void setIconCount(int icons);
145
149 int getIconCount() const;
150
151 // Inherited from Widget
152
154
155 void resizeToContent(bool recursion = true) override;
156 void adjustSize() override;
157
158 protected:
168 void adjustSizeImpl();
169
173 Image const * mImage;
174
180 bool mInternalImage{false};
181
185 int mMaxIcons{0};
186
191
195 Orientation mOrientation{Orientation::Horizontal};
196
200 bool mOpaque{true};
201 };
202}; // namespace fcn
203
204#endif // INCLUDE_FIFECHAN_WIDGETS_ICONPROGRESSBAR_HPP_
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Definition graphics.hpp:58
Displays progress using a sequence of icons.
IconProgressBar()
Default constructor.
Orientation mOrientation
IconProgressBar's orientation.
Image const * mImage
Image used by the progress bar.
int mMaxIcons
Count of icons when progress bar is full.
int mIconCounter
Holds how many icons are currently displayed.
bool mOpaque
True if the widget is opaque, false otherwise.
Orientation
Orientation of the IconProgressBar (horizontal or vertical).
bool mInternalImage
True if the image has been loaded internally, false otherwise.
Abstract holder for image data.
Definition image.hpp:34
Widget()
Constructor.
Definition widget.cpp:52
virtual void resizeToContent(bool recursion=true)
Resizes the widget's size to fit the content exactly, calls recursively all childs.
Definition widget.hpp:1580
Used replacement tokens by configure_file():