|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

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:

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 Rectangle & | getBounds () const
void | setBounds (const Rectangle &bounds)
const Rectangle & | getAbsoluteBounds () const
const Rectangle & | getClipBounds () const
const Rectangle & | getClip () 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::Border & | getBorder (State state=NORMAL) const
void | setSkinRegion (const Rectangle &region, unsigned char states=STATE_ALL)
const Rectangle & | getSkinRegion (State state=NORMAL) const
void | setSkinColor (const Vector4 &color, unsigned char states=STATE_ALL)
const Vector4 & | getSkinColor (State state=NORMAL) const
void | setMargin (float top, float bottom, float left, float right)
const Theme::Margin & | getMargin () const
void | setPadding (float top, float bottom, float left, float right)
const Theme::Padding & | getPadding () const
void | setImageRegion (const char *id, const Rectangle &region, unsigned char states=STATE_ALL)
const Rectangle & | getImageRegion (const char *id, State state) const
void | setImageColor (const char *id, const Vector4 &color, unsigned char states=STATE_ALL)
const Vector4 & | getImageColor (const char *id, State state) const
const Theme::UVs & | getImageUVs (const char *id, State state) const
void | setCursorRegion (const Rectangle &region, unsigned char states)
const Rectangle & | getCursorRegion (State state) const
void | setCursorColor (const Vector4 &color, unsigned char states)
const Vector4 & | getCursorColor (State state)
const Theme::UVs & | getCursorUVs (State state)
void | setFont (Font *font, unsigned char states=STATE_ALL)
Font * | getFont (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 Vector4 & | getTextColor (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::Style * | getStyle () const
void | setStyle (Theme::Style *style)
Theme * | getTheme () 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
Control * | getParent () const
bool | isChild (Control *control) const
Form * | getTopLevelForm () 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 ()
Control & | operator= (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::ThemeImage * | getImage (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

enum gameplay::Control::Alignment

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

enum gameplay::Control::AutoSize

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.

enum gameplay::Control::State

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:

  listener | The listener to add.
  eventFlags | The events to listen for.

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

bool gameplay::Control::canFocus | ( |  | ) | const

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:

  evt | The 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:

  form | The top level form being drawn.
  clip | The 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:

  form | The top level form being drawn.
  clip | The 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:

  form | The top level form being drawn.
  clip | The 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:

  form | The top level form being drawn.
  clip | The 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:

  form | The form being drawn.
  batch | The batch that was previously started (via Control::startBatch).

virtual bool gameplay::Control::gamepadButtonEvent | ( | Gamepad * | gamepad | ) | `[protected, virtual]`

Gamepad callback on gamepad button changes.

Parameters:

  gamepad | The 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:

  gamepad | The gamepad whose one or more buttons have changed.
  index | The 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:

  gamepad | The gamepad whose one or more buttons have changed.
  index | The index of the trigger that changed.

const Rectangle& gameplay::Control::getAbsoluteBounds | ( |  | ) | const

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.

Alignment gameplay::Control::getAlignment | ( |  | ) | const

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:

  alignment | The 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]`

See also:
  AnimationTarget::getAnimationPropertyComponentCount

Implements gameplay::AnimationTarget.

Reimplemented in gameplay::Container.

virtual void gameplay::Control::getAnimationPropertyValue | ( | int | propertyId,
|  | AnimationValue * | value
| ) |  | `[virtual]`

See also:
  AnimationTarget::getAnimationProperty

Implements gameplay::AnimationTarget.

Reimplemented in gameplay::Container.

AutoSize gameplay::Control::getAutoSize | ( |  | ) | const

Returns the auto sizing mode for this control.

Returns:
  The auto size mode for this control.

const Theme::Border& gameplay::Control::getBorder | ( | State | state = `NORMAL` | ) | const

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

Returns:
  This control's border.

const Rectangle& gameplay::Control::getBounds | ( |  | ) | const

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.

const Rectangle& gameplay::Control::getClip | ( |  | ) | const

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

Returns:
  The clipping area of this control.

const Rectangle& gameplay::Control::getClipBounds | ( |  | ) | const

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

Returns:
  The bounds of this control.

bool gameplay::Control::getConsumeInputEvents | ( |  | ) |

Get whether this control consumes touch events.

Returns:
  Whether this control consumes touch events.

const Vector4& gameplay::Control::getCursorColor | ( | State | state | ) |

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

Parameters:

  state | The state to get this property from.

Returns:
  The blend color of this control's cursor.

const Rectangle& gameplay::Control::getCursorRegion | ( | State | state | ) | const

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

Parameters:

  state | The state to get this property from.

Returns:
  The texture region of this control's cursor.

const Theme::UVs& gameplay::Control::getCursorUVs | ( | State | state | ) |

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

Parameters:

  state | The state to get this property from.

Returns:
  The texture coordinates of this control's cursor.

int gameplay::Control::getFocusIndex | ( |  | ) | const

Get this control's focus index.

Returns:
  This control's focus index.

Font* gameplay::Control::getFont | ( | State | state = `NORMAL` | ) | const

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

Parameters:

  state | The 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:

  state | The state to get this property from.

Returns:
  This control's font size.

float gameplay::Control::getHeight | ( |  | ) | const

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:

  id | The ID of the image to retrieve.
  state | The 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:

  id | The ID of the image.
  state | The 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:

  id | The ID of the image.
  state | The 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:

  id | The ID of the image.
  state | The state to get this property from.

Returns:
  The texture coordinates of the specified image.

const Theme::Margin& gameplay::Control::getMargin | ( |  | ) | const

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:

  state | The 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.

const Theme::Padding& gameplay::Control::getPadding | ( |  | ) | const

Get this control's padding.

Returns:
  This control's padding.

Control* gameplay::Control::getParent | ( |  | ) | const

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

Returns:
  This control's parent.

const Vector4& gameplay::Control::getSkinColor | ( | State | state = `NORMAL` | ) | const

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

Parameters:

  state | The state to get this property from.

Returns:
  The blend color of this control's skin.

const Rectangle& gameplay::Control::getSkinRegion | ( | State | state = `NORMAL` | ) | const

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

Parameters:

  state | The state to get this property from.

Returns:
  The texture region of this control's skin.

State gameplay::Control::getState | ( |  | ) | const

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:

  state | The string to match.

Returns:
  The Control::State enum that matches the given string.

Theme::Style* gameplay::Control::getStyle | ( |  | ) | const

Get this control's style.

Returns:
  This control's style.

Font::Justify gameplay::Control::getTextAlignment | ( | State | state = `NORMAL` | ) | const

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

Parameters:

  state | The state to get this property from.

Returns:
  This control's text alignment for the given state.

const Vector4& gameplay::Control::getTextColor | ( | State | state = `NORMAL` | ) | const

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

Parameters:

  state | The state to get this property from.

Returns:
  This control's text color.

bool gameplay::Control::getTextRightToLeft | ( | State | state = `NORMAL` | ) | const

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

Parameters:

  state | The state to get this property from.

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

Theme* gameplay::Control::getTheme | ( |  | ) | const

Returns the theme for this control.

Form* gameplay::Control::getTopLevelForm | ( |  | ) | const

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.

int gameplay::Control::getZIndex | ( |  | ) | const

Get this control's z-index.

Returns:
  This control's z-index.

bool gameplay::Control::hasFocus | ( |  | ) | const

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:

  typeName | The type name of the control being initalized.
  style | The style to apply to this control (optional).
  properties | The 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:

  control | The 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:

  bit | The bit to check.

bool gameplay::Control::isEnabled | ( |  | ) | const

Get whether this control is currently enabled.

Returns:
  Whether this control is currently enabled.

bool gameplay::Control::isEnabledInHierarchy | ( |  | ) | const

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.

bool gameplay::Control::isHeightPercentage | ( |  | ) | const

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.

bool gameplay::Control::isVisible | ( |  | ) | const

Get the visibility of a control.

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

bool gameplay::Control::isVisibleInHierarchy | ( |  | ) | const

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.

bool gameplay::Control::isWidthPercentage | ( |  | ) | const

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.

bool gameplay::Control::isXPercentage | ( |  | ) | const

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.

bool gameplay::Control::isYPercentage | ( |  | ) | const

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:

  evt | The key event that occurred.
  key | If 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:

  evt | The mouse event that occurred.
  x | The x position of the mouse in pixels. Left edge is zero.
  y | The y position of the mouse in pixels. Top edge is zero.
  wheelDelta | The 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.

void gameplay::Control::notifyListeners | ( | Control::Listener::EventType | eventType | ) | `[protected]`

Notify this control's listeners of a specific event.

Parameters:

  eventType | The 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:

  s | A string in the format of either 'N' or 'N' (where N is a number)
  isPercentage | Set 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:

  s | A string in the format of either 'N, N' or 'N%, N' (where N is a number)
  v1 | Set to the value of the first number in the string
  v2 | Set to the value of the second number in the string
  v1Percentage | Set to true if the first number should be treated as a percentage
  v2Percentage | Set 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:

  listener | The listener to remove.

void gameplay::Control::setAlignment | ( | Alignment | alignment | ) |

Set the alignment of this control within its parent container.

Parameters:

  alignment | This 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.

void gameplay::Control::setAutoSize | ( | AutoSize | mode | ) |

Sets the auto size mode for this control.

Parameters:

  mode | The 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:

  top | The height of the border's top side.
  bottom | The height of the border's bottom side.
  left | The width of the border's left side.
  right | The width of the border's right side.
  states | The 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:

  bounds | The new bounds to set.

void gameplay::Control::setCanFocus | ( | bool | acceptsFocus | ) |

Sets whether or not the control accepts input focus.

Parameters:

  acceptsFocus | True if the control should accept input focus, false otherwise.

void gameplay::Control::setConsumeInputEvents | ( | bool | consume | ) |

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

Parameters:

  consume | Whether 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:

  color | The new blend color.
  states | The 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:

  region | The cursor region.
  states | The 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:

  bits | Dirty bits to set.

virtual void gameplay::Control::setEnabled | ( | bool | enabled | ) | `[virtual]`

Enables/Disables a control.

Parameters:

  enabled | true 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:

  focusIndex | The new focus index.

void gameplay::Control::setFont | ( | Font * | font,
|  | unsigned char | states = `STATE_ALL`
| ) |  |

Set the font used by this control.

Parameters:

  font | The new font to use.
  states | The 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:

  size | The new font size.
  states | The 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:

  height | The new height.
  percentage | True 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:

  id | The 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:

  id | The ID of the image to modify.
  color | The new blend color of the image.
  states | The 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:

  id | The ID of the image to modify.
  region | The new texture region of the image.
  states | The 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:

  top | Height of top margin.
  bottom | Height of bottom margin.
  left | Width of left margin.
  right | Width of right margin.

void gameplay::Control::setOpacity | ( | float | opacity,
|  | unsigned char | states = `STATE_ALL`
| ) |  |

Set the opacity of this control.

Parameters:

  opacity | The new opacity.
  states | The 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:

  top | Height of top padding.
  bottom | Height of bottom padding.
  left | Width of left padding.
  right | Width 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:

  x | The x coordinate.
  y | The 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:

  width | The new width.
  height | The new height.

void gameplay::Control::setSkinColor | ( | const Vector4 & | color,
|  | unsigned char | states = `STATE_ALL`
| ) |  |

Set the blend color of this control's skin.

Parameters:

  color | The new blend color.
  states | The 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:

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

void gameplay::Control::setStyle | ( | Theme::Style * | style | ) |

Set the style this control will use when rendering.

Parameters:

  style | The 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:

  alignment | The new text alignment.
  states | The 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:

  color | The new text color.
  states | The 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:

  rightToLeft | Whether text is drawn from right to left within this control.
  states | The 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:

  visible | true 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:

  width | The new width.
  percentage | True 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:

  x | The new X coordinate.
  percentage | True 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:

  y | The new Y coordinate.
  percentage | True 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:

  zIndex | The 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:

  form | The form beign drawn.
  batch | The 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:

  evt | The touch event that occurred.
  x | The x position of the touch in pixels. Left edge is zero.
  y | The y position of the touch in pixels. Top edge is zero.
  contactIndex | The 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:

  elapsedTime | Time 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:

  offset | Offset 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:

  state | The new control state.

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

## Member Data Documentation

Rectangle gameplay::Control::_absoluteBounds `[protected]`

Absolute bounds, including border and padding, before clipping.

Rectangle gameplay::Control::_absoluteClipBounds `[protected]`

Absolute bounds, including border and padding, after clipping.

Alignment gameplay::Control::_alignment `[protected]`

The Control's Alignment

AutoSize gameplay::Control::_autoSize `[protected]`

The Control's auto size mode.

Rectangle gameplay::Control::_bounds `[protected]`

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

int gameplay::Control::_boundsBits `[protected]`

Bits indicating whether bounds values are absolute values or percentages.

bool gameplay::Control::_canFocus `[protected]`

Whether or not the control accepts input focus.

Rectangle gameplay::Control::_clipBounds `[protected]`

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

bool gameplay::Control::_consumeInputEvents `[protected]`

Flag for whether the Control consumes input events.

int gameplay::Control::_contactIndex `[protected]`

The contact index assigned to this control.

int gameplay::Control::_dirtyBits `[protected]`

Control dirty bits.

int gameplay::Control::_focusIndex `[protected]`

The focus order of the control.

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

The Control's ID.

std::map<Control::Listener::EventType, std::list<Control::Listener*>*>* gameplay::Control::_listeners `[protected]`

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

float gameplay::Control::_opacity `[protected]`

The current opacity of the control.

Container* gameplay::Control::_parent `[protected]`

The control's parent container.

Rectangle gameplay::Control::_relativeBounds `[protected]`

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

State gameplay::Control::_state `[protected]`

This control's current state.

Theme::Style* gameplay::Control::_style `[protected]`

The Control's Theme::Style.

Rectangle gameplay::Control::_viewportBounds `[protected]`

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

Rectangle gameplay::Control::_viewportClipBounds `[protected]`

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

const int gameplay::Control::ANIMATE_SIZE_HEIGHT = 6`[static]`

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