6#include <fifechan/widgets/imageprogressbar.hpp>
13#include "fifechan/exception.hpp"
14#include "fifechan/graphics.hpp"
15#include "fifechan/image.hpp"
16#include "fifechan/rectangle.hpp"
20 ImageProgressBar::ImageProgressBar() :
22 mForegroundImage(nullptr),
23 mInternalImage(false),
26 mOrientation(Orientation::Horizontal),
31 ImageProgressBar::ImageProgressBar(
Image* image,
int maxValue) :
40 assert(
"max value must be positive" &&
mMaxValue > 0);
44 ImageProgressBar::ImageProgressBar(std::string
const & filename,
int maxValue) :
53 assert(
"max value must be positive" &&
mMaxValue > 0);
57 ImageProgressBar::~ImageProgressBar()
66 assert(
"graphics must not be null" && graphics !=
nullptr);
67 assert(
"max value must be positive" &&
mMaxValue > 0);
73 ((
getSelectionMode() & Widget::SelectionMode::Background) == Widget::SelectionMode::Background)) {
86 if (active && (
getSelectionMode() & Widget::SelectionMode::Border) == Widget::SelectionMode::Border) {
163 if (orientation != Orientation::Horizontal && orientation != Orientation::Vertical) {
164 throwException(
"Unknown orientation type in ImageProgressBar object");
178 assert(
"max value must be positive" && value > 0);
191 }
else if (value < 0) {
205 static_cast<void>(recursion);
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
virtual void popClipArea()
Removes the top most clip area from the stack.
virtual void drawImage(Image const *image, int srcX, int srcY, int dstX, int dstY, int width, int height)=0
Draws a part of an image.
virtual bool pushClipArea(Rectangle area)
Pushes a clip area onto the stack.
virtual void setColor(Color const &color)=0
Sets the color to use when drawing.
virtual void fillRectangle(Rectangle const &rectangle)=0
Draws a filled rectangle.
int mValue
Holds the current progress bar value.
void setOrientation(Orientation orientation)
Sets the ImageProgressBar's orientation.
void setValue(int value)
Sets the value of the bar.
int mMaxValue
Value when progress bar is full.
Image const * getBarImage() const
void draw(Graphics *graphics) override
Draws this ImageProgressBar.
void setMaxValue(int value)
Sets the max value of the bar.
void setOpaque(bool opaque)
Sets the opacity of the ImageProgressBar.
Orientation
Orientation of the progress bar (horizontal or vertical).
bool mInternalImage
True if the image has been loaded internally, false otherwise.
void adjustSize() override
Resizes the widget's size to fit the content exactly.
void setForegroundImage(Image *image)
Sets the foreground image.
Image const * getForegroundImage() const
void adjustSizeImpl()
Adjusts the size of the progress bar to fit the content.
Orientation mOrientation
ImageProgressBar's orientation.
void setBarImage(Image *image)
Sets the Bar image.
Image const * mForegroundImage
Foreground image.
int getMaxValue() const
Gets the max value of the bar.
Image const * mBarImage
Bar image.
bool mOpaque
True if the widget is opaque, false otherwise.
Orientation getOrientation() const
void resizeToContent(bool recursion=true) override
Resizes the widget's size to fit the content exactly, calls recursively all childs.
int getValue() const
Gets the value of the bar.
Abstract holder for image data.
Represents a rectangular area (X, Y, Width, Height).
Used replacement tokens by configure_file():
void throwException(std::string const &message, std::source_location location=std::source_location::current())
Throw an Exception capturing the current source location.