#include <Container.h>
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 |
Defines a container that contains zero or more controls.
Defines supported focus chagne directions.
The definition for container scrolling.
gameplay::Container::Container | ( | ) | [protected] |
Constructor.
virtual gameplay::Container::~Container | ( | ) | [protected, virtual] |
Destructor.
unsigned int gameplay::Container::addControl | ( | Control * | control | ) |
Adds a new control to this container.
control | The control to add. |
void gameplay::Container::addControls | ( | Properties * | properties | ) | [protected] |
Adds controls nested within a properties object to this container.
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.
id | The container ID. |
style | The container style (optional). |
layout | The container layout (optional). |
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.
style | The style to apply to this container. |
properties | A properties object containing a definition of the container and its nested controls (optional). |
static Layout* gameplay::Container::createLayout | ( | Layout::Type | type | ) | [static, protected] |
Creates a layout for the specified layout type.
type | The type of layout to create. |
virtual unsigned int gameplay::Container::draw | ( | Form * | form, |
const Rectangle & | clip | ||
) | [protected, virtual] |
Reimplemented from gameplay::Control.
Control* gameplay::Container::getActiveControl | ( | ) | const |
Returns the currently active control for this container.
Animation* gameplay::Container::getAnimation | ( | const char * | id = NULL | ) | const |
Reimplemented from gameplay::AnimationTarget.
virtual unsigned int gameplay::Container::getAnimationPropertyComponentCount | ( | int | propertyId | ) | const [virtual] |
Reimplemented from gameplay::Control.
virtual void gameplay::Container::getAnimationPropertyValue | ( | int | propertyId, |
AnimationValue * | value | ||
) | [virtual] |
Reimplemented from gameplay::Control.
Control* gameplay::Container::getControl | ( | unsigned int | index | ) | const |
Control* gameplay::Container::getControl | ( | const char * | id | ) | const |
unsigned int gameplay::Container::getControlCount | ( | ) | const |
Returns the number of child controls for this container.
const std::vector<Control*>& gameplay::Container::getControls | ( | ) | const |
Get the vector of controls within this container.
Get this container's layout.
static Layout::Type gameplay::Container::getLayoutType | ( | const char * | layoutString | ) | [static, protected] |
Gets a Layout::Type enum from a matching string.
layoutString | The layout string to parse |
Scroll gameplay::Container::getScroll | ( | ) | const |
Gets 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.
scroll | A string representing a Scroll enum. |
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.
Reimplemented from gameplay::Control.
Reimplemented in gameplay::Form.
void gameplay::Container::initialize | ( | const char * | typeName, |
Theme::Style * | style, | ||
Properties * | properties | ||
) | [protected, virtual] |
Reimplemented from gameplay::Control.
void gameplay::Container::insertControl | ( | Control * | control, |
unsigned int | index | ||
) |
Inserts a control at a specific index.
control | The control to insert. |
index | The index at which to insert the control. |
bool gameplay::Container::isContainer | ( | ) | const [virtual] |
Reimplemented from gameplay::Control.
virtual bool gameplay::Container::isForm | ( | ) | const [virtual] |
Determines if this container is a top level form.
Reimplemented in gameplay::Form.
bool gameplay::Container::isScrollBarsAutoHide | ( | ) | const |
Whether scrollbars are always visible, or only visible while scrolling.
bool gameplay::Container::isScrolling | ( | ) | const |
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.
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. |
bool gameplay::Container::moveFocus | ( | Direction | direction | ) |
Attempts to switch focus to a child of this container in the specified direction.
direction | The direction for focus change. |
void gameplay::Container::removeControl | ( | unsigned int | index | ) |
Remove a control at a specific index.
index | The index from which to remove the control. |
void gameplay::Container::removeControl | ( | const char * | id | ) |
Remove a control with the given ID.
id | The ID of the control to remove. |
void gameplay::Container::removeControl | ( | Control * | control | ) |
Remove a specific control.
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.
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] |
Reimplemented from gameplay::Control.
void gameplay::Container::setChildrenDirty | ( | int | bits, |
bool | recursive | ||
) | [protected] |
Sets the specified dirty bits for all children within this container.
bits | The bits to set. |
recursive | If true, set the bits recursively on all children and their children. |
bool gameplay::Container::setFocus | ( | ) | [virtual] |
Reimplemented from gameplay::Control.
void gameplay::Container::setLayout | ( | Layout::Type | type | ) |
Sets the layout type for this container.
type | The new layout type for the container. |
void gameplay::Container::setScroll | ( | Scroll | scroll | ) |
Sets the allowed scroll directions for this container.
scroll | The allowed scroll directions for this container. |
void gameplay::Container::setScrollBarsAutoHide | ( | bool | autoHide | ) |
Set whether scrollbars auto hidden when they become static.
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.
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.
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. |
void gameplay::Container::update | ( | float | elapsedTime | ) | [protected, virtual] |
void gameplay::Container::updateAbsoluteBounds | ( | const Vector2 & | offset | ) | [protected, virtual] |
Reimplemented from gameplay::Control.
void gameplay::Container::updateBounds | ( | ) | [protected, virtual] |
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] |
Reimplemented from gameplay::Control.
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.
Scrollbar bottom cap image.
Rectangle gameplay::Container::_scrollBarBounds [protected] |
Scroll bar bounds.
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.