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

- Main Page
- Classes

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

All Classes Functions Variables Typedefs Enumerations Enumerator
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes
gameplay::Container Class Reference

`#include <Container.h>`

Inheritance diagram for gameplay::Container:

List of all members.

## Public Types

enum | Scroll { SCROLL_NONE = 0, SCROLL_HORIZONTAL = 0x01, SCROLL_VERTICAL = 0x02, SCROLL_BOTH = SCROLL_HORIZONTAL | SCROLL_VERTICAL }
enum | Direction { UP = 0x01, DOWN = 0x02, LEFT = 0x04, RIGHT = 0x08, NEXT = 0x10, PREVIOUS = 0x20 }

## Public Member Functions

const char * | getTypeName () const
Layout * | getLayout ()
void | setLayout (Layout::Type type)
unsigned int | addControl (Control *control)
void | insertControl (Control *control, unsigned int index)
void | removeControl (unsigned int index)
void | removeControl (const char *id)
void | removeControl (Control *control)
Control * | getControl (unsigned int index) const
Control * | getControl (const char *id) const
unsigned int | getControlCount () const
const std::vector< Control * > & | getControls () const
virtual bool | isForm () const
void | setScroll (Scroll scroll)
Scroll | getScroll () const
void | setScrollBarsAutoHide (bool autoHide)
bool | isScrollBarsAutoHide () const
bool | isScrolling () const
void | stopScrolling ()
float | getScrollingFriction () const
void | setScrollingFriction (float friction)
float | getScrollWheelSpeed () const
void | setScrollWheelSpeed (float speed)
const Vector2 & | getScrollPosition () const
void | setScrollPosition (const Vector2 &scrollPosition)
Animation * | getAnimation (const char *id=NULL) const
bool | isContainer () const
bool | getScrollWheelRequiresFocus () const
void | setScrollWheelRequiresFocus (bool required)
bool | setFocus ()
bool | moveFocus (Direction direction)
Control * | getActiveControl () const
void | setActiveControl (Control *control)
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 Member Functions

static Container * | create (const char *id, Theme::Style *style=NULL, Layout::Type layout=Layout::LAYOUT_ABSOLUTE)

## Static Public Attributes

static const int | ANIMATE_SCROLLBAR_OPACITY = 8

## Protected Member Functions

| Container ()
virtual | ~Container ()
void | initialize (const char *typeName, Theme::Style *style, Properties *properties)
void | update (float elapsedTime)
void | updateState (State state)
void | updateBounds ()
void | updateAbsoluteBounds (const Vector2 &offset)
bool | updateChildBounds ()
void | setChildrenDirty (int bits, bool recursive)
void | addControls (Properties *properties)
virtual unsigned int | draw (Form *form, const Rectangle &clip)
void | updateScroll ()
void | sortControls ()
bool | touchEventScroll (Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
bool | mouseEventScroll (Mouse::MouseEvent evt, int x, int y, int wheelDelta)

## Static Protected Member Functions

static Control * | create (Theme::Style *style, Properties *properties=NULL)
static Layout::Type | getLayoutType (const char *layoutString)
static Layout * | createLayout (Layout::Type type)
static Scroll | getScroll (const char *scroll)

## Protected Attributes

Layout * | _layout
std::vector< Control * > | _controls
Control * | _activeControl
Theme::ThemeImage * | _scrollBarTopCap
Theme::ThemeImage * | _scrollBarVertical
Theme::ThemeImage * | _scrollBarBottomCap
Theme::ThemeImage * | _scrollBarLeftCap
Theme::ThemeImage * | _scrollBarHorizontal
Theme::ThemeImage * | _scrollBarRightCap
Scroll | _scroll
Rectangle | _scrollBarBounds
Vector2 | _scrollPosition
bool | _scrollBarsAutoHide
float | _scrollBarOpacity
bool | _scrolling
int | _scrollingVeryFirstX
int | _scrollingVeryFirstY
int | _scrollingFirstX
int | _scrollingFirstY
int | _scrollingLastX
int | _scrollingLastY
double | _scrollingStartTimeX
double | _scrollingStartTimeY
double | _scrollingLastTime
Vector2 | _scrollingVelocity
float | _scrollingFriction
float | _scrollWheelSpeed
bool | _scrollingRight
bool | _scrollingDown
bool | _scrollingMouseVertically
bool | _scrollingMouseHorizontally

## Detailed Description

Defines a container that contains zero or more controls.

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

## Member Enumeration Documentation

enum gameplay::Container::Direction

Defines supported focus chagne directions.

enum gameplay::Container::Scroll

The definition for container scrolling.

## Constructor & Destructor Documentation

gameplay::Container::Container | ( |  | ) | `[protected]`

Constructor.

virtual gameplay::Container::~Container | ( |  | ) | `[protected, virtual]`

Destructor.

## Member Function Documentation

unsigned int gameplay::Container::addControl | ( | Control * | control | ) |

Adds a new control to this container.

Parameters:

  control | The control to add.

Returns:
  The index assigned to the new Control.

void gameplay::Container::addControls | ( | Properties * | properties | ) | `[protected]`

Adds controls nested within a properties object to this container.

Parameters:

  properties | The properties to use.

static Container* gameplay::Container::create | ( | const char * | id,
|  | Theme::Style * | style = `NULL`,
|  | Layout::Type | layout = `Layout::LAYOUT_ABSOLUTE`
| ) |  | `[static]`

Creates a new container.

Parameters:

  id | The container ID.
  style | The container style (optional).
  layout | The container layout (optional).

Returns:
  The new container.

Reimplemented in gameplay::Form.

static Control* gameplay::Container::create | ( | Theme::Style * | style,
|  | Properties * | properties = `NULL`
| ) |  | `[static, protected]`

Create a container with a given style and properties, including a list of controls.

Parameters:

  style | The style to apply to this container.
  properties | A properties object containing a definition of the container and its nested controls (optional).

Returns:
  The new container.

static Layout* gameplay::Container::createLayout | ( | Layout::Type | type | ) | `[static, protected]`

Creates a layout for the specified layout type.

Parameters:

  type | The type of layout to create.

Returns:
  The new Layout.

virtual unsigned int gameplay::Container::draw | ( | Form * | form,
|  | const Rectangle & | clip
| ) |  | `[protected, virtual]`

See also:
  Control::draw

Reimplemented from gameplay::Control.

Control* gameplay::Container::getActiveControl | ( |  | ) | const

Returns the currently active control for this container.

Returns:
  This container's active control.

Animation* gameplay::Container::getAnimation | ( | const char * | id = `NULL` | ) | const

See also:
  AnimationTarget::getAnimation

Reimplemented from gameplay::AnimationTarget.

virtual unsigned int gameplay::Container::getAnimationPropertyComponentCount | ( | int | propertyId | ) | const`[virtual]`

See also:
  AnimationTarget::getAnimationPropertyComponentCount

Reimplemented from gameplay::Control.

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

See also:
  AnimationTarget::getAnimationProperty

Reimplemented from gameplay::Control.

Control* gameplay::Container::getControl | ( | unsigned int | index | ) | const

Get the Control at a specific index.

Parameters:

  index | The index at which to retrieve the Control.

Returns:
  The Control at the given index.

Control* gameplay::Container::getControl | ( | const char * | id | ) | const

Get a Control with a specific ID that belongs to this Layout.

Parameters:

  id | The ID of the Control to search for.

unsigned int gameplay::Container::getControlCount | ( |  | ) | const

Returns the number of child controls for this container.

Returns:
  The number of child controls.

const std::vector<Control*>& gameplay::Container::getControls | ( |  | ) | const

Get the vector of controls within this container.

Returns:
  The vector of the controls within this container.

Layout* gameplay::Container::getLayout | ( |  | ) |

Get this container's layout.

Returns:
  This container's layout object.

static Layout::Type gameplay::Container::getLayoutType | ( | const char * | layoutString | ) | `[static, protected]`

Gets a Layout::Type enum from a matching string.

Parameters:

  layoutString | The layout string to parse

Returns:
  The parsed layout type.

Scroll gameplay::Container::getScroll | ( |  | ) | const

Gets the allowed scroll directions for this container.

Returns:
  The allowed scroll directions for this container.

static Scroll gameplay::Container::getScroll | ( | const char * | scroll | ) | `[static, protected]`

Get a Scroll enum from a matching string.

Parameters:

  scroll | A string representing a Scroll enum.

Returns:
  The Scroll enum value that matches the given string.

float gameplay::Container::getScrollingFriction | ( |  | ) | const

Get the friction applied to scrolling velocity for this container.

const Vector2& gameplay::Container::getScrollPosition | ( |  | ) | const

Get an offset of how far this layout has been scrolled in each direction.

bool gameplay::Container::getScrollWheelRequiresFocus | ( |  | ) | const

Get whether this container requires focus in order to handle scroll-wheel events.

float gameplay::Container::getScrollWheelSpeed | ( |  | ) | const

Get the speed added to scrolling velocity on a scroll-wheel event.

const char* gameplay::Container::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: "Container"

See also:
  ScriptTarget::getTypeName()

Reimplemented from gameplay::Control.

Reimplemented in gameplay::Form.

void gameplay::Container::initialize | ( | const char * | typeName,
|  | Theme::Style * | style,
|  | Properties * | properties
| ) |  | `[protected, virtual]`

See also:
  Control::initialize

Reimplemented from gameplay::Control.

void gameplay::Container::insertControl | ( | Control * | control,
|  | unsigned int | index
| ) |  |

Inserts a control at a specific index.

Parameters:

  control | The control to insert.
  index | The index at which to insert the control.

bool gameplay::Container::isContainer | ( |  | ) | const`[virtual]`

See also:
  Control::isContainer

Reimplemented from gameplay::Control.

virtual bool gameplay::Container::isForm | ( |  | ) | const`[virtual]`

Determines if this container is a top level form.

Returns:
  True if the container is a top level form, false otherwise.

Reimplemented in gameplay::Form.

bool gameplay::Container::isScrollBarsAutoHide | ( |  | ) | const

Whether scrollbars are always visible, or only visible while scrolling.

Returns:
  Whether scrollbars are always visible.

bool gameplay::Container::isScrolling | ( |  | ) | const

Whether this container is currently being scrolled.

Returns:
  Whether this container is currently being scrolled.

bool gameplay::Container::mouseEventScroll | ( | Mouse::MouseEvent | evt,
|  | int | x,
|  | int | y,
|  | int | wheelDelta
| ) |  | `[protected]`

Mouse scroll event callback.

Parameters:

  evt | The mouse scroll event that occurred.
  x | The x position of the scroll in pixels. Left edge is zero.
  y | The y position of the scroll in pixels. Top edge is zero.
  wheelDelta | The value change of the mouse's scroll wheel.

Returns:
  Whether the scroll event was consumed by scrolling within this container.

See also:
  Mouse::MouseEvent

bool gameplay::Container::moveFocus | ( | Direction | direction | ) |

Attempts to switch focus to a child of this container in the specified direction.

Parameters:

  direction | The direction for focus change.

Returns:
  True on success, false if there are no controls to focus on.

void gameplay::Container::removeControl | ( | unsigned int | index | ) |

Remove a control at a specific index.

Parameters:

  index | The index from which to remove the control.

void gameplay::Container::removeControl | ( | const char * | id | ) |

Remove a control with the given ID.

Parameters:

  id | The ID of the control to remove.

void gameplay::Container::removeControl | ( | Control * | control | ) |

Remove a specific control.

Parameters:

  control | The control to remove.

void gameplay::Container::setActiveControl | ( | Control * | control | ) |

Sets the active control for this container.

A container's active control is the control that will receive focus when the container receives focus.

Parameters:

  control | The container's new active control (must be a child of this container).

virtual void gameplay::Container::setAnimationPropertyValue | ( | int | propertyId,
|  | AnimationValue * | value,
|  | float | blendWeight = `1.0f`
| ) |  | `[virtual]`

See also:
  AnimationTarget::setAnimationProperty

Reimplemented from gameplay::Control.

void gameplay::Container::setChildrenDirty | ( | int | bits,
|  | bool | recursive
| ) |  | `[protected]`

Sets the specified dirty bits for all children within this container.

Parameters:

  bits | The bits to set.
  recursive | If true, set the bits recursively on all children and their children.

bool gameplay::Container::setFocus | ( |  | ) | `[virtual]`

See also:
  Control::setFocus

Reimplemented from gameplay::Control.

void gameplay::Container::setLayout | ( | Layout::Type | type | ) |

Sets the layout type for this container.

Parameters:

  type | The new layout type for the container.

void gameplay::Container::setScroll | ( | Scroll | scroll | ) |

Sets the allowed scroll directions for this container.

Parameters:

  scroll | The allowed scroll directions for this container.

void gameplay::Container::setScrollBarsAutoHide | ( | bool | autoHide | ) |

Set whether scrollbars auto hidden when they become static.

Parameters:

  autoHide | true to auto hide the scrollbars when they become static.

void gameplay::Container::setScrollingFriction | ( | float | friction | ) |

Get the friction applied to scrolling velocity for this container. A higher value will bring the viewport to a stop sooner.

void gameplay::Container::setScrollPosition | ( | const Vector2 & | scrollPosition | ) |

Set an offset of how far this layout has been scrolled in each direction.

void gameplay::Container::setScrollWheelRequiresFocus | ( | bool | required | ) |

Set whether this container requires focus in order to handle scroll-wheel events. If this property is set to true, scroll-wheel events will only be handled when the container has focus. If this property is set tofalse, scroll-wheel events will only be handled when the container is in the HOVER state.

Parameters:

  required | Whether focus is required in order to handle scroll-wheel events.

void gameplay::Container::setScrollWheelSpeed | ( | float | speed | ) |

Set the speed added to scrolling velocity on a scroll-wheel event.

void gameplay::Container::sortControls | ( |  | ) | `[protected]`

Sorts controls by Z-Order (for absolute layouts only). This method is used by controls to notify their parent container when their Z-Index changes.

void gameplay::Container::stopScrolling | ( |  | ) |

Stops this container from scrolling if it is currently being scrolled.

bool gameplay::Container::touchEventScroll | ( | Touch::TouchEvent | evt,
|  | int | x,
|  | int | y,
|  | unsigned int | contactIndex
| ) |  | `[protected]`

Applies touch events to scroll state.

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 scrolling within this container.

See also:
  Touch::TouchEvent

void gameplay::Container::update | ( | float | elapsedTime | ) | `[protected, virtual]`

See also:
  Control::update

Reimplemented from gameplay::Control.

Reimplemented in gameplay::Form.

void gameplay::Container::updateAbsoluteBounds | ( | const Vector2 & | offset | ) | `[protected, virtual]`

See also:
  Control::updateAbsoluteBounds

Reimplemented from gameplay::Control.

void gameplay::Container::updateBounds | ( |  | ) | `[protected, virtual]`

See also:
  Control::updateBounds

Reimplemented from gameplay::Control.

bool gameplay::Container::updateChildBounds | ( |  | ) | `[protected]`

Updates the bounds for this container's child controls.

void gameplay::Container::updateScroll | ( |  | ) | `[protected]`

Update scroll position and velocity.

void gameplay::Container::updateState | ( | State | state | ) | `[protected, virtual]`

See also:
  Control::updateState

Reimplemented from gameplay::Control.

## Member Data Documentation

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

The active control for the container.

std::vector<Control*> gameplay::Container::_controls `[protected]`

List of controls within the container.

Layout* gameplay::Container::_layout `[protected]`

The container's layout.

Scroll gameplay::Container::_scroll `[protected]`

Flag representing whether scrolling is enabled, and in which directions.

Theme::ThemeImage* gameplay::Container::_scrollBarBottomCap `[protected]`

Scrollbar bottom cap image.

Rectangle gameplay::Container::_scrollBarBounds `[protected]`

Scroll bar bounds.

Theme::ThemeImage* gameplay::Container::_scrollBarHorizontal `[protected]`

Scrollbar horizontal track image.

Theme::ThemeImage* gameplay::Container::_scrollBarLeftCap `[protected]`

Scrollbar left cap image.

float gameplay::Container::_scrollBarOpacity `[protected]`

Used to animate scrollbars fading out.

Theme::ThemeImage* gameplay::Container::_scrollBarRightCap `[protected]`

Scrollbar horizontal image.

bool gameplay::Container::_scrollBarsAutoHide `[protected]`

Whether the scrollbars should auto-hide. Default is false.

Theme::ThemeImage* gameplay::Container::_scrollBarTopCap `[protected]`

Scrollbar top cap image.

Theme::ThemeImage* gameplay::Container::_scrollBarVertical `[protected]`

Scrollbar vertical track image.

bool gameplay::Container::_scrolling `[protected]`

Whether the user is currently touching / holding the mouse down within this layout's container.

bool gameplay::Container::_scrollingDown `[protected]`

Are we scrolling down?

int gameplay::Container::_scrollingFirstX `[protected]`

First scrolling touch x position since last change in direction.

int gameplay::Container::_scrollingFirstY `[protected]`

First scrolling touch y position since last change in direction.

float gameplay::Container::_scrollingFriction `[protected]`

Friction dampens velocity.

double gameplay::Container::_scrollingLastTime `[protected]`

The last time we were scrolling.

int gameplay::Container::_scrollingLastX `[protected]`

The last y position when scrolling.

int gameplay::Container::_scrollingLastY `[protected]`

The last x position when scrolling.

bool gameplay::Container::_scrollingMouseHorizontally `[protected]`

Locked to scrolling horizontally by grabbing the scrollbar with the mouse.

bool gameplay::Container::_scrollingMouseVertically `[protected]`

Locked to scrolling vertically by grabbing the scrollbar with the mouse.

bool gameplay::Container::_scrollingRight `[protected]`

Are we scrolling to the right?

double gameplay::Container::_scrollingStartTimeX `[protected]`

Time we started scrolling horizontally.

double gameplay::Container::_scrollingStartTimeY `[protected]`

Time we started scrolling vertically.

Vector2 gameplay::Container::_scrollingVelocity `[protected]`

Speed to continue scrolling at after touch release or a scroll-wheel event.

int gameplay::Container::_scrollingVeryFirstX `[protected]`

First scrolling touch x position.

int gameplay::Container::_scrollingVeryFirstY `[protected]`

First scrolling touch y position.

Vector2 gameplay::Container::_scrollPosition `[protected]`

How far this layout has been scrolled in each direction.

float gameplay::Container::_scrollWheelSpeed `[protected]`

Amount to add to scrolling velocity on a scroll-wheel event;

const int gameplay::Container::ANIMATE_SCROLLBAR_OPACITY = 8`[static]`

Constant used to auto-hide scrollbars.

All Classes Functions Variables Typedefs Enumerations Enumerator