CUGL
Cornell University Game Library
|
#include <CUProgressBar.h>
Public Member Functions | |
ProgressBar () | |
~ProgressBar () | |
virtual void | dispose () override |
virtual bool | init () override |
bool | init (const Size &size) |
bool | init (const std::shared_ptr< Texture > &background) |
bool | init (const std::shared_ptr< Texture > &background, const Size &size) |
bool | init (const std::shared_ptr< Texture > &background, const std::shared_ptr< Texture > &foreground) |
bool | init (const std::shared_ptr< Texture > &background, const std::shared_ptr< Texture > &foreground, const Size &size) |
bool | initWithCaps (const std::shared_ptr< Texture > &background, const std::shared_ptr< Texture > &foreground, const std::shared_ptr< Texture > &beginCap, const std::shared_ptr< Texture > &finalCap) |
bool | initWithCaps (const std::shared_ptr< Texture > &background, const std::shared_ptr< Texture > &foreground, const std::shared_ptr< Texture > &beginCap, const std::shared_ptr< Texture > &finalCap, const Size &size) |
float | getProgress () const |
void | setProgress (float progress) |
Color4 | getBackgroundColor () const |
void | setBackgroundColor (Color4 color) |
Color4 | getForegroundColor () const |
void | setForegroundColor (Color4 color) |
Public Member Functions inherited from cugl::Node | |
Node () | |
virtual | ~Node () |
virtual bool | initWithPosition (const Vec2 &pos) |
bool | initWithPosition (float x, float y) |
virtual bool | initWithBounds (const Size &size) |
bool | initWithBounds (float width, float height) |
virtual bool | initWithBounds (const Rect &rect) |
bool | initWithBounds (float x, float y, float width, float height) |
virtual Node * | copy (Node *dst) |
unsigned int | getTag () const |
void | setTag (unsigned int tag) |
const std::string & | getName () const |
void | setName (const std::string &name) |
virtual std::string | toString (bool verbose=false) const |
operator std::string () const | |
const Vec2 & | getPosition () const |
void | setPosition (const Vec2 &position) |
void | setPosition (float x, float y) |
float | getPositionX (void) const |
void | setPositionX (float x) |
float | getPositionY (void) const |
void | setPositionY (float y) |
Vec2 | getWorldPosition () const |
const Size & | getContentSize () const |
virtual void | setContentSize (const Size &size) |
virtual void | setContentSize (float width, float height) |
float | getContentWidth () const |
void | setContentWidth (float width) |
float | getContentHeight () const |
void | setContentHeight (float height) |
Size | getSize () const |
float | getWidth () const |
float | getHeight () const |
Rect | getBoundingBox () const |
virtual void | setAnchor (const Vec2 &anchor) |
void | setAnchor (float x, float y) |
const Vec2 & | getAnchor () const |
Vec2 | getAnchorInPixels () |
Color4 | getColor () const |
void | setColor (Color4 color) |
Color4 | getAbsoluteColor () |
bool | isVisible () const |
void | setVisible (bool visible) |
bool | hasRelativeColor () |
void | setRelativeColor (bool flag) |
const Vec2 & | getScale () const |
float | getScaleX () const |
float | getScaleY () const |
void | setScale (float scale) |
void | setScale (const Vec2 &vec) |
void | setScale (float sx, float sy) |
float | getAngle () |
void | setAngle (float angle) |
const Mat4 & | getAlternateTransform () |
void | setAlternateTransform (const Mat4 &transform) |
bool | withAlternateTransform () |
void | chooseAlternateTransform (bool active) |
const Mat4 & | getNodeToParentTransform () const |
Mat4 | getParentToNodeTransform () const |
Mat4 | getNodeToWorldTransform () const |
Mat4 | getWorldToNodeTransform () const |
Vec2 | screenToNodeCoords (const Vec2 &screenPoint) const |
Vec2 | worldToNodeCoords (const Vec2 &worldPoint) const |
Vec2 | nodeToScreenCoords (const Vec2 &nodePoint) const |
Vec2 | nodeToWorldCoords (const Vec2 &nodePoint) const |
Vec2 | parentToNodeCoords (const Vec2 &parentPoint) const |
Vec2 | nodeToParentCoords (const Vec2 &nodePoint) const |
void | setZOrder (int z) |
int | getZOrder () const |
bool | isZDirty () const |
void | sortZOrder () |
size_t | getChildCount () const |
std::shared_ptr< Node > | getChild (unsigned int pos) |
const std::shared_ptr< Node > & | getChild (unsigned int pos) const |
template<typename T > | |
std::shared_ptr< T > | getChild (unsigned int pos) const |
std::shared_ptr< Node > | getChildByTag (unsigned int tag) const |
template<typename T > | |
std::shared_ptr< T > | getChildByTag (unsigned int tag) const |
std::shared_ptr< Node > | getChildByName (const std::string &name) const |
template<typename T > | |
std::shared_ptr< T > | getChildByName (const std::string &name) const |
std::vector< std::shared_ptr< Node > > | getChildren () |
const std::vector< std::shared_ptr< Node > > & | getChildren () const |
void | addChild (std::shared_ptr< Node > child) |
virtual void | addChild (const std::shared_ptr< Node > &child, int zval) |
void | addChildWithTag (const std::shared_ptr< Node > &child, unsigned int tag) |
void | addChildWithTag (const std::shared_ptr< Node > &child, unsigned int tag, int zval) |
void | addChildWithName (const std::shared_ptr< Node > &child, const std::string &name) |
void | addChildWithName (const std::shared_ptr< Node > &child, const std::string &name, int zval) |
void | swapChild (const std::shared_ptr< Node > &child1, const std::shared_ptr< Node > &child2, bool inherit=false) |
Node * | getParent () |
const Node * | getParent () const |
Scene * | getScene () |
const Scene * | getScene () const |
void | removeFromParent () |
virtual void | removeChild (unsigned int pos) |
void | removeChild (const std::shared_ptr< Node > &child) |
void | removeChildByTag (unsigned int tag) |
void | removeChildByName (const std::string &name) |
virtual void | removeAllChildren () |
void | render (const std::shared_ptr< SpriteBatch > &batch, const Mat4 &transform, Color4 tint) |
void | render (const std::shared_ptr< SpriteBatch > &batch) |
virtual void | draw (const std::shared_ptr< SpriteBatch > &batch, const Mat4 &transform, Color4 tint) |
Static Public Member Functions | |
static std::shared_ptr< ProgressBar > | alloc (const Size &size) |
static std::shared_ptr< ProgressBar > | alloc (const std::shared_ptr< Texture > &background) |
static std::shared_ptr< ProgressBar > | alloc (const std::shared_ptr< Texture > &background, const Size &size) |
static std::shared_ptr< ProgressBar > | alloc (const std::shared_ptr< Texture > &background, const std::shared_ptr< Texture > &foreground) |
static std::shared_ptr< ProgressBar > | alloc (const std::shared_ptr< Texture > &background, const std::shared_ptr< Texture > &foreground, const Size &size) |
static std::shared_ptr< ProgressBar > | allocWithCaps (const std::shared_ptr< Texture > &background, const std::shared_ptr< Texture > &foreground, const std::shared_ptr< Texture > &beginCap, const std::shared_ptr< Texture > &finalCap) |
static std::shared_ptr< ProgressBar > | allocWithCaps (const std::shared_ptr< Texture > &background, const std::shared_ptr< Texture > &foreground, const std::shared_ptr< Texture > &beginCap, const std::shared_ptr< Texture > &finalCap, const Size &size) |
Static Public Member Functions inherited from cugl::Node | |
static std::shared_ptr< Node > | alloc () |
static std::shared_ptr< Node > | allocWithPosition (const Vec2 &pos) |
static std::shared_ptr< Node > | allocWithPosition (float x, float y) |
static std::shared_ptr< Node > | allocWithBounds (const Size &size) |
static std::shared_ptr< Node > | allocWithBounds (float width, float height) |
static std::shared_ptr< Node > | allocWithBounds (const Rect &rect) |
static std::shared_ptr< Node > | allocWithBounds (float x, float y, float width, float height) |
Protected Attributes | |
float | _progress |
Size | _foresize |
std::shared_ptr< PolygonNode > | _background |
std::shared_ptr< PolygonNode > | _foreground |
std::shared_ptr< PolygonNode > | _begincap |
std::shared_ptr< PolygonNode > | _finalcap |
Protected Attributes inherited from cugl::Node | |
Vec2 | _position |
Vec2 | _anchor |
Size | _contentSize |
Color4 | _tintColor |
bool | _hasParentColor |
bool | _isVisible |
Vec2 | _scale |
float | _angle |
Mat4 | _transform |
bool | _useTransform |
Mat4 | _combined |
std::vector< std::shared_ptr< Node > > | _children |
Node * | _parent |
Scene * | _graph |
int | _childOffset |
unsigned int | _tag |
std::string | _name |
size_t | _hashOfName |
int | _zOrder |
bool | _zDirty |
This class is a node the represents an (animating) project bar.
The progress bar may either be represented via a texture or a simple colored rectangle. If it is a texture, the foreground texture will be sampled left to right and the maximum horizontal texture coordinate will be the percentage of the progress bar. So if the progress bar is at 50%, the progress bar will draw the left side of the foreground texture.
When using textures it is also possible to specify endcap textures. This allows for progress bars that are not completely rectangular.
|
inline |
Creates an uninitialized progress bar with no size or texture information.
You must initialize this progress bar before use.
NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate a Node on the heap, use one of the static constructors instead.
|
inline |
Deletes this progress bar, disposing all resources
|
inlinestatic |
Returns a newly allocated texture-less progress bar of the given size.
The background will be a white rectangle, while the foreground (measuring progess) will be a red rectangle. You can change these colors with the setBackgroundColor and setForegroundColor methods.
size | The progress bar size |
|
inlinestatic |
Returns a newly allocated progress bar with the given texture.
The progress bar will be the size of the texture. It will use the same texture for the background and foreground. However, the foreground (measuring progress) will be tinted red. You can change this color with the setForegroundColor method.
background | The progress bar texture |
|
inlinestatic |
Returns a newly allocated progress bar with the given texture and size
The progress bar texture will scale to the given size. It will use the same texture for the background and foreground. However, the foreground (measuring progress) will be tinted red. You can change this color with the setForegroundColor method.
background | The progress bar texture |
size | The progress bar size |
|
inlinestatic |
Returns a newly allocated progress bar with the given background and foreground.
The progress bar will be the size of the background texture. The foreground texture will be scaled to this size. Neither the background nor the foreground texture will be tinted.
background | The texture for the background |
foreground | The texture for the animated foreground |
|
inlinestatic |
Returns a newly allocated progress bar with the given textures and size.
The progress bar will scale both the background and foreground texture. to the given size. Neither the background nor the foreground texture will be tinted.
background | The texture for the background |
foreground | The texture for the animated foreground |
size | The progress bar size |
|
inlinestatic |
Returns a newly allocated progress bar with the given textures and size.
The progress bar will be the size of the background texture. The foreground texture and end caps will be scaled so that they are this size when combined together. None of the textures will be tinted.
background | The texture for the background |
foreground | The texture for the animated foreground |
beginCap | The left end cap of the foreground |
finalCap | The right end cap of the foreground |
|
inlinestatic |
Returns a newly allocated progress bar with the given textures and size.
The progress bar will scale the background texture to the given size. The foreground texture and end caps will be scaled so that they are this size when combined together. None of the textures will be tinted.
background | The texture for the background |
foreground | The texture for the animated foreground |
beginCap | The left end cap of the foreground |
finalCap | The right end cap of the foreground |
size | The progress bar size |
|
overridevirtual |
Disposes all of the resources used by this node.
A disposed progress bar can be safely reinitialized. Any children owned by this node will be released. They will be deleted if no other object owns them.
It is unsafe to call this on a progress bar that is still currently inside of a scene graph.
Reimplemented from cugl::Node.
|
inline |
Returns the background color or tint of the progress bar
This is the color applied to the background texture if it exists, or the color of the background rectangle. It is white by default.
|
inline |
Returns the foreground color or tint of the progress bar
This is the color applied to the foreground texture (and end caps) if it exists, or the color of the foreground rectangle. If there is a texture it is white by default. Otherwise it is red by default.
|
inline |
Returns the percentage progress of this progress bar
This value is a float between 0 and 1. Changing this value will alter the size of the progress bar foreground.
|
inlineoverridevirtual |
Deactivates the default initializer.
This initializer may not be used for a progress bar. A progress bar either needs a texture or a size
Reimplemented from cugl::Node.
|
inline |
Initializes a texture-less progress bar of the given size.
The background will be a white rectangle, while the foreground (measuring progess) will be a red rectangle. You can change these colors with the setBackgroundColor and setForegroundColor methods.
size | The progress bar size |
|
inline |
Initializes a progress bar with the given texture.
The progress bar will be the size of the texture. It will use the same texture for the background and foreground. However, the foreground (measuring progress) will be tinted red. You can change this color with the setForegroundColor method.
background | The progress bar texture |
|
inline |
Initializes a progress bar with the given texture and size
The progress bar texture will scale to the given size. It will use the same texture for the background and foreground. However, the foreground (measuring progress) will be tinted red. You can change this color with the setForegroundColor method.
background | The progress bar texture |
size | The progress bar size |
|
inline |
Initializes a progress bar with the given background and foreground.
The progress bar will be the size of the background texture. The foreground texture will be scaled to this size. Neither the background nor the foreground texture will be tinted.
background | The texture for the background |
foreground | The texture for the animated foreground |
|
inline |
Initializes a progress bar with the given textures and size.
The progress bar will scale both the background and foreground texture. to the given size. Neither the background nor the foreground texture will be tinted.
background | The texture for the background |
foreground | The texture for the animated foreground |
size | The progress bar size |
bool cugl::ProgressBar::initWithCaps | ( | const std::shared_ptr< Texture > & | background, |
const std::shared_ptr< Texture > & | foreground, | ||
const std::shared_ptr< Texture > & | beginCap, | ||
const std::shared_ptr< Texture > & | finalCap | ||
) |
Initializes a progress bar with the given textures and size.
The progress bar will be the size of the background texture. The foreground texture and end caps will be scaled so that they are this size when combined together. None of the textures will be tinted.
background | The texture for the background |
foreground | The texture for the animated foreground |
beginCap | The left end cap of the foreground |
finalCap | The right end cap of the foreground |
bool cugl::ProgressBar::initWithCaps | ( | const std::shared_ptr< Texture > & | background, |
const std::shared_ptr< Texture > & | foreground, | ||
const std::shared_ptr< Texture > & | beginCap, | ||
const std::shared_ptr< Texture > & | finalCap, | ||
const Size & | size | ||
) |
Initializes a progress bar with the given textures and size.
The progress bar will scale the background texture to the given size. The foreground texture and end caps will be scaled so that they are this size when combined together. None of the textures will be tinted.
background | The texture for the background |
foreground | The texture for the animated foreground |
beginCap | The left end cap of the foreground |
finalCap | The right end cap of the foreground |
size | The progress bar size |
|
inline |
Sets the background color or tint of the progress bar
This is the color applied to the background texture if it exists, or the color of the background rectangle. It is white by default.
color | The background color or tint of the progress bar |
void cugl::ProgressBar::setForegroundColor | ( | Color4 | color | ) |
Sets the foreground color or tint of the progress bar
This is the color applied to the foreground texture (and end caps) if it exists, or the color of the foreground rectangle. If there is a texture it is white by default. Otherwise it is red by default.
color | The foreground color or tint of the progress bar |
void cugl::ProgressBar::setProgress | ( | float | progress | ) |
Sets the percentage progress of this progress bar
This value is a float between 0 and 1. Changing this value will alter the size of the progress bar foreground.
progress | The percentage progress of this progress bar |
|
protected |
The background image or rectangle (representing total time)
|
protected |
The starting endcap image
|
protected |
The finishing endcap image
|
protected |
The foreground image or rectangle (representing progress)
|
protected |
The (maximum) size of the foreground texture or node
|
protected |
The progress percentage of this progress bar (between 0 and 1)