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::TopLeft,
  Gravity::TopRight,
  Gravity::BottomLeft,
  Gravity::BottomRight
}
 
typedef CubeOffset Margin
 

Public Member Functions

 CYILayoutConfig ()
 
virtual ~CYILayoutConfig ()
 
virtual std::unique_ptr< CYILayoutConfigClone () const
 
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 layoutable)
 
bool IsLayoutable () const
 
void SetItemGravity (const glm::vec3 &itemGravity)
 
void SetItemGravity (Gravity itemGravity)
 
const glm::vec3 & GetItemGravity () const
 
void SetIsBackground (bool background)
 
bool IsBackground () const
 

Static Public Member Functions

static void RemoveSuffixFromNumber (CYIString &inOutNumber, CYIString &outSuffix)
 
static glm::vec3 ReadGravityFrom (CYIStringView key, const IYIPropertiesSource *pSource, const glm::vec3 &defaultGravity)
 
static glm::vec3 GetGravityVectorFor (Gravity gravity)
 

Member Typedef Documentation

◆ Margin

Member Enumeration Documentation

◆ Gravity

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
CYILayout::SetGravity
SetItemGravity
Enumerator
None 

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

Center 

Centers the child in the container.

Left 

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

Right 

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

Top 

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

Bottom 

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

Front 

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

Back 

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

TopLeft 

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

TopRight 

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

BottomLeft 

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

BottomRight 

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

Constructor & Destructor Documentation

◆ CYILayoutConfig()

CYILayoutConfig::CYILayoutConfig ( )

◆ ~CYILayoutConfig()

virtual CYILayoutConfig::~CYILayoutConfig ( )
virtual

Member Function Documentation

◆ Clone()

virtual std::unique_ptr<CYILayoutConfig> CYILayoutConfig::Clone ( ) const
virtual

Creates a duplicate of this layout configuration object. The created type is the dynamic type of this object.

Reimplemented in CYIGridLayoutConfig, and CYIAnimatingLayoutConfig.

◆ ConfigureFrom()

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.
CYILayout instances do not call this function when pSource has no properties.
See also
IYIPropertiesSource::HasProperties()

Reimplemented in CYIGridLayoutConfig, and CYIAnimatingLayoutConfig.

◆ GetGravityVectorFor()

static glm::vec3 CYILayoutConfig::GetGravityVectorFor ( Gravity  gravity)
static

Returns the gravity vector equivalent to the gravity enum gravity.

◆ GetItemGravity()

const glm::vec3 & CYILayoutConfig::GetItemGravity ( ) const
inline

◆ GetMargin()

const CYILayoutConfig::Margin & CYILayoutConfig::GetMargin ( ) const
inline

◆ GetSizeConstraints()

const CYILayoutConfig::SizeConstraints & CYILayoutConfig::GetSizeConstraints ( ) const
inline

◆ IsBackground()

bool CYILayoutConfig::IsBackground ( ) const
inline

◆ IsLayoutable()

bool CYILayoutConfig::IsLayoutable ( ) const
inline

◆ ReadGravityFrom()

static glm::vec3 CYILayoutConfig::ReadGravityFrom ( CYIStringView  key,
const IYIPropertiesSource pSource,
const glm::vec3 &  defaultGravity 
)
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 default are used.

◆ RemoveSuffixFromNumber()

static void CYILayoutConfig::RemoveSuffixFromNumber ( CYIString inOutNumber,
CYIString outSuffix 
)
static
Deprecated:
This function is deprecated and may be removed in a future release. CYIStringParsing::SplitSuffixFromNumber should be used instead.

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.

◆ SetIsBackground()

void CYILayoutConfig::SetIsBackground ( bool  background)

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

◆ SetItemGravity() [1/2]

void CYILayoutConfig::SetItemGravity ( const glm::vec3 &  itemGravity)

Sets the item gravity to gravity.

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 &gravity)

◆ SetItemGravity() [2/2]

void CYILayoutConfig::SetItemGravity ( Gravity  itemGravity)

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

See also
SetItemGravity(const glm::vec3 &itemGravity)
Gravity

◆ SetLayoutable()

void CYILayoutConfig::SetLayoutable ( bool  layoutable)

Sets the layoutable flag to layoutable.

By default, all scene nodes are layoutable. However, if this function is called with layoutable = 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.

◆ SetMargin()

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

◆ SetSizeConstraints()

void CYILayoutConfig::SetSizeConstraints ( const SizeConstraints sizeConstraints)

Sets the size constraints to sizeConstraints.

See also
CYILayoutConfig::SizeConstraints
CYILayoutConfig::SizeConstraint

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