CUGL 2.3
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) |
bool | initWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data) override |
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::scene2::SceneNode | |
SceneNode () | |
~SceneNode () | |
virtual void | dispose () |
virtual bool | init () |
virtual bool | initWithPosition (const Vec2 pos) |
bool | initWithPosition (float x, float y) |
virtual bool | initWithBounds (const Size size) |
virtual bool | initWithBounds (float width, float height) |
virtual bool | initWithBounds (const Rect rect) |
virtual bool | initWithBounds (float x, float y, float width, float height) |
virtual bool | initWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data) |
virtual std::shared_ptr< SceneNode > | copy (const std::shared_ptr< SceneNode > &dst) const |
unsigned int | getTag () const |
void | setTag (unsigned int tag) |
const std::string | getName () const |
void | setName (const std::string name) |
const std::string | getClassName () const |
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) |
virtual Rect | getLayoutBounds () const |
Size | getSize () const |
float | getWidth () const |
float | getHeight () const |
Rect | getBoundingBox () const |
virtual void | setAnchor (const Vec2 anchor) |
virtual void | setAnchor (float x, float y) |
const Vec2 | getAnchor () const |
Vec2 | getAnchorInPixels () |
Color4 | getColor () const |
virtual void | setColor (Color4 color) |
Color4 | getAbsoluteColor () |
bool | isVisible () const |
void | setVisible (bool visible) |
bool | hasRelativeColor () const |
void | setRelativeColor (bool flag) |
std::shared_ptr< Scissor > | getScissor () const |
void | setScissor (const std::shared_ptr< Scissor > &scissor) |
void | setScissor () |
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 Affine2 & | getTransform () const |
const Affine2 & | getAlternateTransform () const |
void | setAlternateTransform (const Affine2 &transform) |
bool | withAlternateTransform () |
void | chooseAlternateTransform (bool active) |
const Affine2 & | getNodeToParentTransform () const |
Affine2 | getParentToNodeTransform () const |
Affine2 | getNodeToWorldTransform () const |
Affine2 | 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 |
size_t | getChildCount () const |
std::shared_ptr< SceneNode > | getChild (unsigned int pos) |
const std::shared_ptr< SceneNode > & | getChild (unsigned int pos) const |
template<typename T > | |
std::shared_ptr< T > | getChild (unsigned int pos) const |
std::shared_ptr< SceneNode > | getChildByTag (unsigned int tag) const |
template<typename T > | |
std::shared_ptr< T > | getChildByTag (unsigned int tag) const |
std::shared_ptr< SceneNode > | getChildByName (const std::string name) const |
template<typename T > | |
std::shared_ptr< T > | getChildByName (const std::string name) const |
std::vector< std::shared_ptr< SceneNode > > | getChildren () |
const std::vector< std::shared_ptr< SceneNode > > & | getChildren () const |
void | addChild (const std::shared_ptr< SceneNode > &child) |
void | addChildWithTag (const std::shared_ptr< SceneNode > &child, unsigned int tag) |
void | addChildWithName (const std::shared_ptr< SceneNode > &child, const std::string name) |
void | swapChild (const std::shared_ptr< SceneNode > &child1, const std::shared_ptr< SceneNode > &child2, bool inherit=false) |
SceneNode * | getParent () |
const SceneNode * | getParent () const |
Scene2 * | getScene () |
const Scene2 * | getScene () const |
void | removeFromParent () |
virtual void | removeChild (unsigned int pos) |
void | removeChild (const std::shared_ptr< SceneNode > &child) |
void | removeChildByTag (unsigned int tag) |
void | removeChildByName (const std::string name) |
virtual void | removeAllChildren () |
void | setPriority (float priority) |
float | getPriority () |
virtual void | render (const std::shared_ptr< SpriteBatch > &batch, const Affine2 &transform, Color4 tint) |
virtual void | render (const std::shared_ptr< SpriteBatch > &batch) |
virtual void | draw (const std::shared_ptr< SpriteBatch > &batch, const Affine2 &transform, Color4 tint) |
const std::shared_ptr< Layout > & | getLayout () const |
void | setLayout (const std::shared_ptr< Layout > &layout) |
virtual void | doLayout () |
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 std::shared_ptr< SceneNode > | allocWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data) |
Static Public Member Functions inherited from cugl::scene2::SceneNode | |
static std::shared_ptr< SceneNode > | alloc () |
static std::shared_ptr< SceneNode > | allocWithPosition (const Vec2 pos) |
static std::shared_ptr< SceneNode > | allocWithPosition (float x, float y) |
static std::shared_ptr< SceneNode > | allocWithBounds (const Size size) |
static std::shared_ptr< SceneNode > | allocWithBounds (float width, float height) |
static std::shared_ptr< SceneNode > | allocWithBounds (const Rect rect) |
static std::shared_ptr< SceneNode > | allocWithBounds (float x, float y, float width, float height) |
static std::shared_ptr< SceneNode > | allocWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data) |
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::scene2::SceneNode | |
Vec2 | _position |
Vec2 | _anchor |
Size | _contentSize |
Color4 | _tintColor |
bool | _hasParentColor |
bool | _isVisible |
std::shared_ptr< Scissor > | _scissor |
Vec2 | _scale |
float | _angle |
Affine2 | _transform |
bool | _useTransform |
Affine2 | _combined |
std::vector< std::shared_ptr< SceneNode > > | _children |
SceneNode * | _parent |
Scene2 * | _graph |
std::shared_ptr< Layout > | _layout |
int | _childOffset |
unsigned int | _tag |
std::string | _name |
size_t | _hashOfName |
std::string | _classname |
float | _priority |
std::shared_ptr< JsonValue > | _json |
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.
The progress bar will be placed at the origin of the parent and by anchored at the bottom left.
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.
The progress bar will be placed at the origin of the parent and by anchored at the bottom left.
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.
The progress bar will be placed at the origin of the parent and by anchored at the bottom left.
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.
The progress bar will be placed at the origin of the parent and by anchored at the bottom left.
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.
The progress bar will be placed at the origin of the parent and by anchored at the bottom left.
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.
The progress bar will be placed at the origin of the parent and by anchored at the bottom left.
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.
The progress bar will be placed at the origin of the parent and by anchored at the bottom left.
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 |
|
inlinestatic |
Returns a newly allocated node with the given JSON specificaton.
This initializer is designed to receive the "data" object from the JSON passed to Scene2Loader
. This JSON format supports all of the attribute values of its parent class. In addition, it supports the following additional attributes:
"foreground": The name of a previously loaded texture asset "background": The name of a previously loaded texture asset "left_cap": The name of a previously loaded texture asset "right_cap": The name of a previously loaded texture asset
All attributes are optional. There are no required attributes.
loader | The scene loader passing this JSON file |
data | The JSON object specifying the node |
|
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::scene2::SceneNode.
|
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::scene2::SceneNode.
|
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.
The progress bar will be placed at the origin of the parent and by anchored at the bottom left.
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.
The progress bar will be placed at the origin of the parent and by anchored at the bottom left.
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.
The progress bar will be placed at the origin of the parent and by anchored at the bottom left.
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.
The progress bar will be placed at the origin of the parent and by anchored at the bottom left.
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.
The progress bar will be placed at the origin of the parent and by anchored at the bottom left.
background | The texture for the background |
foreground | The texture for the animated foreground |
size | The progress bar size |
bool cugl::scene2::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.
The progress bar will be placed at the origin of the parent and by anchored at the bottom left.
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::scene2::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.
The progress bar will be placed at the origin of the parent and by anchored at the bottom left.
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 |
Initializes a node with the given JSON specificaton.
This initializer is designed to receive the "data" object from the JSON passed to Scene2Loader
. This JSON format supports all of the attribute values of its parent class. In addition, it supports the following additional attributes:
"foreground": The name of a previously loaded texture asset "background": The name of a previously loaded texture asset "left_cap": The name of a previously loaded texture asset "right_cap": The name of a previously loaded texture asset
All attributes are optional. There are no required attributes.
loader | The scene loader passing this JSON file |
data | The JSON object specifying the node |
Reimplemented from cugl::scene2::SceneNode.
|
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::scene2::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::scene2::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)