omegalib  13.1
omegaToolkit::ui::Widget Class Reference

#include <Widget.h>

Classes

struct  BorderStyle
 

Public Types

enum  Layer { Back, Middle, Front, NumLayers }
 
enum  BlendMode { BlendInherit, BlendNormal, BlendAdditive, BlendDisabled }
 

Public Member Functions

 Widget (Engine *server)
 
virtual ~Widget ()
 
virtual RenderablecreateRenderable ()
 
virtual void handleEvent (const Event &evt)
 
virtual void update (const omega::UpdateContext &context)
 
ContainergetContainer ()
 
const String & getName ()
 Returns the widget name. More...
 
void setName (const String &name)
 Sets the widget name. More...
 
int getId ()
 Returns the unique Widget id. More...
 
virtual void layout ()
 
void setStereo (bool value)
 
bool isStereo ()
 
virtual void autosize ()
 
virtual void updateSize ()
 
void requestLayoutRefresh ()
 
Layer getLayer ()
 
void setLayer (Layer layer)
 
bool hitTest (const Vector2f &point)
 Returns true if the point is within this widget's bounding box. More...
 
Vector2f transformPoint (const omega::Vector2f &point)
 Transforms a 2D point from screen space to this widget's reference frame. More...
 
void setUserData (void *data)
 
void * getUserData ()
 
bool isDraggable ()
 
void setDraggable (bool value)
 
bool isDragging ()
 
bool isPinned ()
 When a widget is pinned, its position will remain fixed with respect to its container. More...
 
void setPinned (bool value)
 
void setSizeAnchorEnabled (bool enabled)
 
bool isSizeAnchorEnabled ()
 
void setSizeAnchor (const Vector2f &value)
 
const Vector2f getSizeAnchor ()
 
WidgetFactorygetFactory ()
 
void setUIEventHandler (IEventListener *value)
 Input and Events. More...
 
IEventListener * getUIEventHandler ()
 
void setUIEventCommand (const String &command)
 
bool isButtonDown (const Event &evt, Event::Flags button)
 Returns true if the event is a button down event happening on this widget. More...
 
bool isButtonUp (const Event &evt, Event::Flags button)
 Returns true if the event is a button up event happening on this widget. More...
 
void setUpdateCommand (const String &cmd)
 Sets or gets a script command to be invoked on every update for this widget. More...
 
String getUpdateCommand ()
 
void setDragBeginCommand (const String &cmd)
 Sets or gets a script command to be invoked when this widget starts dragging. More...
 
String getDragBeginCommand ()
 
void setDragEndCommand (const String &cmd)
 Sets or gets a script command to be invoked when this widget ends dragging. More...
 
String getDragEndCommand ()
 
void setActivateCommand (const String &cmd)
 Sets or gets a script command to be invoked when this widget gets active status. More...
 
String getActivateCommand ()
 
void setDeactivateCommand (const String &cmd)
 Sets or gets a script command to be invoked when this widget loses active status. More...
 
String getDeactivateCommand ()
 
const Vector2f & getPosition ()
 Position and rotation. More...
 
Vector2f getDerivedPosition ()
 Gets the widget position in screen space. More...
 
void setPosition (const omega::Vector2f &value)
 Sets the widget position. More...
 
void setPosition (int value, int dimension)
 
void setCenter (const omega::Vector2f &value)
 
Vector2f getCenter ()
 
void setRotation (float value)
 Sets the widget rotation. More...
 
float getRotation ()
 Gets the widget position. More...
 
const Vector2f & getSize ()
 Size constraints. More...
 
float getWidth ()
 
float getHeight ()
 
void setSize (const Vector2f &value)
 Sets the widget size. More...
 
void setWidth (float value)
 
void setHeight (float value)
 
const Vector2f & getMinimumSize ()
 
const Vector2f & getMaximumSize ()
 
void setMinimumSize (const Vector2f &value)
 
int getMinimumWidth ()
 
int getMinimumHeight ()
 
void setMaximumSize (const Vector2f &value)
 
int getMaximumWidth ()
 
int getMaximumHeight ()
 
void setMinimumWidth (float value)
 
void setMinimumHeight (float value)
 
void setMaximumWidth (float value)
 
void setMaximumHeight (float value)
 
void clearSizeConstaints ()
 
void setAutosize (bool value)
 
bool getAutosize ()
 
bool isVisible ()
 Flags. More...
 
void setVisible (bool value)
 
bool isEnabled ()
 When true, the widget is enabled, i.e. it can receive input events and takes part in navigation (can become active) More...
 
void setEnabled (bool value)
 
bool isActive ()
 
void setActive (bool value)
 
virtual bool isIn3DContainer ()
 Returns true if this widget is part of a container that will be drawn in 3D mode. More...
 
bool isPointerInside ()
 
void setHorizontalNextWidget (Widget *value)
 Navigation. More...
 
WidgetgetHorizontalNextWidget ()
 
void setHorizontalPrevWidget (Widget *value)
 
WidgetgetHorizontalPrevWidget ()
 
void setVerticalNextWidget (Widget *value)
 
WidgetgetVerticalNextWidget ()
 
void setVerticalPrevWidget (Widget *value)
 
WidgetgetVerticalPrevWidget ()
 
bool isNavigationEnabled ()
 
void setNavigationEnabled (bool value)
 
bool isGamepadInteractionEnabled ()
 
bool isPointerInteractionEnabled ()
 
void setStyle (const String &style)
 Appearance. More...
 
String getStyleValue (const String &key, const String &defaultValue="")
 
void setStyleValue (const String &key, const String &value)
 
void setScale (float value)
 
void setActiveStyle (const String &value)
 
void setInactiveStyle (const String &value)
 
String getActiveStyle ()
 
String getInactiveStyle ()
 
float getScale ()
 Sets the widget scale. More...
 
float getDerivedScale ()
 Gets the scale of this widget, taking into account the scale of any parent container. More...
 
void setAlpha (float value)
 
float getAlpha ()
 
void setBlendMode (BlendMode value)
 
BlendMode getBlendMode ()
 
void setFillColor (const Color &c)
 
void setFillEnabled (bool value)
 
BorderStylegetBorderStyle (int side)
 Gets the style for one of the borders. More...
 
void setShaderEnabled (bool value)
 Enables or disables shaders for this widget. More...
 
bool isShaderEnabled ()
 
void setShaderName (const String &name)
 Sets the name of the shader used by this widget. More...
 
const String & getShaderName ()
 
Color getDebugColor ()
 Debug mode. More...
 
void setDebugColor (omega::Color value)
 Sets the color used when widget debug mode is enabled. More...
 
bool isDebugModeEnabled ()
 Returns true if debug mode is enabled for this widget. More...
 
void setDebugModeEnabled (bool value)
 Enabled or disabled debug mode for this widget. More...
 
void setPreDrawCallback (PyObject *predcb)
 Scriptable draw callbacks. More...
 
void setPostDrawCallback (PyObject *postdcb)
 Sets a python function to be called right before rendering of this widget terminates. More...
 
- Public Member Functions inherited from omega::RenderableFactory
 RenderableFactory ()
 
virtual ~RenderableFactory ()
 
virtual void initialize (Engine *srv)
 
void dispose ()
 
void refresh ()
 
virtual bool isInitialized ()
 
RenderablegetRenderable (Renderer *client)
 
EnginegetEngine ()
 
- Public Member Functions inherited from omicron::ReferenceType
 ReferenceType ()
 
virtual ~ReferenceType ()
 
void ref ()
 
void unref ()
 
long refCount ()
 

Static Public Member Functions

static Widgetcreate (Container *parent)
 
template<typename W >
static W * getSource (const Event &evt)
 
- Static Public Member Functions inherited from omicron::ReferenceType
static void printObjCounts ()
 

Static Public Attributes

static const int MaxWidgets = 16384
 

Protected Member Functions

bool simpleHitTest (const omega::Vector2f &point)
 
virtual void activate ()
 Called when this widget becomes the active widget. More...
 
virtual void deactivate ()
 Called when this widget is not the active widget anymore. More...
 
virtual void updateStyle ()
 
void setContainer (Container *value)
 
void dispatchUIEvent (const Event &evt)
 
void playMenuScrollSound ()
 
bool needLayoutRefresh ()
 internal layout management More...
 
void setActualSize (int value, Orientation orientation, bool force=false)
 
- Protected Member Functions inherited from omega::RenderableFactory
RenderableaddRenderable (Renderer *cli)
 

Static Protected Member Functions

static bool simpleHitTest (const omega::Vector2f &point, const omega::Vector2f &pos, const omega::Vector2f &size)
 

Protected Attributes

omega::Vector2f myPosition
 
omega::Vector2f mySize
 
float myRotation
 

Friends

class UiManager
 
class UiRenderPass
 
class Container
 
class WidgetRenderable
 

Additional Inherited Members

- Static Protected Attributes inherited from omicron::ReferenceType
static List< ReferenceType * > mysObjList
 
+ Inheritance diagram for omegaToolkit::ui::Widget:

Member Enumeration Documentation

Enumerator
BlendInherit 
BlendNormal 
BlendAdditive 
BlendDisabled 
Enumerator
Back 
Middle 
Front 
NumLayers 

Constructor & Destructor Documentation

omegaToolkit::ui::Widget::Widget ( Engine server)
virtual omegaToolkit::ui::Widget::~Widget ( )
virtual

Member Function Documentation

virtual void omegaToolkit::ui::Widget::activate ( )
inlineprotectedvirtual

Called when this widget becomes the active widget.

Derivec classes can implement this method to specify a custom activation behavior

Reimplemented in omegaToolkit::ui::Container, and omegaToolkit::ui::TextBox.

virtual void omegaToolkit::ui::Widget::autosize ( )
inlinevirtual
void omegaToolkit::ui::Widget::clearSizeConstaints ( )
static Widget* omegaToolkit::ui::Widget::create ( Container parent)
static
virtual void omegaToolkit::ui::Widget::deactivate ( )
inlineprotectedvirtual

Called when this widget is not the active widget anymore.

Derivec classes can implement this method to specify a custom deactivation behavior

Reimplemented in omegaToolkit::ui::TextBox.

void omegaToolkit::ui::Widget::dispatchUIEvent ( const Event &  evt)
protected
String omegaToolkit::ui::Widget::getActivateCommand ( )
inline
String omegaToolkit::ui::Widget::getActiveStyle ( )
inline
float omegaToolkit::ui::Widget::getAlpha ( )
bool omegaToolkit::ui::Widget::getAutosize ( )
inline
BlendMode omegaToolkit::ui::Widget::getBlendMode ( )
inline
BorderStyle& omegaToolkit::ui::Widget::getBorderStyle ( int  side)
inline

Gets the style for one of the borders.

Remarks
valid values for side are: 0 - for top 1 - for right 2 - for bottom 3 - for left
Vector2f omegaToolkit::ui::Widget::getCenter ( )
Container* omegaToolkit::ui::Widget::getContainer ( )
inline
String omegaToolkit::ui::Widget::getDeactivateCommand ( )
inline
Color omegaToolkit::ui::Widget::getDebugColor ( )
inline

Debug mode.

Gets the color used when widget debug mode is enabled.

Vector2f omegaToolkit::ui::Widget::getDerivedPosition ( )

Gets the widget position in screen space.

float omegaToolkit::ui::Widget::getDerivedScale ( )

Gets the scale of this widget, taking into account the scale of any parent container.

String omegaToolkit::ui::Widget::getDragBeginCommand ( )
inline
String omegaToolkit::ui::Widget::getDragEndCommand ( )
inline
WidgetFactory* omegaToolkit::ui::Widget::getFactory ( )
float omegaToolkit::ui::Widget::getHeight ( )
inline
Widget* omegaToolkit::ui::Widget::getHorizontalNextWidget ( )
inline
Widget* omegaToolkit::ui::Widget::getHorizontalPrevWidget ( )
inline
int omegaToolkit::ui::Widget::getId ( )

Returns the unique Widget id.

String omegaToolkit::ui::Widget::getInactiveStyle ( )
inline
Layer omegaToolkit::ui::Widget::getLayer ( )
inline
int omegaToolkit::ui::Widget::getMaximumHeight ( )
inline
const Vector2f & omegaToolkit::ui::Widget::getMaximumSize ( )
inline
int omegaToolkit::ui::Widget::getMaximumWidth ( )
inline
int omegaToolkit::ui::Widget::getMinimumHeight ( )
inline
const Vector2f & omegaToolkit::ui::Widget::getMinimumSize ( )
inline
int omegaToolkit::ui::Widget::getMinimumWidth ( )
inline
const String & omegaToolkit::ui::Widget::getName ( )
inline

Returns the widget name.

const Vector2f& omegaToolkit::ui::Widget::getPosition ( )
inline

Position and rotation.

Gets the widget position relative to its container

float omegaToolkit::ui::Widget::getRotation ( )
inline

Gets the widget position.

float omegaToolkit::ui::Widget::getScale ( )
inline

Sets the widget scale.

Scale controls the visual appearance of a widget without changing its actual size or forcing a layout refresh of the widget container. Scale is indicated as a proportion of the current widget size.

const String& omegaToolkit::ui::Widget::getShaderName ( )
inline
const Vector2f & omegaToolkit::ui::Widget::getSize ( )
inline

Size constraints.

Gets the widget size

const Vector2f omegaToolkit::ui::Widget::getSizeAnchor ( )
inline
template<typename W >
W * omegaToolkit::ui::Widget::getSource ( const Event &  evt)
inlinestatic
String omegaToolkit::ui::Widget::getStyleValue ( const String &  key,
const String &  defaultValue = "" 
)
IEventListener * omegaToolkit::ui::Widget::getUIEventHandler ( )
inline
See also
setWidgetEventHandler
String omegaToolkit::ui::Widget::getUpdateCommand ( )
inline
void* omegaToolkit::ui::Widget::getUserData ( )
inline
Widget* omegaToolkit::ui::Widget::getVerticalNextWidget ( )
inline
Widget* omegaToolkit::ui::Widget::getVerticalPrevWidget ( )
inline
float omegaToolkit::ui::Widget::getWidth ( )
inline
virtual void omegaToolkit::ui::Widget::handleEvent ( const Event &  evt)
virtual

Reimplemented in omegaToolkit::ui::TextBox.

bool omegaToolkit::ui::Widget::hitTest ( const Vector2f &  point)

Returns true if the point is within this widget's bounding box.

bool omegaToolkit::ui::Widget::isActive ( )
inline
bool omegaToolkit::ui::Widget::isButtonDown ( const Event &  evt,
Event::Flags  button 
)
inline

Returns true if the event is a button down event happening on this widget.

bool omegaToolkit::ui::Widget::isButtonUp ( const Event &  evt,
Event::Flags  button 
)
inline

Returns true if the event is a button up event happening on this widget.

bool omegaToolkit::ui::Widget::isDebugModeEnabled ( )
inline

Returns true if debug mode is enabled for this widget.

bool omegaToolkit::ui::Widget::isDraggable ( )
inline
bool omegaToolkit::ui::Widget::isDragging ( )
inline
bool omegaToolkit::ui::Widget::isEnabled ( )
inline

When true, the widget is enabled, i.e. it can receive input events and takes part in navigation (can become active)

bool omegaToolkit::ui::Widget::isGamepadInteractionEnabled ( )
virtual bool omegaToolkit::ui::Widget::isIn3DContainer ( )
virtual

Returns true if this widget is part of a container that will be drawn in 3D mode.

Reimplemented in omegaToolkit::ui::Container.

bool omegaToolkit::ui::Widget::isNavigationEnabled ( )
inline
bool omegaToolkit::ui::Widget::isPinned ( )
inline

When a widget is pinned, its position will remain fixed with respect to its container.

Pinning widgets is useful to make container draggable only on a sub-section represented by the pinned widget.

bool omegaToolkit::ui::Widget::isPointerInside ( )
inline
bool omegaToolkit::ui::Widget::isPointerInteractionEnabled ( )
bool omegaToolkit::ui::Widget::isShaderEnabled ( )
inline
bool omegaToolkit::ui::Widget::isSizeAnchorEnabled ( )
inline
bool omegaToolkit::ui::Widget::isStereo ( )
inline
bool omegaToolkit::ui::Widget::isVisible ( )
inline

Flags.

virtual void omegaToolkit::ui::Widget::layout ( )
virtual

Reimplemented in omegaToolkit::ui::Container.

bool omegaToolkit::ui::Widget::needLayoutRefresh ( )
protected

internal layout management

void omegaToolkit::ui::Widget::playMenuScrollSound ( )
protected
void omegaToolkit::ui::Widget::requestLayoutRefresh ( )
void omegaToolkit::ui::Widget::setActivateCommand ( const String &  cmd)
inline

Sets or gets a script command to be invoked when this widget gets active status.

void omegaToolkit::ui::Widget::setActive ( bool  value)
void omegaToolkit::ui::Widget::setActiveStyle ( const String &  value)
inline
void omegaToolkit::ui::Widget::setActualSize ( int  value,
Orientation  orientation,
bool  force = false 
)
protected
void omegaToolkit::ui::Widget::setAlpha ( float  value)
inline
void omegaToolkit::ui::Widget::setAutosize ( bool  value)
inline
void omegaToolkit::ui::Widget::setBlendMode ( BlendMode  value)
inline
void omegaToolkit::ui::Widget::setCenter ( const omega::Vector2f value)
void omegaToolkit::ui::Widget::setContainer ( Container value)
protected
void omegaToolkit::ui::Widget::setDeactivateCommand ( const String &  cmd)
inline

Sets or gets a script command to be invoked when this widget loses active status.

void omegaToolkit::ui::Widget::setDebugColor ( omega::Color  value)
inline

Sets the color used when widget debug mode is enabled.

void omegaToolkit::ui::Widget::setDebugModeEnabled ( bool  value)
inline

Enabled or disabled debug mode for this widget.

When debug mode is enabled, the widget bounding box will be displayed.

void omegaToolkit::ui::Widget::setDragBeginCommand ( const String &  cmd)
inline

Sets or gets a script command to be invoked when this widget starts dragging.

void omegaToolkit::ui::Widget::setDragEndCommand ( const String &  cmd)
inline

Sets or gets a script command to be invoked when this widget ends dragging.

void omegaToolkit::ui::Widget::setDraggable ( bool  value)
inline
void omegaToolkit::ui::Widget::setEnabled ( bool  value)
inline
void omegaToolkit::ui::Widget::setFillColor ( const Color c)
inline
void omegaToolkit::ui::Widget::setFillEnabled ( bool  value)
inline
void omegaToolkit::ui::Widget::setHeight ( float  value)
inline
void omegaToolkit::ui::Widget::setHorizontalNextWidget ( Widget value)
inline

Navigation.

void omegaToolkit::ui::Widget::setHorizontalPrevWidget ( Widget value)
inline
void omegaToolkit::ui::Widget::setInactiveStyle ( const String &  value)
inline
void omegaToolkit::ui::Widget::setLayer ( Layer  layer)
inline
void omegaToolkit::ui::Widget::setMaximumHeight ( float  value)
inline
void omegaToolkit::ui::Widget::setMaximumSize ( const Vector2f &  value)
inline
void omegaToolkit::ui::Widget::setMaximumWidth ( float  value)
inline
void omegaToolkit::ui::Widget::setMinimumHeight ( float  value)
inline
void omegaToolkit::ui::Widget::setMinimumSize ( const Vector2f &  value)
inline
void omegaToolkit::ui::Widget::setMinimumWidth ( float  value)
inline
void omegaToolkit::ui::Widget::setName ( const String &  name)
inline

Sets the widget name.

void omegaToolkit::ui::Widget::setNavigationEnabled ( bool  value)
void omegaToolkit::ui::Widget::setPinned ( bool  value)
inline
void omegaToolkit::ui::Widget::setPosition ( const omega::Vector2f value)
inline

Sets the widget position.

void omegaToolkit::ui::Widget::setPosition ( int  value,
int  dimension 
)
inline
void omegaToolkit::ui::Widget::setPostDrawCallback ( PyObject *  postdcb)
inline

Sets a python function to be called right before rendering of this widget terminates.

Pointer must be to a callable PyObject.

void omegaToolkit::ui::Widget::setPreDrawCallback ( PyObject *  predcb)
inline

Scriptable draw callbacks.

Sets a python function to be called before rendering of this widget begins. Pointer must be to a callable PyObject.

void omegaToolkit::ui::Widget::setRotation ( float  value)
inline

Sets the widget rotation.

Parameters
value- the widget rotation in degrees
void omegaToolkit::ui::Widget::setScale ( float  value)
inline
void omegaToolkit::ui::Widget::setShaderEnabled ( bool  value)
inline

Enables or disables shaders for this widget.

Shaders are enabled by default and are required to correctly render some widget features like correct transparency. The shader used by the widget can be replaced using the setShaderName method.

void omegaToolkit::ui::Widget::setShaderName ( const String &  name)
inline

Sets the name of the shader used by this widget.

The widget will look for a vertex and a fragment shader with this name. By default, widgets use a shader named 'system/shaders/widget-shader'. The default shaders will be 'system/shaders/widget-shader.vert' and 'system/shaders/widget-shader.frag'. The shader sources can be found in the omegalib data directory.

void omegaToolkit::ui::Widget::setSize ( const Vector2f &  value)
inline

Sets the widget size.

void omegaToolkit::ui::Widget::setSizeAnchor ( const Vector2f &  value)
inline
void omegaToolkit::ui::Widget::setSizeAnchorEnabled ( bool  enabled)
inline
void omegaToolkit::ui::Widget::setStereo ( bool  value)
inline
void omegaToolkit::ui::Widget::setStyle ( const String &  style)

Appearance.

void omegaToolkit::ui::Widget::setStyleValue ( const String &  key,
const String &  value 
)
void omegaToolkit::ui::Widget::setUIEventCommand ( const String &  command)
void omegaToolkit::ui::Widget::setUIEventHandler ( IEventListener *  value)
inline

Input and Events.

Sets the event listener used to handle events generated by this widget.

void omegaToolkit::ui::Widget::setUpdateCommand ( const String &  cmd)
inline

Sets or gets a script command to be invoked on every update for this widget.

void omegaToolkit::ui::Widget::setUserData ( void *  data)
inline
void omegaToolkit::ui::Widget::setVerticalNextWidget ( Widget value)
inline
void omegaToolkit::ui::Widget::setVerticalPrevWidget ( Widget value)
inline
void omegaToolkit::ui::Widget::setVisible ( bool  value)
inline
void omegaToolkit::ui::Widget::setWidth ( float  value)
inline
bool omegaToolkit::ui::Widget::simpleHitTest ( const omega::Vector2f point)
protected
static bool omegaToolkit::ui::Widget::simpleHitTest ( const omega::Vector2f point,
const omega::Vector2f pos,
const omega::Vector2f size 
)
staticprotected
Vector2f omegaToolkit::ui::Widget::transformPoint ( const omega::Vector2f point)

Transforms a 2D point from screen space to this widget's reference frame.

virtual void omegaToolkit::ui::Widget::update ( const omega::UpdateContext context)
virtual
virtual void omegaToolkit::ui::Widget::updateSize ( )
virtual
virtual void omegaToolkit::ui::Widget::updateStyle ( )
protectedvirtual

Reimplemented in omegaToolkit::ui::Label.

Friends And Related Function Documentation

friend class Container
friend
friend class UiManager
friend
friend class UiRenderPass
friend
friend class WidgetRenderable
friend

Member Data Documentation

const int omegaToolkit::ui::Widget::MaxWidgets = 16384
static
omega::Vector2f omegaToolkit::ui::Widget::myPosition
protected
float omegaToolkit::ui::Widget::myRotation
protected
omega::Vector2f omegaToolkit::ui::Widget::mySize
protected

The documentation for this class was generated from the following file: