axmol/cocos/ui/UILayoutComponent.h

166 lines
5.4 KiB
C
Raw Normal View History

2014-10-09 18:28:09 +08:00
/****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __cocos2d_libs__LayoutComponent__
#define __cocos2d_libs__LayoutComponent__
#include "2d/CCComponent.h"
#include "ui/GUIExport.h"
NS_CC_BEGIN
2014-12-22 11:20:03 +08:00
namespace ui {
class CC_GUI_DLL LayoutComponent : public Component
{
public:
LayoutComponent();
~LayoutComponent();
virtual bool init()override;
CREATE_FUNC(LayoutComponent);
2014-12-22 14:51:50 +08:00
static LayoutComponent* boundingLayoutForNode(Node* node);
2014-12-22 11:20:03 +08:00
enum class HorizontalEage
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
None,
Left,
Right,
Center
2014-10-09 18:28:09 +08:00
};
2014-12-22 11:20:03 +08:00
enum class VerticalEage
{
None,
2014-12-22 14:51:50 +08:00
Bottom,
2014-12-22 11:20:03 +08:00
Top,
Center
};
2014-12-22 18:39:44 +08:00
// OldVersion
2014-12-22 11:20:03 +08:00
virtual void setUsingPercentContentSize(bool isUsed);
2014-12-22 19:05:31 +08:00
virtual bool getUsingPercentContentSize()const;
2014-12-22 11:20:03 +08:00
virtual void setPercentContentSize(const Vec2 &percent);
2014-12-22 19:05:31 +08:00
virtual Vec2 getPercentContentSize()const;
2014-12-22 11:20:03 +08:00
2014-12-22 18:39:44 +08:00
// Position & Margin
2014-12-22 19:05:31 +08:00
virtual const Point& getAnchorPosition()const;
virtual void setAnchorPosition(const Point& point);
2014-12-22 11:20:03 +08:00
2014-12-22 19:05:31 +08:00
virtual const Point& getPosition()const;
virtual void setPosition(const Point& position);
2014-12-22 11:20:03 +08:00
2014-12-22 19:05:31 +08:00
virtual bool isUsingPositionPercentX()const;
2014-12-22 11:20:03 +08:00
virtual void setPositionPercentXEnabled(bool isUsed);
2014-12-22 19:05:31 +08:00
virtual float getPositionPercentX()const;
2014-12-22 11:20:03 +08:00
virtual void setPositionPercentX(float percentMargin);
2014-12-22 19:05:31 +08:00
virtual bool isUsingPositionPercentY()const;
2014-12-22 11:20:03 +08:00
virtual void setPositionPercentYEnabled(bool isUsed);
2014-12-22 19:05:31 +08:00
virtual float getPositionPercentY()const;
2014-12-22 11:20:03 +08:00
virtual void setPositionPercentY(float percentMargin);
2014-12-22 19:05:31 +08:00
virtual HorizontalEage getHorizontalEage()const;
2014-12-22 11:20:03 +08:00
virtual void setHorizontalEage(HorizontalEage hEage);
2014-12-22 19:05:31 +08:00
virtual VerticalEage getVerticalEage()const;
2014-12-22 11:20:03 +08:00
virtual void setVerticalEage(VerticalEage vEage);
2014-12-22 19:05:31 +08:00
virtual float getLeftMargin()const;
2014-12-22 11:20:03 +08:00
virtual void setLeftMargin(float margin);
2014-12-22 19:05:31 +08:00
virtual float getRightMargin()const;
2014-12-22 11:20:03 +08:00
virtual void setRightMargin(float margin);
2014-12-22 19:05:31 +08:00
virtual float getTopMargin()const;
2014-12-22 11:20:03 +08:00
virtual void setTopMargin(float margin);
2014-12-22 19:05:31 +08:00
virtual float getButtomMargin()const;
2014-12-22 11:20:03 +08:00
virtual void setButtomMargin(float margin);
2014-12-22 18:39:44 +08:00
// Size & Percent
2014-12-22 19:05:31 +08:00
virtual const Size& getSize()const;
virtual void setSize(const Size& _size);
2014-12-22 11:20:03 +08:00
2014-12-22 19:05:31 +08:00
virtual bool isUsingPercentWidth()const;
2014-12-22 11:20:03 +08:00
virtual void setPercentWidthEnabled(bool isUsed);
2014-12-22 19:05:31 +08:00
virtual float getSizeWidth()const;
2014-12-22 11:20:03 +08:00
virtual void setSizeWidth(float width);
2014-12-22 19:05:31 +08:00
virtual float getPercentWidth()const;
2014-12-22 11:20:03 +08:00
virtual void setPercentWidth(float percentWidth);
2014-12-22 19:05:31 +08:00
virtual bool isUsingPercentHeight()const;
2014-12-22 11:20:03 +08:00
virtual void setPercentHeightEnabled(bool isUsed);
2014-12-22 19:05:31 +08:00
virtual float getSizeHeight()const;
2014-12-22 11:20:03 +08:00
virtual void setSizeHeight(float height);
2014-12-22 19:05:31 +08:00
virtual float getPercentHeight()const;
2014-12-22 11:20:03 +08:00
virtual void setPercentHeight(float percentHeight);
2014-12-22 19:05:31 +08:00
virtual bool isUsingStretchWidth()const;
2014-12-22 11:20:03 +08:00
virtual void setStretchWidthEnabled(bool isUsed);
2014-12-22 19:05:31 +08:00
virtual bool isUsingStretchHeight()const;
2014-12-22 11:20:03 +08:00
virtual void setStretchHeightEnabled(bool isUsed);
virtual void setActiveEnable(bool enable);
virtual void refreshLayout();
protected:
Node* getOwnerParent();
virtual void refreshHorizontalMargin();
virtual void refreshVerticalMargin();
protected:
HorizontalEage _horizontalEage;
VerticalEage _verticalEage;
float _leftMargin;
float _rightMargin;
float _buttomMargin;
float _topMargin;
bool _usingPositionPercentX;
float _positionPercentX;
bool _usingPositionPercentY;
float _positionPercentY;
bool _usingStretchWidth;
bool _usingStretchHeight;
float _percentWidth;
bool _usingPercentWidth;
float _percentHeight;
bool _usingPercentHeight;
bool _actived;
};
2014-10-09 18:28:09 +08:00
}
NS_CC_END
#endif /* defined(__cocos2d_libs__LayoutComponent__) */