overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
gameplay::Control Class Reference

#include <Control.h>

Inheritance diagram for gameplay::Control:
gameplay::Ref gameplay::AnimationTarget gameplay::ScriptTarget gameplay::Container gameplay::ImageControl gameplay::JoystickControl gameplay::Label gameplay::Form gameplay::Button gameplay::Slider gameplay::TextBox gameplay::CheckBox gameplay::RadioButton

List of all members.

Classes

class  Listener

Public Types

enum  State {
  NORMAL = 0x01, FOCUS = 0x02, ACTIVE = 0x04, DISABLED = 0x08,
  HOVER = 0x10
}
enum  Alignment {
  ALIGN_LEFT = 0x01, ALIGN_HCENTER = 0x02, ALIGN_RIGHT = 0x04, ALIGN_TOP = 0x10,
  ALIGN_VCENTER = 0x20, ALIGN_BOTTOM = 0x40, ALIGN_TOP_LEFT = ALIGN_TOP | ALIGN_LEFT, ALIGN_VCENTER_LEFT = ALIGN_VCENTER | ALIGN_LEFT,
  ALIGN_BOTTOM_LEFT = ALIGN_BOTTOM | ALIGN_LEFT, ALIGN_TOP_HCENTER = ALIGN_TOP | ALIGN_HCENTER, ALIGN_VCENTER_HCENTER = ALIGN_VCENTER | ALIGN_HCENTER, ALIGN_BOTTOM_HCENTER = ALIGN_BOTTOM | ALIGN_HCENTER,
  ALIGN_TOP_RIGHT = ALIGN_TOP | ALIGN_RIGHT, ALIGN_VCENTER_RIGHT = ALIGN_VCENTER | ALIGN_RIGHT, ALIGN_BOTTOM_RIGHT = ALIGN_BOTTOM | ALIGN_RIGHT
}
enum  AutoSize { AUTO_SIZE_NONE = 0x00, AUTO_SIZE_WIDTH = 0x01, AUTO_SIZE_HEIGHT = 0x02, AUTO_SIZE_BOTH = (AUTO_SIZE_WIDTH | AUTO_SIZE_HEIGHT) }

Public Member Functions

const char * getTypeName () const
const char * getId () const
void setId (const char *id)
float getX () const
void setX (float x, bool percentage=false)
bool isXPercentage () const
float getY () const
void setY (float y, bool percentage=false)
bool isYPercentage () const
float getWidth () const
void setWidth (float width, bool percentage=false)
bool isWidthPercentage () const
float getHeight () const
void setHeight (float height, bool percentage=false)
bool isHeightPercentage () const
void setPosition (float x, float y)
void setSize (float width, float height)
const RectanglegetBounds () const
void setBounds (const Rectangle &bounds)
const RectanglegetAbsoluteBounds () const
const RectanglegetClipBounds () const
const RectanglegetClip () const
AutoSize getAutoSize () const
void setAutoSize (AutoSize mode)
void setAlignment (Alignment alignment)
Alignment getAlignment () const
void setBorder (float top, float bottom, float left, float right, unsigned char states=STATE_ALL)
const Theme::BordergetBorder (State state=NORMAL) const
void setSkinRegion (const Rectangle &region, unsigned char states=STATE_ALL)
const RectanglegetSkinRegion (State state=NORMAL) const
void setSkinColor (const Vector4 &color, unsigned char states=STATE_ALL)
const Vector4getSkinColor (State state=NORMAL) const
void setMargin (float top, float bottom, float left, float right)
const Theme::MargingetMargin () const
void setPadding (float top, float bottom, float left, float right)
const Theme::PaddinggetPadding () const
void setImageRegion (const char *id, const Rectangle &region, unsigned char states=STATE_ALL)
const RectanglegetImageRegion (const char *id, State state) const
void setImageColor (const char *id, const Vector4 &color, unsigned char states=STATE_ALL)
const Vector4getImageColor (const char *id, State state) const
const Theme::UVsgetImageUVs (const char *id, State state) const
void setCursorRegion (const Rectangle &region, unsigned char states)
const RectanglegetCursorRegion (State state) const
void setCursorColor (const Vector4 &color, unsigned char states)
const Vector4getCursorColor (State state)
const Theme::UVsgetCursorUVs (State state)
void setFont (Font *font, unsigned char states=STATE_ALL)
FontgetFont (State state=NORMAL) const
void setFontSize (unsigned int size, unsigned char states=STATE_ALL)
unsigned int getFontSize (State state=NORMAL) const
void setTextColor (const Vector4 &color, unsigned char states=STATE_ALL)
const Vector4getTextColor (State state=NORMAL) const
void setTextAlignment (Font::Justify alignment, unsigned char states=STATE_ALL)
Font::Justify getTextAlignment (State state=NORMAL) const
void setTextRightToLeft (bool rightToLeft, unsigned char states=STATE_ALL)
bool getTextRightToLeft (State state=NORMAL) const
void setVisible (bool visible)
bool isVisible () const
bool isVisibleInHierarchy () const
void setOpacity (float opacity, unsigned char states=STATE_ALL)
float getOpacity (State state=NORMAL) const
virtual void setEnabled (bool enabled)
bool isEnabled () const
bool isEnabledInHierarchy () const
State getState () const
void setConsumeInputEvents (bool consume)
bool getConsumeInputEvents ()
Theme::StylegetStyle () const
void setStyle (Theme::Style *style)
ThemegetTheme () const
int getZIndex () const
void setZIndex (int zIndex)
bool canFocus () const
void setCanFocus (bool acceptsFocus)
bool hasFocus () const
virtual bool setFocus ()
int getFocusIndex () const
void setFocusIndex (int focusIndex)
virtual bool isContainer () const
ControlgetParent () const
bool isChild (Control *control) const
FormgetTopLevelForm () const
virtual void addListener (Control::Listener *listener, int eventFlags)
virtual void removeListener (Control::Listener *listener)
virtual unsigned int getAnimationPropertyComponentCount (int propertyId) const
virtual void getAnimationPropertyValue (int propertyId, AnimationValue *value)
virtual void setAnimationPropertyValue (int propertyId, AnimationValue *value, float blendWeight=1.0f)

Static Public Attributes

static const unsigned char STATE_ALL = NORMAL | ACTIVE | FOCUS | DISABLED | HOVER
static const int ANIMATE_POSITION = 1
static const int ANIMATE_POSITION_X = 2
static const int ANIMATE_POSITION_Y = 3
static const int ANIMATE_SIZE = 4
static const int ANIMATE_SIZE_WIDTH = 5
static const int ANIMATE_SIZE_HEIGHT = 6
static const int ANIMATE_OPACITY = 7

Protected Member Functions

 Control ()
virtual ~Control ()
Controloperator= (const Control &)
void setXInternal (float x, bool percentage=false)
void setYInternal (float x, bool percentage=false)
void setWidthInternal (float width, bool percentage=false)
void setHeightInternal (float height, bool percentage=false)
Theme::Style::OverlayType getOverlayType () const
virtual bool touchEvent (Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
virtual bool keyEvent (Keyboard::KeyEvent evt, int key)
virtual bool mouseEvent (Mouse::MouseEvent evt, int x, int y, int wheelDelta)
virtual bool gamepadButtonEvent (Gamepad *gamepad)
virtual bool gamepadTriggerEvent (Gamepad *gamepad, unsigned int index)
virtual bool gamepadJoystickEvent (Gamepad *gamepad, unsigned int index)
virtual void update (float elapsedTime)
virtual void updateState (State state)
virtual void updateBounds ()
virtual void updateAbsoluteBounds (const Vector2 &offset)
void startBatch (Form *form, SpriteBatch *batch)
void finishBatch (Form *form, SpriteBatch *batch)
virtual unsigned int draw (Form *form, const Rectangle &clip)
virtual unsigned int drawBorder (Form *form, const Rectangle &clip)
virtual unsigned int drawImages (Form *form, const Rectangle &clip)
virtual unsigned int drawText (Form *form, const Rectangle &clip)
virtual void initialize (const char *typeName, Theme::Style *style, Properties *properties)
Theme::ThemeImagegetImage (const char *id, State state)
void notifyListeners (Control::Listener::EventType eventType)
virtual void controlEvent (Control::Listener::EventType evt)
void setDirty (int bits)
bool isDirty (int bit) const

Static Protected Member Functions

static State getState (const char *state)
static Alignment getAlignment (const char *alignment)
static float parseCoord (const char *s, bool *isPercentage)
static bool parseCoordPair (const char *s, float *v1, float *v2, bool *v1Percentage, bool *v2Percentage)

Protected Attributes

std::string _id
int _boundsBits
Rectangle _relativeBounds
Rectangle _bounds
Rectangle _clipBounds
Rectangle _absoluteBounds
Rectangle _absoluteClipBounds
Rectangle _viewportBounds
Rectangle _viewportClipBounds
int _dirtyBits
bool _consumeInputEvents
Alignment _alignment
AutoSize _autoSize
std::map
< Control::Listener::EventType,
std::list< Control::Listener * > * > * 
_listeners
Theme::Style_style
bool _visible
float _opacity
int _zIndex
int _contactIndex
int _focusIndex
bool _canFocus
State _state
Container_parent

Static Protected Attributes

static const int INVALID_CONTACT_INDEX = -1
static const int DIRTY_BOUNDS = 1
static const int DIRTY_STATE = 2
static const int BOUNDS_X_PERCENTAGE_BIT = 1
static const int BOUNDS_Y_PERCENTAGE_BIT = 2
static const int BOUNDS_WIDTH_PERCENTAGE_BIT = 4
static const int BOUNDS_HEIGHT_PERCENTAGE_BIT = 8
static const int BOUNDS_RADIUS_PERCENTAGE_BIT = 16

Detailed Description

Defines the base class for all controls.

See also:
http://gameplay3d.github.io/GamePlay/docs/file-formats.html#wiki-UI_Forms

Member Enumeration Documentation

Defines the set of alignments for positioning controls and justifying text.

Defines supported auto sizing modes for controls.

Enumerator:
AUTO_SIZE_NONE 

No auto sizing is applied.

AUTO_SIZE_WIDTH 

The control's width is set to tightly fit its contents.

AUTO_SIZE_HEIGHT 

The control's height is set to tightly fit its contents.

AUTO_SIZE_BOTH 

The control's width and height are set to tightly fit its contents.

The possible states a control can be in.

Enumerator:
NORMAL 

State of an enabled but inactive control.

FOCUS 

State of a control when it is currently in focus.

ACTIVE 

State of a control that is currently being acted on, e.g. through touch or mouse-click events.

DISABLED 

State of a control that has been disabled.

HOVER 

When a mouse is in use, the state of a control the cursor is over.


Constructor & Destructor Documentation

gameplay::Control::Control ( ) [protected]

Constructor.

virtual gameplay::Control::~Control ( ) [protected, virtual]

Destructor.


Member Function Documentation

virtual void gameplay::Control::addListener ( Control::Listener listener,
int  eventFlags 
) [virtual]

Adds a listener to be notified of specific events affecting this control. Event types can be OR'ed together. E.g. To listen to touch-press and touch-release events, pass Control::Listener::TOUCH | Control::Listener::RELEASE as the second parameter.

Parameters:
listenerThe listener to add.
eventFlagsThe events to listen for.

Reimplemented in gameplay::Slider, gameplay::TextBox, gameplay::CheckBox, gameplay::RadioButton, gameplay::Label, and gameplay::JoystickControl.

Determines if this control accepts focus.

Returns:
True if this control accepts focus, false if it does not.
virtual void gameplay::Control::controlEvent ( Control::Listener::EventType  evt) [protected, virtual]

Called when a control event is fired for this control, before external listeners are notified of the event.

Parameters:
evtThe event type.

Reimplemented in gameplay::TextBox, gameplay::RadioButton, and gameplay::CheckBox.

virtual unsigned int gameplay::Control::draw ( Form form,
const Rectangle clip 
) [protected, virtual]

Draws the control.

Implementations of Control are expected to perform all drawing into a SpriteBatch. Batches should not be explicitly started or finished, but instead should be passed to Control::prepare(Form*, SpriteBatch*). This will handle automatically starting and finishing the batch when neccessary.

Parameters:
formThe top level form being drawn.
clipThe clipping rectangle.
Returns:
The number of draw calls issued.

Reimplemented in gameplay::Container.

virtual unsigned int gameplay::Control::drawBorder ( Form form,
const Rectangle clip 
) [protected, virtual]

Draws the themed border and background of a control.

Implementations of Control are expected to perform all drawing into a SpriteBatch. Batches should not be explicitly started or finished, but instead should be passed to Control::prepare(Form*, SpriteBatch*). This will handle automatically starting and finishing the batch when neccessary.

Parameters:
formThe top level form being drawn.
clipThe clipping rectangle of this control's parent container.
Returns:
The number of draw calls issued.
virtual unsigned int gameplay::Control::drawImages ( Form form,
const Rectangle clip 
) [protected, virtual]

Draw the images associated with this control.

Implementations of Control are expected to perform all drawing into a SpriteBatch. Batches should not be explicitly started or finished, but instead should be passed to Control::prepare(Form*, SpriteBatch*). This will handle automatically starting and finishing the batch when neccessary.

Parameters:
formThe top level form being drawn.
clipThe clipping rectangle of this control's parent container.
Returns:
The number of draw calls issued.

Reimplemented in gameplay::Slider, gameplay::JoystickControl, gameplay::TextBox, gameplay::RadioButton, gameplay::CheckBox, and gameplay::ImageControl.

virtual unsigned int gameplay::Control::drawText ( Form form,
const Rectangle clip 
) [protected, virtual]

Draw this control's text.

Implementations of Control are expected to perform all drawing into a SpriteBatch. Batches should not be explicitly started or finished, but instead should be passed to Control::prepare(Form*, SpriteBatch*). This will handle automatically starting and finishing the batch when neccessary.

Parameters:
formThe top level form being drawn.
clipThe clipping rectangle of this control's parent container.
Returns:
The number of draw calls issued.

Reimplemented in gameplay::Slider, gameplay::TextBox, and gameplay::Label.

void gameplay::Control::finishBatch ( Form form,
SpriteBatch batch 
) [protected]

Called after a batch has been drawn into and before any other batch is used.

Parameters:
formThe form being drawn.
batchThe batch that was previously started (via Control::startBatch).
virtual bool gameplay::Control::gamepadButtonEvent ( Gamepad gamepad) [protected, virtual]

Gamepad callback on gamepad button changes.

Parameters:
gamepadThe gamepad whose one or more buttons have changed.
virtual bool gameplay::Control::gamepadJoystickEvent ( Gamepad gamepad,
unsigned int  index 
) [protected, virtual]

Gamepad callback on gamepad analog joystick changes.

Parameters:
gamepadThe gamepad whose one or more buttons have changed.
indexThe index of the joystick that changed.

Reimplemented in gameplay::Slider.

virtual bool gameplay::Control::gamepadTriggerEvent ( Gamepad gamepad,
unsigned int  index 
) [protected, virtual]

Gamepad callback on gamepad trigger changes.

Parameters:
gamepadThe gamepad whose one or more buttons have changed.
indexThe index of the trigger that changed.

Get the absolute bounds of this control, in pixels, including border and padding, before clipping.

The absolute bounds of a control represents its final computed bounds after all alignment, auto sizing, relative position and sizing has been computed. The returned bounds is in absolute coordinates, relative to the control's top-most parent container (usually its form).

Returns:
The absolute bounds of this control.

Get the alignment of this control within its parent container.

Returns:
The alignment of this control within its parent container.
static Alignment gameplay::Control::getAlignment ( const char *  alignment) [static, protected]

Gets the Alignment by string.

Parameters:
alignmentThe string representation of the Alignment type.
Returns:
The Alignment enum value corresponding to the given string.
virtual unsigned int gameplay::Control::getAnimationPropertyComponentCount ( int  propertyId) const [virtual]
virtual void gameplay::Control::getAnimationPropertyValue ( int  propertyId,
AnimationValue value 
) [virtual]
See also:
AnimationTarget::getAnimationProperty

Implements gameplay::AnimationTarget.

Reimplemented in gameplay::Container.

Returns the auto sizing mode for this control.

Returns:
The auto size mode for this control.

Get the measurements of this control's border for a given state.

Returns:
This control's border.

Get the bounds of this control, relative to its parent container and including its border and padding, before clipping.

Returns:
The bounds of this control.

Get the content area of this control, in screen coordinates, after clipping.

Returns:
The clipping area of this control.

Get the bounds of this control, relative to its parent container, after clipping.

Returns:
The bounds of this control.

Get whether this control consumes touch events.

Returns:
Whether this control consumes touch events.

Get the blend color of this control's cursor for a given state.

Parameters:
stateThe state to get this property from.
Returns:
The blend color of this control's cursor.

Get the texture region of this control's cursor for a given state.

Parameters:
stateThe state to get this property from.
Returns:
The texture region of this control's cursor.

Get the texture coordinates of this control's cursor for a given state.

Parameters:
stateThe state to get this property from.
Returns:
The texture coordinates of this control's cursor.

Get this control's focus index.

Returns:
This control's focus index.

Get the font used by this control for a given state.

Parameters:
stateThe state to get this property from.
Returns:
the font used by this control.
unsigned int gameplay::Control::getFontSize ( State  state = NORMAL) const

Get this control's font size for a given state.

Parameters:
stateThe state to get this property from.
Returns:
This control's font size.

Get the height of this control.

Returns:
The height of this control.
const char* gameplay::Control::getId ( ) const

Get this control's ID string.

Returns:
This control's ID.
Theme::ThemeImage* gameplay::Control::getImage ( const char *  id,
State  state 
) [protected]

Get a Theme::ThemeImage from its ID, for a given state.

Parameters:
idThe ID of the image to retrieve.
stateThe state to get this image from.
Returns:
The requested Theme::ThemeImage, or an empty image from the controls theme if none was found.
const Vector4& gameplay::Control::getImageColor ( const char *  id,
State  state 
) const

Get the blend color of an image used by this control for a given state.

Parameters:
idThe ID of the image.
stateThe state to get this property from.
Returns:
The blend color of the specified image.
const Rectangle& gameplay::Control::getImageRegion ( const char *  id,
State  state 
) const

Get the texture region of an image used by this control for a given state.

Parameters:
idThe ID of the image.
stateThe state to get this property from.
Returns:
The texture region of the specified image.
const Theme::UVs& gameplay::Control::getImageUVs ( const char *  id,
State  state 
) const

Get the texture coordinates of an image used by this control for a given state.

Parameters:
idThe ID of the image.
stateThe state to get this property from.
Returns:
The texture coordinates of the specified image.

Get this control's margin.

Returns:
This control's margin.
float gameplay::Control::getOpacity ( State  state = NORMAL) const

Get the opacity of this control for a given state.

Parameters:
stateThe state to get this property from.
Returns:
The opacity of this control for a given state.
Theme::Style::OverlayType gameplay::Control::getOverlayType ( ) const [protected]

Get the overlay type corresponding to this control's current state.

Returns:
The overlay type corresponding to this control's current state.

Get this control's padding.

Returns:
This control's padding.

Returns this control's parent, or NULL if this control does not have a parent.

Returns:
This control's parent.

Get the blend color of this control's skin for a given state.

Parameters:
stateThe state to get this property from.
Returns:
The blend color of this control's skin.

Get the texture region of this control's skin for a given state.

Parameters:
stateThe state to get this property from.
Returns:
The texture region of this control's skin.

Get this control's current state.

Returns:
This control's current state.
static State gameplay::Control::getState ( const char *  state) [static, protected]

Get a Control::State enum from a matching string.

Parameters:
stateThe string to match.
Returns:
The Control::State enum that matches the given string.

Get this control's style.

Returns:
This control's style.

Get this control's text alignment for a given state.

Parameters:
stateThe state to get this property from.
Returns:
This control's text alignment for the given state.

Get this control's text color for a given state.

Parameters:
stateThe state to get this property from.
Returns:
This control's text color.

Get whether text is drawn from right to left within this control, for a given state.

Parameters:
stateThe state to get this property from.
Returns:
Whether text is drawn from right to left within this control, for the given state.

Returns the theme for this control.

Returns this control's top level form, or NULL if this control does not belong to a form.

Returns:
this control's form.
const char* gameplay::Control::getTypeName ( ) const [virtual]

Extends ScriptTarget::getTypeName() to return the type name of this class.

Child controls should override this function to return the correct type name.

Returns:
The type name of this class: "Control"
See also:
ScriptTarget::getTypeName()

Implements gameplay::ScriptTarget.

Reimplemented in gameplay::Form, gameplay::Container, gameplay::Button, gameplay::TextBox, gameplay::ImageControl, gameplay::RadioButton, gameplay::Slider, gameplay::CheckBox, gameplay::JoystickControl, and gameplay::Label.

float gameplay::Control::getWidth ( ) const

Get the width of this control.

Returns:
The width of this control.
float gameplay::Control::getX ( ) const

Get the x coordinate of this control.

Returns:
The x coordinate of this control.
float gameplay::Control::getY ( ) const

Get the y coordinate of this control.

Returns:
The y coordinate of this control.

Get this control's z-index.

Returns:
This control's z-index.

Determines if this control is currently in focus.

Returns:
True if the control is currently in focus.
virtual void gameplay::Control::initialize ( const char *  typeName,
Theme::Style style,
Properties properties 
) [protected, virtual]

Initializes the control.

Parameters:
typeNameThe type name of the control being initalized.
styleThe style to apply to this control (optional).
propertiesThe properties to set on this control (optional).

Reimplemented in gameplay::Container, gameplay::Slider, gameplay::JoystickControl, gameplay::TextBox, gameplay::ImageControl, gameplay::RadioButton, gameplay::CheckBox, gameplay::Label, and gameplay::Button.

bool gameplay::Control::isChild ( Control control) const

Determines if this control is a child (at any level of hierarchy) of the specified control.

Parameters:
controlThe control to check.
Returns:
True if this control is a direct or indirect child of the specified control.
virtual bool gameplay::Control::isContainer ( ) const [virtual]

Returns whether this Control object is a Container or not.

Returns:
true if this object is of class Container, false otherwise.

Reimplemented in gameplay::Container.

bool gameplay::Control::isDirty ( int  bit) const [protected]

Determines if the specified bit is dirty.

Parameters:
bitThe bit to check.

Get whether this control is currently enabled.

Returns:
Whether this control is currently enabled.

Determines if this control is enabled in its hierarchy.

A control is enabled in its hierarchy if it is enabled and all of its parents are also enabled.

Determines if the height of this control is computed as a percentage of its parent container.

Returns:
True if the height is computed as a percentage of its parent container.

Get the visibility of a control.

Returns:
true if the control is visible; false if not visible.

Determines if this control is visible in its hierarchy.

A control is visible in its hierarchy if it is visible and all of its parents are also visible.

Determines if the width of this control is computed as a percentage of its parent container.

Returns:
True if the width is computed as a percentage of its parent container.

Determines if the X coordinate of this control computed as a percentage of its parent container.

Returns:
True if the X value is computed as a percentage of its parent container.

Determines if the Y coordinate of this control is computed as a percentage of its parent container.

Returns:
True if the Y value is computed as a percentage of its parent container.
virtual bool gameplay::Control::keyEvent ( Keyboard::KeyEvent  evt,
int  key 
) [protected, virtual]

Keyboard callback on key events.

Parameters:
evtThe key event that occurred.
keyIf evt is KEY_PRESS or KEY_RELEASE then key is the key code from Keyboard::Key. If evt is KEY_CHAR then key is the unicode value of the character.
Returns:
Whether the key event was consumed by this control.
See also:
Keyboard::KeyEvent
Keyboard::Key

Reimplemented in gameplay::Slider, gameplay::TextBox, gameplay::RadioButton, and gameplay::CheckBox.

virtual bool gameplay::Control::mouseEvent ( Mouse::MouseEvent  evt,
int  x,
int  y,
int  wheelDelta 
) [protected, virtual]

Mouse callback on mouse events.

Parameters:
evtThe mouse event that occurred.
xThe x position of the mouse in pixels. Left edge is zero.
yThe y position of the mouse in pixels. Top edge is zero.
wheelDeltaThe number of mouse wheel ticks. Positive is up (forward), negative is down (backward).
Returns:
True if the mouse event is consumed or false if it is not consumed.
See also:
Mouse::MouseEvent

Reimplemented in gameplay::Slider.

Notify this control's listeners of a specific event.

Parameters:
eventTypeThe event to trigger.
Control& gameplay::Control::operator= ( const Control ) [protected]

Hidden copy assignment operator.

static float gameplay::Control::parseCoord ( const char *  s,
bool *  isPercentage 
) [static, protected]

Converts a string in the format of either 'N' or 'N' (where N is a number) into its value and sets a flag to indicate if it should be treated as a percentage.

Parameters:
sA string in the format of either 'N' or 'N' (where N is a number)
isPercentageSet to true if the returned value should be treated as a percentage
Returns:
The number contained within the string
static bool gameplay::Control::parseCoordPair ( const char *  s,
float *  v1,
float *  v2,
bool *  v1Percentage,
bool *  v2Percentage 
) [static, protected]

Converts a string in the format of either 'N, N' or 'N%, N' (where N is a number) into its values and sets flags to indicate which numbers should be treated as percentages

Parameters:
sA string in the format of either 'N, N' or 'N%, N' (where N is a number)
v1Set to the value of the first number in the string
v2Set to the value of the second number in the string
v1PercentageSet to true if the first number should be treated as a percentage
v2PercentageSet to true if the second number should be treated as a percentage
Returns:
true if the string was parsed
virtual void gameplay::Control::removeListener ( Control::Listener listener) [virtual]

Removes a listener from this control.

Parameters:
listenerThe listener to remove.

Set the alignment of this control within its parent container.

Parameters:
alignmentThis control's alignment.
virtual void gameplay::Control::setAnimationPropertyValue ( int  propertyId,
AnimationValue value,
float  blendWeight = 1.0f 
) [virtual]
See also:
AnimationTarget::setAnimationProperty

Implements gameplay::AnimationTarget.

Reimplemented in gameplay::Container.

Sets the auto size mode for this control.

Parameters:
modeThe new auto size mode for this control.
void gameplay::Control::setBorder ( float  top,
float  bottom,
float  left,
float  right,
unsigned char  states = STATE_ALL 
)

Set the size of this control's border.

Parameters:
topThe height of the border's top side.
bottomThe height of the border's bottom side.
leftThe width of the border's left side.
rightThe width of the border's right side.
statesThe states to set this property on. One or more members of the Control::State enum, ORed together.
void gameplay::Control::setBounds ( const Rectangle bounds)

Set the bounds of this control, relative to its parent container and including its border and padding, before clipping.

This method sets the local bounds of the control, relative to its container. Setting percetage values is not supported with this method, use setX, setY, setWidth and setHeight instead.

Explicitly setting the bounds of a control clears the AutoSize bits, if set.

Parameters:
boundsThe new bounds to set.
void gameplay::Control::setCanFocus ( bool  acceptsFocus)

Sets whether or not the control accepts input focus.

Parameters:
acceptsFocusTrue if the control should accept input focus, false otherwise.

Set whether this control consumes input events, preventing them from being passed to the game.

Parameters:
consumeWhether this control consumes input events.
void gameplay::Control::setCursorColor ( const Vector4 color,
unsigned char  states 
)

Set the blend color of this control's cursor.

Parameters:
colorThe new blend color.
statesThe states to set this property on. One or more members of the Control::State enum, ORed together.
void gameplay::Control::setCursorRegion ( const Rectangle region,
unsigned char  states 
)

Set the texture region of this control's cursor.

Parameters:
regionThe cursor region.
statesThe states to set this property on. One or more members of the Control::State enum, ORed together.
void gameplay::Control::setDirty ( int  bits) [protected]

Sets dirty bits for the control.

Valid bits are any of the "DIRTY_xxx" constants from the Control class.

Parameters:
bitsDirty bits to set.
virtual void gameplay::Control::setEnabled ( bool  enabled) [virtual]

Enables/Disables a control.

Parameters:
enabledtrue if the control is enabled; false if disabled.
virtual bool gameplay::Control::setFocus ( ) [virtual]

Sets input focus to this control.

If this control accepts focus (the hasFocus method returns true), input focus is set to this control. If this control is a container, the first focusable control within it gains focus.

Returns:
True if this control or one of its children successfully gained focus, false otherwise.

Reimplemented in gameplay::Container.

void gameplay::Control::setFocusIndex ( int  focusIndex)

Set this control's focus index.

Focus indexes control the order in which input focus changes between controls when using the focus change controls such as the TAB key.

Valid focus indexes should be zero or greater, with a negative number indicating an unset focus index.

Parameters:
focusIndexThe new focus index.
void gameplay::Control::setFont ( Font font,
unsigned char  states = STATE_ALL 
)

Set the font used by this control.

Parameters:
fontThe new font to use.
statesThe states to set this property on. One or more members of the Control::State enum, ORed together.
void gameplay::Control::setFontSize ( unsigned int  size,
unsigned char  states = STATE_ALL 
)

Set this control's font size.

Parameters:
sizeThe new font size.
statesThe states to set this property on. One or more members of the Control::State enum, ORed together.
void gameplay::Control::setHeight ( float  height,
bool  percentage = false 
)

Set the desired height of the control, including it's border and padding, before clipping.

If the value is passed as a percentage of its parent container's clip region, it is interpreted as a value between 0-1, where 1 equals the full size of it's parent.

Explicitly setting the height of a control clears the AUTO_SIZE_HEIGHT bit, if set.

Parameters:
heightThe new height.
percentageTrue if the value should be interpreted as a percentage (0-1), false if it is regular number.
void gameplay::Control::setHeightInternal ( float  height,
bool  percentage = false 
) [protected]

Internal method for setting the height of the control.

The height of the control is set without modifying the existing AutoSize rules for the control.

This method is meant for internal use by the Control or descendent classes who need to modify the size of the control during bounds computation.

See also:
setHeight(float, bool)
void gameplay::Control::setId ( const char *  id)

Sets this control's ID string.

Parameters:
idThe new control ID.
void gameplay::Control::setImageColor ( const char *  id,
const Vector4 color,
unsigned char  states = STATE_ALL 
)

Set the blend color of an image used by this control.

Parameters:
idThe ID of the image to modify.
colorThe new blend color of the image.
statesThe states to set this property on. One or more members of the Control::State enum, ORed together.
void gameplay::Control::setImageRegion ( const char *  id,
const Rectangle region,
unsigned char  states = STATE_ALL 
)

Set the texture region of an image used by this control.

Parameters:
idThe ID of the image to modify.
regionThe new texture region of the image.
statesThe states to set this property on. One or more members of the Control::State enum, ORed together.
void gameplay::Control::setMargin ( float  top,
float  bottom,
float  left,
float  right 
)

Set this control's margin.

Parameters:
topHeight of top margin.
bottomHeight of bottom margin.
leftWidth of left margin.
rightWidth of right margin.
void gameplay::Control::setOpacity ( float  opacity,
unsigned char  states = STATE_ALL 
)

Set the opacity of this control.

Parameters:
opacityThe new opacity.
statesThe states to set this property on. One or more members of the Control::State enum, OR'ed together.
void gameplay::Control::setPadding ( float  top,
float  bottom,
float  left,
float  right 
)

Set this control's padding.

Parameters:
topHeight of top padding.
bottomHeight of bottom padding.
leftWidth of left padding.
rightWidth of right padding.
void gameplay::Control::setPosition ( float  x,
float  y 
)

Set the position of this control relative to its parent container.

This method sets the local position of the control, relative to its container. Setting percetage values is not supported with this method, use setX and setY instead.

Parameters:
xThe x coordinate.
yThe y coordinate.
void gameplay::Control::setSize ( float  width,
float  height 
)

Set the desired size of this control, including its border and padding, before clipping.

This method sets the size of the control, relative to its container. Setting percetage values is not supported with this method, use setWidth and setHeight instead.

Explicitly setting the size of a control clears the AutoSize bits, if set.

Parameters:
widthThe new width.
heightThe new height.
void gameplay::Control::setSkinColor ( const Vector4 color,
unsigned char  states = STATE_ALL 
)

Set the blend color of this control's skin.

Parameters:
colorThe new blend color.
statesThe states to set this property on. One or more members of the Control::State enum, ORed together.
void gameplay::Control::setSkinRegion ( const Rectangle region,
unsigned char  states = STATE_ALL 
)

Set the texture region of this control's skin.

Parameters:
regionThe texture region, in pixels.
statesThe states to set this property on. One or more members of the Control::State enum, ORed together.

Set the style this control will use when rendering.

Parameters:
styleThe style this control will use when rendering.
void gameplay::Control::setTextAlignment ( Font::Justify  alignment,
unsigned char  states = STATE_ALL 
)

Set this control's text alignment.

Parameters:
alignmentThe new text alignment.
statesThe states to set this property on. One or more members of the Control::State enum, ORed together.
void gameplay::Control::setTextColor ( const Vector4 color,
unsigned char  states = STATE_ALL 
)

Set this control's text color.

Parameters:
colorThe new text color.
statesThe states to set this property on. One or more members of the Control::State enum, ORed together.
void gameplay::Control::setTextRightToLeft ( bool  rightToLeft,
unsigned char  states = STATE_ALL 
)

Set whether text is drawn from right to left within this control.

Parameters:
rightToLeftWhether text is drawn from right to left within this control.
statesThe states to set this property on. One or more members of the Control::State enum, ORed together.
void gameplay::Control::setVisible ( bool  visible)

Sets the visibility of a control.

This is a quick way to hide a control without having to remove it from a form.

Parameters:
visibletrue if the control is visible and enabled; false if not-visible and disabled.
void gameplay::Control::setWidth ( float  width,
bool  percentage = false 
)

Set the desired width of the control, including it's border and padding, before clipping.

If the value is passed as a percentage of its parent container's clip region, it is interpreted as a value between 0-1, where 1 equals the full size of it's parent.

Explicitly setting the width of a control clears the AUTO_SIZE_WIDTH bit, if set.

Parameters:
widthThe new width.
percentageTrue if the value should be interpreted as a percentage (0-1), false if it is regular number.
void gameplay::Control::setWidthInternal ( float  width,
bool  percentage = false 
) [protected]

Internal method for setting the width of the control.

The width of the control is set without modifying the existing AutoSize rules for the control.

This method is meant for internal use by the Control or descendent classes who need to modify the size of the control during bounds computation.

See also:
setWidth(float, bool)
void gameplay::Control::setX ( float  x,
bool  percentage = false 
)

Sets the X coordinate for the control.

If the value is passed as a percentage of its parent container's clip region, it is interpreted as a value between 0-1, where 1 equals the full size of it's parent.

Parameters:
xThe new X coordinate.
percentageTrue if the value should be interpreted as a percentage (0-1), false if it is regular number.
void gameplay::Control::setXInternal ( float  x,
bool  percentage = false 
) [protected]

Internal method for setting the X position of the control.

This method is meant for internal use by the Control or descendent classes who need to modify the position of the control during bounds computation.

See also:
setX(float, bool)
void gameplay::Control::setY ( float  y,
bool  percentage = false 
)

Sets the Y coordinate for the control.

If the value is passed as a percentage of its parent container's clip region, it is interpreted as a value between 0-1, where 1 equals the full size of it's parent.

Parameters:
yThe new Y coordinate.
percentageTrue if the value should be interpreted as a percentage (0-1), false if it is regular number.
void gameplay::Control::setYInternal ( float  x,
bool  percentage = false 
) [protected]

Internal method for setting the Y position of the control.

This method is meant for internal use by the Control or descendent classes who need to modify the position of the control during bounds computation.

See also:
setY(float, bool)
void gameplay::Control::setZIndex ( int  zIndex)

Set this control's z-index.

Parameters:
zIndexThe new z-index.
void gameplay::Control::startBatch ( Form form,
SpriteBatch batch 
) [protected]

Indicates that a control will begin drawing into the specified batch.

When drawing is finshed (before any other batch can be drawn into), the finishBatch method should be called.

Parameters:
formThe form beign drawn.
batchThe sprite batch to be drawn into.
virtual bool gameplay::Control::touchEvent ( Touch::TouchEvent  evt,
int  x,
int  y,
unsigned int  contactIndex 
) [protected, virtual]

Touch callback on touch events. Controls return true if they consume the touch event.

Parameters:
evtThe touch event that occurred.
xThe x position of the touch in pixels. Left edge is zero.
yThe y position of the touch in pixels. Top edge is zero.
contactIndexThe order of occurrence for multiple touch contacts starting at zero.
Returns:
Whether the touch event was consumed by this control.
See also:
Touch::TouchEvent

Reimplemented in gameplay::Slider, gameplay::JoystickControl, and gameplay::TextBox.

virtual void gameplay::Control::update ( float  elapsedTime) [protected, virtual]

Called each frame to update this control and its children.

Any logic that must be performed every frame should be implemented here, such as custom animation or interpolation that depends on time. Layout logic should not be implemented here, but in updateBounds instead.

Parameters:
elapsedTimeTime since last frame.

Reimplemented in gameplay::Container, gameplay::Slider, gameplay::Form, and gameplay::Label.

virtual void gameplay::Control::updateAbsoluteBounds ( const Vector2 offset) [protected, virtual]

Updates the absolute bounds for this control and its children.

Parameters:
offsetOffset to add to the control's position (most often used for scrolling).

Reimplemented in gameplay::Container, gameplay::JoystickControl, gameplay::RadioButton, gameplay::CheckBox, and gameplay::Label.

virtual void gameplay::Control::updateBounds ( ) [protected, virtual]

Updates the local bounds for this control and its children.

Child controls that need to customize their bounds calculation should override this method.

Reimplemented in gameplay::Container, gameplay::Slider, gameplay::ImageControl, gameplay::RadioButton, gameplay::CheckBox, and gameplay::Label.

virtual void gameplay::Control::updateState ( State  state) [protected, virtual]

Called when the state of the control has been updated.

When the state of a control is updated (for example, a control becomes active, focused, hovered, disabled, etc), this method is called to allow implementations to update internal data related to control state.

Parameters:
stateThe new control state.

Reimplemented in gameplay::Container, gameplay::Slider, gameplay::TextBox, gameplay::RadioButton, gameplay::CheckBox, and gameplay::Label.


Member Data Documentation

Absolute bounds, including border and padding, before clipping.

Absolute bounds, including border and padding, after clipping.

The Control's Alignment

The Control's auto size mode.

Local bounds, relative to parent container's clipping window, and desired size.

Bits indicating whether bounds values are absolute values or percentages.

bool gameplay::Control::_canFocus [protected]

Whether or not the control accepts input focus.

Local bounds, relative to parent container's clipping window, including border and padding, after clipping.

Flag for whether the Control consumes input events.

The contact index assigned to this control.

Control dirty bits.

The focus order of the control.

std::string gameplay::Control::_id [protected]

The Control's ID.

Listeners map of EventType's to a list of Listeners.

float gameplay::Control::_opacity [protected]

The current opacity of the control.

The control's parent container.

Local bounds, relative to parent container's clipping window, possibly stored as percentages (see _boundsBits).

This control's current state.

Absolute bounds of content area (i.e. without border and padding), before clipping.

Absolute bounds of content area (i.e. without border and padding), after clipping.

bool gameplay::Control::_visible [protected]

The control is not visible and _state become DISABLED if false.

int gameplay::Control::_zIndex [protected]

The z-order of the control.

const int gameplay::Control::ANIMATE_OPACITY = 7 [static]

Opacity property. Data = opacity

const int gameplay::Control::ANIMATE_POSITION = 1 [static]

Position animation property. Data = x, y

const int gameplay::Control::ANIMATE_POSITION_X = 2 [static]

Position x animation property. Data = x

const int gameplay::Control::ANIMATE_POSITION_Y = 3 [static]

Position y animation property. Data = y

const int gameplay::Control::ANIMATE_SIZE = 4 [static]

Size animation property. Data = width, height

Size height animation property. Data = height

const int gameplay::Control::ANIMATE_SIZE_WIDTH = 5 [static]

Size width animation property. Data = width

const int gameplay::Control::BOUNDS_HEIGHT_PERCENTAGE_BIT = 8 [static, protected]

Indicates that the height of the control is a percentage.

const int gameplay::Control::BOUNDS_RADIUS_PERCENTAGE_BIT = 16 [static, protected]

Indicates that the radius of the control is a percentage.

const int gameplay::Control::BOUNDS_WIDTH_PERCENTAGE_BIT = 4 [static, protected]

Indicates that the width of the control is a percentage.

const int gameplay::Control::BOUNDS_X_PERCENTAGE_BIT = 1 [static, protected]

Indicates that the x position of the control is a percentage.

const int gameplay::Control::BOUNDS_Y_PERCENTAGE_BIT = 2 [static, protected]

Indicates that the y position of the control is a percentage.

const int gameplay::Control::DIRTY_BOUNDS = 1 [static, protected]

Indicates that the bounds of the control are dirty.

const int gameplay::Control::DIRTY_STATE = 2 [static, protected]

Indicates that the state of the control is dirty.

const int gameplay::Control::INVALID_CONTACT_INDEX = -1 [static, protected]

Constant value representing an unset or invalid contact index.

const unsigned char gameplay::Control::STATE_ALL = NORMAL | ACTIVE | FOCUS | DISABLED | HOVER [static]
A constant used for setting themed attributes on all control states simultaneously.

 All Classes Functions Variables Typedefs Enumerations Enumerator