axmol/cocos/gui/UILayoutParameter.cpp

122 lines
3.2 KiB
C++
Raw Normal View History

2013-09-13 22:20:20 +08:00
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
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.
****************************************************************************/
2013-11-06 16:04:06 +08:00
#include "gui/UILayoutParameter.h"
#include "gui/UILayout.h"
2013-09-13 22:20:20 +08:00
namespace gui {
2013-09-13 22:20:20 +08:00
2013-11-06 16:04:06 +08:00
UILayoutParameter* UILayoutParameter::create()
2013-09-13 22:20:20 +08:00
{
2013-11-06 16:04:06 +08:00
UILayoutParameter* parameter = new UILayoutParameter();
2013-09-13 22:20:20 +08:00
if (parameter)
{
parameter->autorelease();
return parameter;
}
CC_SAFE_DELETE(parameter);
2013-11-14 11:37:46 +08:00
return nullptr;
2013-09-13 22:20:20 +08:00
}
2013-11-06 16:04:06 +08:00
void UILayoutParameter::setMargin(const UIMargin &margin)
2013-09-13 22:20:20 +08:00
{
2013-09-16 20:54:13 +08:00
_margin = margin;
2013-09-13 22:20:20 +08:00
}
2013-11-06 16:04:06 +08:00
const UIMargin& UILayoutParameter::getMargin() const
2013-09-13 22:20:20 +08:00
{
2013-09-16 20:54:13 +08:00
return _margin;
2013-09-13 22:20:20 +08:00
}
2013-11-06 16:04:06 +08:00
LayoutParameterType UILayoutParameter::getLayoutType() const
2013-09-13 22:20:20 +08:00
{
2013-09-16 20:54:13 +08:00
return _layoutParameterType;
2013-09-13 22:20:20 +08:00
}
2013-11-06 16:04:06 +08:00
UILinearLayoutParameter* UILinearLayoutParameter::create()
2013-09-13 22:20:20 +08:00
{
2013-11-06 16:04:06 +08:00
UILinearLayoutParameter* parameter = new UILinearLayoutParameter();
2013-09-13 22:20:20 +08:00
if (parameter)
{
parameter->autorelease();
return parameter;
}
CC_SAFE_DELETE(parameter);
2013-11-14 11:37:46 +08:00
return nullptr;
2013-09-13 22:20:20 +08:00
}
2013-11-06 16:04:06 +08:00
void UILinearLayoutParameter::setGravity(UILinearGravity gravity)
2013-09-13 22:20:20 +08:00
{
2013-09-25 19:04:37 +08:00
_linearGravity = gravity;
2013-09-13 22:20:20 +08:00
}
2013-11-06 16:04:06 +08:00
UILinearGravity UILinearLayoutParameter::getGravity() const
2013-09-13 22:20:20 +08:00
{
2013-09-25 19:04:37 +08:00
return _linearGravity;
2013-09-13 22:20:20 +08:00
}
2013-11-06 16:04:06 +08:00
UIRelativeLayoutParameter* UIRelativeLayoutParameter::create()
2013-09-13 22:20:20 +08:00
{
2013-11-06 16:04:06 +08:00
UIRelativeLayoutParameter* parameter = new UIRelativeLayoutParameter();
2013-09-13 22:20:20 +08:00
if (parameter)
{
parameter->autorelease();
return parameter;
}
CC_SAFE_DELETE(parameter);
2013-11-14 11:37:46 +08:00
return nullptr;
2013-09-13 22:20:20 +08:00
}
2013-11-06 16:04:06 +08:00
void UIRelativeLayoutParameter::setAlign(UIRelativeAlign align)
2013-09-13 22:20:20 +08:00
{
2013-09-25 19:04:37 +08:00
_relativeAlign = align;
2013-09-13 22:20:20 +08:00
}
2013-11-06 16:04:06 +08:00
UIRelativeAlign UIRelativeLayoutParameter::getAlign() const
2013-09-13 22:20:20 +08:00
{
2013-09-25 19:04:37 +08:00
return _relativeAlign;
2013-09-13 22:20:20 +08:00
}
2013-11-06 16:04:06 +08:00
void UIRelativeLayoutParameter::setRelativeToWidgetName(const char *name)
2013-09-13 22:20:20 +08:00
{
2013-09-25 19:04:37 +08:00
_relativeWidgetName = name;
2013-09-13 22:20:20 +08:00
}
2013-11-06 16:04:06 +08:00
const char* UIRelativeLayoutParameter::getRelativeToWidgetName() const
2013-09-13 22:20:20 +08:00
{
2013-09-25 19:04:37 +08:00
return _relativeWidgetName.c_str();
2013-09-13 22:20:20 +08:00
}
2013-11-06 16:04:06 +08:00
void UIRelativeLayoutParameter::setRelativeName(const char* name)
2013-09-13 22:20:20 +08:00
{
2013-09-25 19:04:37 +08:00
_relativeLayoutName = name;
2013-09-13 22:20:20 +08:00
}
2013-11-06 16:04:06 +08:00
const char* UIRelativeLayoutParameter::getRelativeName() const
2013-09-13 22:20:20 +08:00
{
2013-09-25 19:04:37 +08:00
return _relativeLayoutName.c_str();
2013-09-13 22:20:20 +08:00
}
}