You.i Engine
CYILayoutConfig Class Reference

Detailed Description

A class used to hold node-specific layout configuration (such as, for example, Margin).

Subclasses of CYILayout will also subclass CYILayoutConfig (or one of its subclasses) if they use custom node-specific layout configuration values.

See also
CYILayout

#include <layout/YiLayoutConfig.h>

Inheritance diagram for CYILayoutConfig:

Classes

class  CubeOffset
 A class used to hold a 3D 'cube offset'. More...
 
class  SizeConstraint
 A class used to hold a size constraint for a specific dimension. More...
 
class  SizeConstraints
 A class used to hold the size constraint for each of the 3 dimensions. A flag that indicates if the width/height aspect ratio should be maintained is also contained in this class. More...
 

Public Types

enum  GRAVITY {
  GRAVITY_NONE,
  GRAVITY_CENTER,
  GRAVITY_LEFT,
  GRAVITY_RIGHT,
  GRAVITY_TOP,
  GRAVITY_BOTTOM,
  GRAVITY_FRONT,
  GRAVITY_BACK,
  GRAVITY_TOP_LEFT,
  GRAVITY_TOP_RIGHT,
  GRAVITY_BOTTOM_LEFT,
  GRAVITY_BOTTOM_RIGHT
}
 
typedef CubeOffset Margin
 

Public Member Functions

 CYILayoutConfig ()
 
virtual ~CYILayoutConfig ()
 
virtual void ConfigureFrom (const IYIPropertiesSource *pSource)
 
void SetSizeConstraints (const SizeConstraints &sizeConstraints)
 
const SizeConstraintsGetSizeConstraints () const
 
void SetMargin (const Margin &margin)
 
const MarginGetMargin () const
 
void SetLayoutable (bool bLayoutable)
 
bool IsLayoutable () const
 
void SetItemGravity (const glm::vec3 &vItemGravity)
 
void SetItemGravity (GRAVITY eItemGravity)
 
const glm::vec3 & GetItemGravity () const
 
void SetIsBackground (bool bBackground)
 
bool IsBackground () const
 
- Public Member Functions inherited from CYIScriptableRTTIObject
 CYIScriptableRTTIObject ()
 
virtual ~CYIScriptableRTTIObject ()
 
virtual const CYIRuntimeTypeInfoGetRuntimeTypeInfoForScriptObject () const override
 
- Public Member Functions inherited from CYIScriptableObject
 CYIScriptableObject ()
 
 CYIScriptableObject (const CYIScriptableObject &other)
 
CYIScriptableObjectoperator= (const CYIScriptableObject &other)
 
virtual ~CYIScriptableObject ()
 
CYIBindingImplementationGetBindingImplementation () const
 
void SetBindingImplementation (CYIBindingImplementation *pBindingImplementation)
 

Static Public Member Functions

static void RemoveSuffixFromNumber (CYIString &inOutNumber, CYIString &outSuffix)
 
static bool ParseBooleanValue (const CYIString &value)
 
static float ParseFloatValue (const CYIString &value)
 
static uint32_t ParseTimeValue (const CYIString &value)
 
static float ParseLengthValue (const CYIString &length)
 
static glm::vec3 ReadGravityFrom (const CYIString &key, const IYIPropertiesSource *pSource, const glm::vec3 &vDefault)
 
static glm::vec3 GetGravityVectorFor (GRAVITY eGravity)
 

Additional Inherited Members

- Protected Member Functions inherited from CYIScriptableRTTIObject
virtual std::pair< const CYIRuntimeTypeInfo *, const void * > GetRuntimeTypeInfoWithObject () const =0
 

Member Typedef Documentation

Member Enumeration Documentation

An enum listing often-used gravity values. Note that not all possible gravity values are represented here. Also note that all presets (except BACK and NONE) will use a 'depth' gravity of 'FRONT'.

See also
SetGravity
Enumerator
GRAVITY_NONE 

Indicates that the existing position of the child will be retained.

GRAVITY_CENTER 

Centers the child in the container.

GRAVITY_LEFT 

Aligns the left edge of the child with the left edge of the container.

GRAVITY_RIGHT 

Aligns the right edge of the child with the right edge of the container.

GRAVITY_TOP 

Aligns the top edge of the child with the top edge of the container.

GRAVITY_BOTTOM 

Aligns the bottom edge of the child with the bottom edge of the container.

GRAVITY_FRONT 

Aligns the front edge of the child with the front edge of the container.

GRAVITY_BACK 

Aligns the back edge of the child with the back edge of the container.

GRAVITY_TOP_LEFT 

Aligns the top-left corner of the child with the top-left corner of the container.

GRAVITY_TOP_RIGHT 

Aligns the top-right corner of the child with the top-right corner of the container.

GRAVITY_BOTTOM_LEFT 

Aligns the bottom-left corner of the child with the bottom-left corner of the container.

GRAVITY_BOTTOM_RIGHT 

Aligns the bottom-right corner of the child with the bottom-right corner of the container.

Constructor & Destructor Documentation

CYILayoutConfig::CYILayoutConfig ( )
virtual CYILayoutConfig::~CYILayoutConfig ( )
virtual

Member Function Documentation

virtual void CYILayoutConfig::ConfigureFrom ( const IYIPropertiesSource pSource)
virtual

Extracts configuration properties from properties source pSource (typically a scene node) and assigns them to this object.

Note
Subclasses should override this method. Remember to call the parent ConfigureFrom function.

Reimplemented in CYIGridLayoutConfig, and CYIAnimatingLayoutConfig.

static glm::vec3 CYILayoutConfig::GetGravityVectorFor ( GRAVITY  eGravity)
static

Returns the gravity vector equivalent to the gravity enum eGravity.

const glm::vec3 & CYILayoutConfig::GetItemGravity ( ) const
inline
const CYILayoutConfig::Margin & CYILayoutConfig::GetMargin ( ) const
inline
const CYILayoutConfig::SizeConstraints & CYILayoutConfig::GetSizeConstraints ( ) const
inline
bool CYILayoutConfig::IsBackground ( ) const
inline
bool CYILayoutConfig::IsLayoutable ( ) const
inline
static bool CYILayoutConfig::ParseBooleanValue ( const CYIString value)
static

Parses a String value as a boolean.

Any of these values will be considered true: 1, yes, true, on, enabled, enable, active. Any other value will be considered false.

Note
The value parameter must be in lowercase.
static float CYILayoutConfig::ParseFloatValue ( const CYIString value)
static

Parses a String value as a float.

Note
An empty or invalid String will result in a value of 0.0f being returned, and a warning message being logged.
static float CYILayoutConfig::ParseLengthValue ( const CYIString length)
static

Parses a String as a length value.

Note
This function is used to facilitate eventually supporting multiple length 'units'.
See also
ParseFloatValue
static uint32_t CYILayoutConfig::ParseTimeValue ( const CYIString value)
static

Parses a String value as a time, in milliseconds.

Note
An empty or invalid String will result in a value of 0 being returned, and a warning message being logged.
The following suffixes are supported: ms (millisecond), s (second), m (minute) and h (hour). If no suffix is present, the value is assumed to be in milliseconds.
static glm::vec3 CYILayoutConfig::ReadGravityFrom ( const CYIString key,
const IYIPropertiesSource pSource,
const glm::vec3 &  vDefault 
)
static

Extracts gravity values from pSource using the property key key. If no value is specified (or only partial values are specified), then the values from vDefault are used.

static void CYILayoutConfig::RemoveSuffixFromNumber ( CYIString inOutNumber,
CYIString outSuffix 
)
static

An utility function that removes the 'suffix' from inOutNumber, and stores it in outSuffix.

This function removes a text suffix from a number, and stores it in a separate CYIString. For example, if called with "54.2 ms" for inOutNumber, the inOutNumber string will be set to "54.2" and the outSuffix string will be set to "ms". Spaces between the number and the suffix are removed.

The suffix is considered to start at the first character encountered that is no within this group: '0123456789 .-' For example, if called with "54.2+ suffix" for inOutNumber, the inOutNumber string will be set to "54.2" and the outSuffix string will be set to "+ suffix".

Note
The referenced strings inOutNumber and outSuffix may be modified by this function.
If no suffix is found, inOutNumber and outSuffix will be unchanged.
void CYILayoutConfig::SetIsBackground ( bool  bBackground)

Sets whether the associated node should be laid out as a 'background' to its container.

Background nodes will be laid out to completely fill the container. The padding values configured in the container will be ignored, but the margin values configured in the node will be respected.

Note
Setting bBackground to true does not modify the draw order of the children, and thus the 'background' node may actually be rendered on top if it's last in the childrens list.
void CYILayoutConfig::SetItemGravity ( const glm::vec3 &  vItemGravity)

Sets the item gravity to vGravity.

Each component of the provided vector specifies a gravity value for the given dimension. A value of 0.0 means 'align to the start of the container', a value of 1.0 means 'align to the end of the container', and a value of 0.5 means 'center on the container'. The special value -1.0 means 'use the gravity value of the associated layout'.

Note
Some layouts will ignore one or more of the gravity components specified in a scene node. For example, a horizontal layout would ignore the x component of the gravity vector, since that layout's job is to horizontally-align scene nodes. In that case, the role of horizontal gravity is fulfilled by the 'alignment' property.
The item gravity values 'override' the gravity values of the associated layout.
Warning
Component values other than 0.0, 0.5, 1.0 and -1.0 are not supported.
See also
CYILayout::SetGravity(const glm::vec3 &vGravity)
void CYILayoutConfig::SetItemGravity ( GRAVITY  eItemGravity)

Sets the item gravity to one of the pre-defined gravity values.

See also
SetItemGravity(const glm::vec3 &vItemGravity)
Gravity
void CYILayoutConfig::SetLayoutable ( bool  bLayoutable)

Sets the layoutable flag to bLayoutable.

By default, all scene nodes are layoutable. However, if this function is called with bLayoutable = false, then the scene node that has this configuration object will be considered non-layoutable. Non-layoutable scene nodes will still be measured and have the ApplyMeasurements function called on them, but layouts that attempt to layout those scene nodes will not set their position, will not change their size, and will not consider the scene node's size in their layout calculations.

void CYILayoutConfig::SetMargin ( const Margin margin)

Sets the margin to margin.

The margin of an object is a blank area left around the object when the object is laid out. The margin effectively increases the size of an object when it is laid out (but without affecting the content or children of the object).

void CYILayoutConfig::SetSizeConstraints ( const SizeConstraints sizeConstraints)

Sets the size constraints to sizeConstraints.

See also
SizeConstraints
SizeConstraint

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