overview wiki api reference download
 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:
gameplay::Control gameplay::Ref gameplay::AnimationTarget gameplay::ScriptTarget gameplay::Form

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
LayoutgetLayout ()
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)
ControlgetControl (unsigned int index) const
ControlgetControl (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 Vector2getScrollPosition () const
void setScrollPosition (const Vector2 &scrollPosition)
AnimationgetAnimation (const char *id=NULL) const
bool isContainer () const
bool getScrollWheelRequiresFocus () const
void setScrollWheelRequiresFocus (bool required)
bool setFocus ()
bool moveFocus (Direction direction)
ControlgetActiveControl () 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 Containercreate (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 Controlcreate (Theme::Style *style, Properties *properties=NULL)
static Layout::Type getLayoutType (const char *layoutString)
static LayoutcreateLayout (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

Defines supported focus chagne directions.

The definition for container scrolling.


Constructor & Destructor Documentation

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:
controlThe 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:
propertiesThe 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:
idThe container ID.
styleThe container style (optional).
layoutThe 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:
styleThe style to apply to this container.
propertiesA 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:
typeThe 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.

Returns the currently active control for this container.

Returns:
This container's active control.
Animation* gameplay::Container::getAnimation ( const char *  id = NULL) const
virtual unsigned int gameplay::Container::getAnimationPropertyComponentCount ( int  propertyId) const [virtual]
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:
indexThe 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:
idThe 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.

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:
layoutStringThe layout string to parse
Returns:
The parsed layout type.

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:
scrollA string representing a Scroll enum.
Returns:
The Scroll enum value that matches the given string.

Get the friction applied to scrolling velocity for this container.

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

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

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:
controlThe control to insert.
indexThe 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.

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

Returns:
Whether scrollbars are always visible.

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:
evtThe mouse scroll event that occurred.
xThe x position of the scroll in pixels. Left edge is zero.
yThe y position of the scroll in pixels. Top edge is zero.
wheelDeltaThe value change of the mouse's scroll wheel.
Returns:
Whether the scroll event was consumed by scrolling within this container.
See also:
Mouse::MouseEvent

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

Parameters:
directionThe 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:
indexThe index from which to remove the control.
void gameplay::Container::removeControl ( const char *  id)

Remove a control with the given ID.

Parameters:
idThe ID of the control to remove.

Remove a specific control.

Parameters:
controlThe control to remove.

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:
controlThe 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:
bitsThe bits to set.
recursiveIf true, set the bits recursively on all children and their children.
bool gameplay::Container::setFocus ( ) [virtual]
See also:
Control::setFocus

Reimplemented from gameplay::Control.

Sets the layout type for this container.

Parameters:
typeThe new layout type for the container.

Sets the allowed scroll directions for this container.

Parameters:
scrollThe allowed scroll directions for this container.

Set whether scrollbars auto hidden when they become static.

Parameters:
autoHidetrue to auto hide the scrollbars when they become static.

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.

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:
requiredWhether focus is required in order to handle scroll-wheel events.

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.

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:
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 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.

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

The active control for the container.

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

List of controls within the container.

The container's layout.

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

Scrollbar bottom cap image.

Scroll bar bounds.

Scrollbar horizontal track image.

Scrollbar left cap image.

Used to animate scrollbars fading out.

Scrollbar horizontal image.

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

Scrollbar top cap image.

Scrollbar vertical track image.

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

Are we scrolling down?

First scrolling touch x position since last change in direction.

First scrolling touch y position since last change in direction.

Friction dampens velocity.

The last time we were scrolling.

The last y position when scrolling.

The last x position when scrolling.

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

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

Are we scrolling to the right?

Time we started scrolling horizontally.

Time we started scrolling vertically.

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

First scrolling touch x position.

First scrolling touch y position.

How far this layout has been scrolled in each direction.

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

Constant used to auto-hide scrollbars.

 All Classes Functions Variables Typedefs Enumerations Enumerator