本文来自http://blog.csdn.net/runaying ,引用必须注明出处!
cocos2d-X 节点(LayoutParameter.h)API
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记
一些布局参数,相对布局参数,线性布局参数
///cocos2d-x-3.0alpha0/extensions/CocoStudio/GUI/Layouts
// 一些布局参数,相对布局参数,线性布局参数
#ifndef __LAYOUTPARMETER_H__
#define __LAYOUTPARMETER_H__
#include "UILayoutDefine.h"
NS_CC_EXT_BEGIN
typedef enum
{
LAYOUT_PARAMETER_NONE,
LAYOUT_PARAMETER_LINEAR,
LAYOUT_PARAMETER_RELATIVE
}LayoutParameterType;
class LayoutParameter : public Object
{
public:
/**
* Default constructor
*/
LayoutParameter() : _margin(UIMargin()){_layoutParameterType = LAYOUT_PARAMETER_NONE;};
/**
* Default destructor
*/
virtual ~LayoutParameter(){};
/**
* Allocates and initializes.
* @return 一个初始化的被标记为自动释放的 LayoutParameter
*/
static LayoutParameter* create();
/**
* 为 LayoutParameter 设置 margin (边距)参数.
*
* @see UIMargin
*
* @param margin
*/
void setMargin(const UIMargin& margin);
const UIMargin& getMargin() const;
/**
* Gets LayoutParameterType of LayoutParameter.
*
* @see LayoutParameterType
*
* @return LayoutParameterType
*/
LayoutParameterType getLayoutType() const;
protected:
UIMargin _margin;
LayoutParameterType _layoutParameterType;
};
class LinearLayoutParameter : public LayoutParameter
{
public:
/**
* Default constructor
*/
LinearLayoutParameter() : m_eLinearGravity(LINEAR_GRAVITY_NONE){_layoutParameterType = LAYOUT_PARAMETER_LINEAR;};
/**
* Default destructor
*/
virtual ~LinearLayoutParameter(){};
/**
* 分配并初始化.
* @return A initialized LayoutParameter which is marked as "autorelease".
*/
static LinearLayoutParameter* create();
/**
* Sets UILinearGravity parameter for LayoutParameter.
*
* @see UILinearGravity
*
* @param UILinearGravity
*/
void setGravity(UILinearGravity gravity);
UILinearGravity getGravity() const;
protected:
UILinearGravity m_eLinearGravity;
};
class RelativeLayoutParameter : public LayoutParameter
{
public:
/**
* Default constructor
*/
RelativeLayoutParameter() : m_eRelativeAlign(RELATIVE_ALIGN_NONE),m_strRelativeWidgetName(""),m_strRelativeLayoutName(""){_layoutParameterType = LAYOUT_PARAMETER_RELATIVE;};
/**
* Default destructor
*/
virtual ~RelativeLayoutParameter(){};
/**
* 分配并初始化.
* @return A initialized LayoutParameter which is marked as "autorelease".
*/
static RelativeLayoutParameter* create();
/**
* Sets UIRelativeAlign parameter for LayoutParameter.
*
* @see UIRelativeAlign
*
* @param UIRelativeAlign
*/
void setAlign(UIRelativeAlign align);
/**
* Gets UIRelativeAlign parameter for LayoutParameter.
*
* @see UIRelativeAlign
*
* @return UIRelativeAlign
*/
UIRelativeAlign getAlign() const;
/**
* 为 LayoutParameter 设置一个key.这是相对于 widget named
*
* @param name
*/
void setRelativeToWidgetName(const char* name);
const char* getRelativeToWidgetName() const;
/**
* Sets LayoutParameter的相对布局的名称。
*
* @param name
*/
void setRelativeName(const char* name);
/**
* 获取LayoutParameter的相对布局的名称。
*
* @return name
*/
const char* getRelativeName() const;
protected:
UIRelativeAlign m_eRelativeAlign;
std::string m_strRelativeWidgetName;
std::string m_strRelativeLayoutName;
};
NS_CC_EXT_END
#endif /* defined(__LayoutParameter__) */