mirror of https://github.com/axmolengine/axmol.git
Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3_ui_binary
This commit is contained in:
commit
ea99c08d0e
|
@ -521,8 +521,8 @@ void Sprite::updateTransform(void)
|
|||
else
|
||||
{
|
||||
CCASSERT( dynamic_cast<Sprite*>(_parent), "Logic error in Sprite. Parent must be a Sprite");
|
||||
Mat4 nodeToParent = getNodeToParentTransform();
|
||||
Mat4 parentTransform = static_cast<Sprite*>(_parent)->_transformToBatch;
|
||||
const Mat4 &nodeToParent = getNodeToParentTransform();
|
||||
Mat4 &parentTransform = static_cast<Sprite*>(_parent)->_transformToBatch;
|
||||
_transformToBatch = parentTransform * nodeToParent;
|
||||
}
|
||||
|
||||
|
@ -530,7 +530,7 @@ void Sprite::updateTransform(void)
|
|||
// calculate the Quad based on the Affine Matrix
|
||||
//
|
||||
|
||||
Size size = _rect.size;
|
||||
Size &size = _rect.size;
|
||||
|
||||
float x1 = _offsetPosition.x;
|
||||
float y1 = _offsetPosition.y;
|
||||
|
|
|
@ -76,9 +76,9 @@ namespace cocostudio
|
|||
|
||||
}
|
||||
else if(key == P_Scale9Width){
|
||||
imageView->setSize(Size(valueToFloat(value), imageView->getSize().height));
|
||||
imageView->setContentSize(Size(valueToFloat(value), imageView->getContentSize().height));
|
||||
}else if(key == P_Scale9Height){
|
||||
imageView->setSize(Size(imageView->getSize().width, valueToFloat(value)));
|
||||
imageView->setContentSize(Size(imageView->getContentSize().width, valueToFloat(value)));
|
||||
}
|
||||
else if(key == P_CapInsetsX){
|
||||
capsx = valueToFloat(value);
|
||||
|
|
|
@ -187,7 +187,7 @@ namespace cocostudio
|
|||
w = DICTOOL->getFloatValue_json(options, P_Width);
|
||||
h = DICTOOL->getFloatValue_json(options, P_Height);
|
||||
}
|
||||
panel->setSize(Size(w, h));
|
||||
panel->setContentSize(Size(w, h));
|
||||
/**/
|
||||
|
||||
panel->setClippingEnabled(DICTOOL->getBooleanValue_json(options, P_ClipAble));
|
||||
|
|
|
@ -156,7 +156,7 @@ namespace cocostudio
|
|||
|
||||
if (barTextureScale9Enable)
|
||||
{
|
||||
slider->setSize(Size(barLength, slider->getContentSize().height));
|
||||
slider->setContentSize(Size(barLength, slider->getContentSize().height));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
-- @return Node#Node ret (return value: cc.Node)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getSize
|
||||
-- @function [parent=#Widget] getSizePercent
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
-- @return vec2_table#vec2_table ret (return value: vec2_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] setPositionPercent
|
||||
|
@ -203,11 +203,6 @@
|
|||
-- @param self
|
||||
-- @param #size_table size
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getSizePercent
|
||||
-- @param self
|
||||
-- @return vec2_table#vec2_table ret (return value: vec2_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getTouchMovePosition
|
||||
-- @param self
|
||||
|
@ -260,11 +255,6 @@
|
|||
-- @param self
|
||||
-- @param #ccui.Widget::SizeType sizetype
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] setSize
|
||||
-- @param self
|
||||
-- @param #size_table size
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] setBright
|
||||
-- @param self
|
||||
|
@ -295,6 +285,11 @@
|
|||
-- @param self
|
||||
-- @param #vec2_table vec2
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] setContentSize
|
||||
-- @param self
|
||||
-- @param #size_table size
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] Widget
|
||||
-- @param self
|
||||
|
|
|
@ -1039,7 +1039,7 @@ int lua_cocos2dx_ui_Widget_getVirtualRenderer(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_ui_Widget_getSize(lua_State* tolua_S)
|
||||
int lua_cocos2dx_ui_Widget_getSizePercent(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::ui::Widget* cobj = nullptr;
|
||||
|
@ -1059,7 +1059,7 @@ int lua_cocos2dx_ui_Widget_getSize(lua_State* tolua_S)
|
|||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getSize'", nullptr);
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getSizePercent'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -1069,16 +1069,16 @@ int lua_cocos2dx_ui_Widget_getSize(lua_State* tolua_S)
|
|||
{
|
||||
if(!ok)
|
||||
return 0;
|
||||
const cocos2d::Size& ret = cobj->getSize();
|
||||
size_to_luaval(tolua_S, ret);
|
||||
const cocos2d::Vec2& ret = cobj->getSizePercent();
|
||||
vec2_to_luaval(tolua_S, ret);
|
||||
return 1;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSize",argc, 0);
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSizePercent",argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getSize'.",&tolua_err);
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getSizePercent'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -2567,50 +2567,6 @@ int lua_cocos2dx_ui_Widget_updateSizeAndPosition(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_ui_Widget_getSizePercent(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::ui::Widget* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getSizePercent'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 0)
|
||||
{
|
||||
if(!ok)
|
||||
return 0;
|
||||
const cocos2d::Vec2& ret = cobj->getSizePercent();
|
||||
vec2_to_luaval(tolua_S, ret);
|
||||
return 1;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSizePercent",argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getSizePercent'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_ui_Widget_getTouchMovePosition(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
|
@ -3065,52 +3021,6 @@ int lua_cocos2dx_ui_Widget_setSizeType(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_ui_Widget_setSize(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::ui::Widget* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_setSize'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 1)
|
||||
{
|
||||
cocos2d::Size arg0;
|
||||
|
||||
ok &= luaval_to_size(tolua_S, 2, &arg0);
|
||||
if(!ok)
|
||||
return 0;
|
||||
cobj->setSize(arg0);
|
||||
return 0;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSize",argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_setSize'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_ui_Widget_setBright(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
|
@ -3316,7 +3226,7 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S)
|
|||
tolua_function(tolua_S,"setFlippedY",lua_cocos2dx_ui_Widget_setFlippedY);
|
||||
tolua_function(tolua_S,"setFlippedX",lua_cocos2dx_ui_Widget_setFlippedX);
|
||||
tolua_function(tolua_S,"getVirtualRenderer",lua_cocos2dx_ui_Widget_getVirtualRenderer);
|
||||
tolua_function(tolua_S,"getSize",lua_cocos2dx_ui_Widget_getSize);
|
||||
tolua_function(tolua_S,"getSizePercent",lua_cocos2dx_ui_Widget_getSizePercent);
|
||||
tolua_function(tolua_S,"setPositionPercent",lua_cocos2dx_ui_Widget_setPositionPercent);
|
||||
tolua_function(tolua_S,"getLayoutSize",lua_cocos2dx_ui_Widget_getLayoutSize);
|
||||
tolua_function(tolua_S,"setHighlighted",lua_cocos2dx_ui_Widget_setHighlighted);
|
||||
|
@ -3350,7 +3260,6 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S)
|
|||
tolua_function(tolua_S,"getCurrentFocusedWidget",lua_cocos2dx_ui_Widget_getCurrentFocusedWidget);
|
||||
tolua_function(tolua_S,"requestFocus",lua_cocos2dx_ui_Widget_requestFocus);
|
||||
tolua_function(tolua_S,"updateSizeAndPosition",lua_cocos2dx_ui_Widget_updateSizeAndPosition);
|
||||
tolua_function(tolua_S,"getSizePercent",lua_cocos2dx_ui_Widget_getSizePercent);
|
||||
tolua_function(tolua_S,"getTouchMovePosition",lua_cocos2dx_ui_Widget_getTouchMovePosition);
|
||||
tolua_function(tolua_S,"getSizeType",lua_cocos2dx_ui_Widget_getSizeType);
|
||||
tolua_function(tolua_S,"addTouchEventListener",lua_cocos2dx_ui_Widget_addTouchEventListener);
|
||||
|
@ -3361,7 +3270,6 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S)
|
|||
tolua_function(tolua_S,"isFlippedY",lua_cocos2dx_ui_Widget_isFlippedY);
|
||||
tolua_function(tolua_S,"isClippingParentContainsPoint",lua_cocos2dx_ui_Widget_isClippingParentContainsPoint);
|
||||
tolua_function(tolua_S,"setSizeType",lua_cocos2dx_ui_Widget_setSizeType);
|
||||
tolua_function(tolua_S,"setSize",lua_cocos2dx_ui_Widget_setSize);
|
||||
tolua_function(tolua_S,"setBright",lua_cocos2dx_ui_Widget_setBright);
|
||||
tolua_function(tolua_S,"isFocusEnabled",lua_cocos2dx_ui_Widget_isFocusEnabled);
|
||||
tolua_function(tolua_S,"enableDpadNavigation", lua_cocos2dx_ui_Widget_enableDpadNavigation);
|
||||
|
|
|
@ -384,8 +384,6 @@ int register_all_cocos2dx_ui(lua_State* tolua_S);
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -56,9 +56,9 @@ _capInsetsDisabled(Rect::ZERO),
|
|||
_normalTexType(TextureResType::LOCAL),
|
||||
_pressedTexType(TextureResType::LOCAL),
|
||||
_disabledTexType(TextureResType::LOCAL),
|
||||
_normalTextureSize(_size),
|
||||
_pressedTextureSize(_size),
|
||||
_disabledTextureSize(_size),
|
||||
_normalTextureSize(_contentSize),
|
||||
_pressedTextureSize(_contentSize),
|
||||
_disabledTextureSize(_contentSize),
|
||||
_pressedActionEnabled(false),
|
||||
_titleColor(Color3B::WHITE),
|
||||
_normalTextureScaleXInSize(1.0f),
|
||||
|
@ -615,7 +615,7 @@ void Button::normalTextureScaleChangedWithSize()
|
|||
{
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
static_cast<extension::Scale9Sprite*>(_buttonNormalRenderer)->setPreferredSize(_size);
|
||||
static_cast<extension::Scale9Sprite*>(_buttonNormalRenderer)->setPreferredSize(_contentSize);
|
||||
_normalTextureScaleXInSize = _normalTextureScaleYInSize = 1.0f;
|
||||
}
|
||||
else
|
||||
|
@ -626,8 +626,8 @@ void Button::normalTextureScaleChangedWithSize()
|
|||
_buttonNormalRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float scaleX = _size.width / textureSize.width;
|
||||
float scaleY = _size.height / textureSize.height;
|
||||
float scaleX = _contentSize.width / textureSize.width;
|
||||
float scaleY = _contentSize.height / textureSize.height;
|
||||
_buttonNormalRenderer->setScaleX(scaleX);
|
||||
_buttonNormalRenderer->setScaleY(scaleY);
|
||||
_normalTextureScaleXInSize = scaleX;
|
||||
|
@ -651,7 +651,7 @@ void Button::pressedTextureScaleChangedWithSize()
|
|||
{
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
static_cast<extension::Scale9Sprite*>(_buttonClickedRenderer)->setPreferredSize(_size);
|
||||
static_cast<extension::Scale9Sprite*>(_buttonClickedRenderer)->setPreferredSize(_contentSize);
|
||||
_pressedTextureScaleXInSize = _pressedTextureScaleYInSize = 1.0f;
|
||||
}
|
||||
else
|
||||
|
@ -662,8 +662,8 @@ void Button::pressedTextureScaleChangedWithSize()
|
|||
_buttonClickedRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float scaleX = _size.width / _pressedTextureSize.width;
|
||||
float scaleY = _size.height / _pressedTextureSize.height;
|
||||
float scaleX = _contentSize.width / _pressedTextureSize.width;
|
||||
float scaleY = _contentSize.height / _pressedTextureSize.height;
|
||||
_buttonClickedRenderer->setScaleX(scaleX);
|
||||
_buttonClickedRenderer->setScaleY(scaleY);
|
||||
_pressedTextureScaleXInSize = scaleX;
|
||||
|
@ -686,7 +686,7 @@ void Button::disabledTextureScaleChangedWithSize()
|
|||
{
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
static_cast<extension::Scale9Sprite*>(_buttonDisableRenderer)->setPreferredSize(_size);
|
||||
static_cast<extension::Scale9Sprite*>(_buttonDisableRenderer)->setPreferredSize(_contentSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -696,8 +696,8 @@ void Button::disabledTextureScaleChangedWithSize()
|
|||
_buttonDisableRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float scaleX = _size.width / _disabledTextureSize.width;
|
||||
float scaleY = _size.height / _disabledTextureSize.height;
|
||||
float scaleX = _contentSize.width / _disabledTextureSize.width;
|
||||
float scaleY = _contentSize.height / _disabledTextureSize.height;
|
||||
_buttonDisableRenderer->setScaleX(scaleX);
|
||||
_buttonDisableRenderer->setScaleY(scaleY);
|
||||
}
|
||||
|
|
|
@ -473,8 +473,8 @@ void CheckBox::backGroundTextureScaleChangedWithSize()
|
|||
_backGroundBoxRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float scaleX = _size.width / textureSize.width;
|
||||
float scaleY = _size.height / textureSize.height;
|
||||
float scaleX = _contentSize.width / textureSize.width;
|
||||
float scaleY = _contentSize.height / textureSize.height;
|
||||
_backGroundBoxRenderer->setScaleX(scaleX);
|
||||
_backGroundBoxRenderer->setScaleY(scaleY);
|
||||
}
|
||||
|
@ -495,8 +495,8 @@ void CheckBox::backGroundSelectedTextureScaleChangedWithSize()
|
|||
_backGroundSelectedBoxRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float scaleX = _size.width / textureSize.width;
|
||||
float scaleY = _size.height / textureSize.height;
|
||||
float scaleX = _contentSize.width / textureSize.width;
|
||||
float scaleY = _contentSize.height / textureSize.height;
|
||||
_backGroundSelectedBoxRenderer->setScaleX(scaleX);
|
||||
_backGroundSelectedBoxRenderer->setScaleY(scaleY);
|
||||
}
|
||||
|
@ -517,8 +517,8 @@ void CheckBox::frontCrossTextureScaleChangedWithSize()
|
|||
_frontCrossRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float scaleX = _size.width / textureSize.width;
|
||||
float scaleY = _size.height / textureSize.height;
|
||||
float scaleX = _contentSize.width / textureSize.width;
|
||||
float scaleY = _contentSize.height / textureSize.height;
|
||||
_frontCrossRenderer->setScaleX(scaleX);
|
||||
_frontCrossRenderer->setScaleY(scaleY);
|
||||
}
|
||||
|
@ -539,8 +539,8 @@ void CheckBox::backGroundDisabledTextureScaleChangedWithSize()
|
|||
_backGroundBoxDisabledRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float scaleX = _size.width / textureSize.width;
|
||||
float scaleY = _size.height / textureSize.height;
|
||||
float scaleX = _contentSize.width / textureSize.width;
|
||||
float scaleY = _contentSize.height / textureSize.height;
|
||||
_backGroundBoxDisabledRenderer->setScaleX(scaleX);
|
||||
_backGroundBoxDisabledRenderer->setScaleY(scaleY);
|
||||
}
|
||||
|
@ -561,8 +561,8 @@ void CheckBox::frontCrossDisabledTextureScaleChangedWithSize()
|
|||
_frontCrossDisabledRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float scaleX = _size.width / textureSize.width;
|
||||
float scaleY = _size.height / textureSize.height;
|
||||
float scaleX = _contentSize.width / textureSize.width;
|
||||
float scaleY = _contentSize.height / textureSize.height;
|
||||
_frontCrossDisabledRenderer->setScaleX(scaleX);
|
||||
_frontCrossDisabledRenderer->setScaleY(scaleY);
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ bool HBox::initWithSize(const Size& size)
|
|||
{
|
||||
if (init())
|
||||
{
|
||||
setSize(size);
|
||||
setContentSize(size);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -45,7 +45,7 @@ _capInsets(Rect::ZERO),
|
|||
_imageRenderer(nullptr),
|
||||
_textureFile(""),
|
||||
_imageTexType(TextureResType::LOCAL),
|
||||
_imageTextureSize(_size),
|
||||
_imageTextureSize(_contentSize),
|
||||
_imageRendererAdaptDirty(true)
|
||||
{
|
||||
|
||||
|
@ -300,7 +300,7 @@ void ImageView::imageTextureScaleChangedWithSize()
|
|||
{
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
static_cast<extension::Scale9Sprite*>(_imageRenderer)->setPreferredSize(_size);
|
||||
static_cast<extension::Scale9Sprite*>(_imageRenderer)->setPreferredSize(_contentSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -310,8 +310,8 @@ void ImageView::imageTextureScaleChangedWithSize()
|
|||
_imageRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float scaleX = _size.width / textureSize.width;
|
||||
float scaleY = _size.height / textureSize.height;
|
||||
float scaleX = _contentSize.width / textureSize.width;
|
||||
float scaleY = _contentSize.height / textureSize.height;
|
||||
_imageRenderer->setScaleX(scaleX);
|
||||
_imageRenderer->setScaleY(scaleY);
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ bool Layout::init()
|
|||
if (Widget::init())
|
||||
{
|
||||
ignoreContentAdaptWithSize(false);
|
||||
setSize(Size::ZERO);
|
||||
setContentSize(Size::ZERO);
|
||||
setAnchorPoint(Vec2::ZERO);
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this);
|
||||
return true;
|
||||
|
@ -429,7 +429,7 @@ void Layout::setClippingEnabled(bool able)
|
|||
_clippingStencil->onEnter();
|
||||
}
|
||||
_clippingStencil->retain();
|
||||
setStencilClippingSize(_size);
|
||||
setStencilClippingSize(_contentSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -469,9 +469,9 @@ void Layout::setStencilClippingSize(const Size &size)
|
|||
{
|
||||
Vec2 rect[4];
|
||||
rect[0] = Vec2::ZERO;
|
||||
rect[1] = Vec2(_size.width, 0);
|
||||
rect[2] = Vec2(_size.width, _size.height);
|
||||
rect[3] = Vec2(0, _size.height);
|
||||
rect[1] = Vec2(_contentSize.width, 0);
|
||||
rect[2] = Vec2(_contentSize.width, _contentSize.height);
|
||||
rect[3] = Vec2(0, _contentSize.height);
|
||||
Color4F green(0, 1, 0, 1);
|
||||
_clippingStencil->clear();
|
||||
_clippingStencil->drawPolygon(rect, 4, green, 0, green);
|
||||
|
@ -484,8 +484,8 @@ const Rect& Layout::getClippingRect()
|
|||
{
|
||||
Vec2 worldPos = convertToWorldSpace(Vec2::ZERO);
|
||||
AffineTransform t = getNodeToWorldAffineTransform();
|
||||
float scissorWidth = _size.width*t.a;
|
||||
float scissorHeight = _size.height*t.d;
|
||||
float scissorWidth = _contentSize.width*t.a;
|
||||
float scissorHeight = _contentSize.height*t.d;
|
||||
Rect parentClippingRect;
|
||||
Layout* parent = this;
|
||||
|
||||
|
@ -560,24 +560,24 @@ const Rect& Layout::getClippingRect()
|
|||
void Layout::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
setStencilClippingSize(_size);
|
||||
setStencilClippingSize(_contentSize);
|
||||
_doLayoutDirty = true;
|
||||
_clippingRectDirty = true;
|
||||
if (_backGroundImage)
|
||||
{
|
||||
_backGroundImage->setPosition(Vec2(_size.width/2.0f, _size.height/2.0f));
|
||||
_backGroundImage->setPosition(Vec2(_contentSize.width/2.0f, _contentSize.height/2.0f));
|
||||
if (_backGroundScale9Enabled && _backGroundImage)
|
||||
{
|
||||
static_cast<extension::Scale9Sprite*>(_backGroundImage)->setPreferredSize(_size);
|
||||
static_cast<extension::Scale9Sprite*>(_backGroundImage)->setPreferredSize(_contentSize);
|
||||
}
|
||||
}
|
||||
if (_colorRender)
|
||||
{
|
||||
_colorRender->setContentSize(_size);
|
||||
_colorRender->setContentSize(_contentSize);
|
||||
}
|
||||
if (_gradientRender)
|
||||
{
|
||||
_gradientRender->setContentSize(_size);
|
||||
_gradientRender->setContentSize(_contentSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -626,7 +626,7 @@ void Layout::setBackGroundImage(const std::string& fileName,TextureResType texTy
|
|||
default:
|
||||
break;
|
||||
}
|
||||
bgiScale9->setPreferredSize(_size);
|
||||
bgiScale9->setPreferredSize(_contentSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -643,7 +643,7 @@ void Layout::setBackGroundImage(const std::string& fileName,TextureResType texTy
|
|||
}
|
||||
}
|
||||
_backGroundImageTextureSize = _backGroundImage->getContentSize();
|
||||
_backGroundImage->setPosition(Vec2(_size.width/2.0f, _size.height/2.0f));
|
||||
_backGroundImage->setPosition(Vec2(_contentSize.width/2.0f, _contentSize.height/2.0f));
|
||||
updateBackGroundImageRGBA();
|
||||
}
|
||||
|
||||
|
@ -701,14 +701,14 @@ void Layout::addBackGroundImage()
|
|||
{
|
||||
_backGroundImage = extension::Scale9Sprite::create();
|
||||
addProtectedChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1);
|
||||
static_cast<extension::Scale9Sprite*>(_backGroundImage)->setPreferredSize(_size);
|
||||
static_cast<extension::Scale9Sprite*>(_backGroundImage)->setPreferredSize(_contentSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
_backGroundImage = Sprite::create();
|
||||
addProtectedChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1);
|
||||
}
|
||||
_backGroundImage->setPosition(Vec2(_size.width/2.0f, _size.height/2.0f));
|
||||
_backGroundImage->setPosition(Vec2(_contentSize.width/2.0f, _contentSize.height/2.0f));
|
||||
}
|
||||
|
||||
void Layout::removeBackGroundImage()
|
||||
|
@ -767,14 +767,14 @@ void Layout::setBackGroundColorType(BackGroundColorType type)
|
|||
break;
|
||||
case BackGroundColorType::SOLID:
|
||||
_colorRender = LayerColor::create();
|
||||
_colorRender->setContentSize(_size);
|
||||
_colorRender->setContentSize(_contentSize);
|
||||
_colorRender->setOpacity(_cOpacity);
|
||||
_colorRender->setColor(_cColor);
|
||||
addProtectedChild(_colorRender, BCAKGROUNDCOLORRENDERER_Z, -1);
|
||||
break;
|
||||
case BackGroundColorType::GRADIENT:
|
||||
_gradientRender = LayerGradient::create();
|
||||
_gradientRender->setContentSize(_size);
|
||||
_gradientRender->setContentSize(_contentSize);
|
||||
_gradientRender->setOpacity(_cOpacity);
|
||||
_gradientRender->setStartColor(_gStartColor);
|
||||
_gradientRender->setEndColor(_gEndColor);
|
||||
|
@ -947,7 +947,7 @@ void Layout::requestDoLayout()
|
|||
|
||||
Size Layout::getLayoutContentSize()const
|
||||
{
|
||||
return this->getSize();
|
||||
return this->getContentSize();
|
||||
}
|
||||
|
||||
const Vector<Node*>& Layout::getLayoutElements()const
|
||||
|
@ -1068,7 +1068,7 @@ Size Layout::getLayoutAccumulatedSize()const
|
|||
{
|
||||
widgetCount++;
|
||||
Margin m = w->getLayoutParameter()->getMargin();
|
||||
layoutSize = layoutSize + w->getSize() + Size(m.right + m.left, m.top + m.bottom) * 0.5;
|
||||
layoutSize = layoutSize + w->getContentSize() + Size(m.right + m.left, m.top + m.bottom) * 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1090,7 +1090,7 @@ Vec2 Layout::getWorldCenterPoint(Widget* widget)const
|
|||
{
|
||||
Layout *layout = dynamic_cast<Layout*>(widget);
|
||||
//FIXEDME: we don't need to calculate the content size of layout anymore
|
||||
Size widgetSize = layout ? layout->getLayoutAccumulatedSize() : widget->getSize();
|
||||
Size widgetSize = layout ? layout->getLayoutAccumulatedSize() : widget->getContentSize();
|
||||
// CCLOG("contnet size : width = %f, height = %f", widgetSize.width, widgetSize.height);
|
||||
return widget->convertToWorldSpace(Vec2(widgetSize.width/2, widgetSize.height/2));
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ void LinearHorizontalLayoutManager::doLayout(LayoutProtocol* layout)
|
|||
{
|
||||
LinearLayoutParameter::LinearGravity childGravity = layoutParameter->getGravity();
|
||||
Vec2 ap = child->getAnchorPoint();
|
||||
Size cs = child->getSize();
|
||||
Size cs = child->getContentSize();
|
||||
float finalPosX = leftBoundary + (ap.x * cs.width);
|
||||
float finalPosY = layoutSize.height - (1.0f - ap.y) * cs.height;
|
||||
switch (childGravity)
|
||||
|
@ -206,7 +206,7 @@ Widget* RelativeLayoutManager::getRelativeWidget(Widget* widget)
|
|||
bool RelativeLayoutManager::caculateFinalPositionWithRelativeWidget(LayoutProtocol *layout)
|
||||
{
|
||||
Vec2 ap = _widget->getAnchorPoint();
|
||||
Size cs = _widget->getSize();
|
||||
Size cs = _widget->getContentSize();
|
||||
|
||||
_finalPositionX = 0.0f;
|
||||
_finalPositionY = 0.0f;
|
||||
|
@ -280,7 +280,7 @@ bool RelativeLayoutManager::caculateFinalPositionWithRelativeWidget(LayoutProtoc
|
|||
{
|
||||
return false;
|
||||
}
|
||||
Size rbs = relativeWidget->getSize();
|
||||
Size rbs = relativeWidget->getContentSize();
|
||||
float locationTop = relativeWidget->getTopBoundary();
|
||||
|
||||
_finalPositionY = locationTop + ap.y * cs.height;
|
||||
|
@ -320,7 +320,7 @@ bool RelativeLayoutManager::caculateFinalPositionWithRelativeWidget(LayoutProtoc
|
|||
{
|
||||
return false;
|
||||
}
|
||||
Size rbs = relativeWidget->getSize();
|
||||
Size rbs = relativeWidget->getContentSize();
|
||||
float locationLeft = relativeWidget->getLeftBoundary();
|
||||
_finalPositionX = locationLeft - (1.0f - ap.x) * cs.width;
|
||||
|
||||
|
@ -360,7 +360,7 @@ bool RelativeLayoutManager::caculateFinalPositionWithRelativeWidget(LayoutProtoc
|
|||
{
|
||||
return false;
|
||||
}
|
||||
Size rbs = relativeWidget->getSize();
|
||||
Size rbs = relativeWidget->getContentSize();
|
||||
float locationRight = relativeWidget->getRightBoundary();
|
||||
_finalPositionX = locationRight + ap.x * cs.width;
|
||||
|
||||
|
@ -400,7 +400,7 @@ bool RelativeLayoutManager::caculateFinalPositionWithRelativeWidget(LayoutProtoc
|
|||
{
|
||||
return false;
|
||||
}
|
||||
Size rbs = relativeWidget->getSize();
|
||||
Size rbs = relativeWidget->getContentSize();
|
||||
float locationBottom = relativeWidget->getBottomBoundary();
|
||||
|
||||
_finalPositionY = locationBottom - (1.0f - ap.y) * cs.height;
|
||||
|
|
|
@ -96,9 +96,9 @@ void ListView::updateInnerContainerSize()
|
|||
float totalHeight = (length - 1) * _itemsMargin;
|
||||
for (auto& item : _items)
|
||||
{
|
||||
totalHeight += item->getSize().height;
|
||||
totalHeight += item->getContentSize().height;
|
||||
}
|
||||
float finalWidth = _size.width;
|
||||
float finalWidth = _contentSize.width;
|
||||
float finalHeight = totalHeight;
|
||||
setInnerContainerSize(Size(finalWidth, finalHeight));
|
||||
break;
|
||||
|
@ -109,10 +109,10 @@ void ListView::updateInnerContainerSize()
|
|||
float totalWidth = (length - 1) * _itemsMargin;
|
||||
for (auto& item : _items)
|
||||
{
|
||||
totalWidth += item->getSize().width;
|
||||
totalWidth += item->getContentSize().width;
|
||||
}
|
||||
float finalWidth = totalWidth;
|
||||
float finalHeight = _size.height;
|
||||
float finalHeight = _contentSize.height;
|
||||
setInnerContainerSize(Size(finalWidth, finalHeight));
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -317,7 +317,7 @@ void LoadingBar::barRendererScaleChangedWithSize()
|
|||
}
|
||||
else
|
||||
{
|
||||
_totalLength = _size.width;
|
||||
_totalLength = _contentSize.width;
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
setScale9Scale();
|
||||
|
@ -331,8 +331,8 @@ void LoadingBar::barRendererScaleChangedWithSize()
|
|||
_barRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float scaleX = _size.width / textureSize.width;
|
||||
float scaleY = _size.height / textureSize.height;
|
||||
float scaleX = _contentSize.width / textureSize.width;
|
||||
float scaleY = _contentSize.height / textureSize.height;
|
||||
_barRenderer->setScaleX(scaleX);
|
||||
_barRenderer->setScaleY(scaleY);
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ void LoadingBar::barRendererScaleChangedWithSize()
|
|||
void LoadingBar::setScale9Scale()
|
||||
{
|
||||
float width = (float)(_percent) / 100.0f * _totalLength;
|
||||
static_cast<extension::Scale9Sprite*>(_barRenderer)->setPreferredSize(Size(width, _size.height));
|
||||
static_cast<extension::Scale9Sprite*>(_barRenderer)->setPreferredSize(Size(width, _contentSize.height));
|
||||
}
|
||||
|
||||
std::string LoadingBar::getDescription() const
|
||||
|
|
|
@ -121,7 +121,7 @@ void PageView::addWidgetToPage(Widget *widget, ssize_t pageIdx, bool forceCreate
|
|||
Layout* PageView::createPage()
|
||||
{
|
||||
Layout* newPage = Layout::create();
|
||||
newPage->setSize(getSize());
|
||||
newPage->setContentSize(getContentSize());
|
||||
return newPage;
|
||||
}
|
||||
|
||||
|
@ -212,23 +212,23 @@ ssize_t PageView::getPageCount()const
|
|||
|
||||
float PageView::getPositionXByIndex(ssize_t idx)const
|
||||
{
|
||||
return (getSize().width * (idx-_curPageIdx));
|
||||
return (getContentSize().width * (idx-_curPageIdx));
|
||||
}
|
||||
|
||||
void PageView::onSizeChanged()
|
||||
{
|
||||
Layout::onSizeChanged();
|
||||
_rightBoundary = getSize().width;
|
||||
_rightBoundary = getContentSize().width;
|
||||
|
||||
_doLayoutDirty = true;
|
||||
}
|
||||
|
||||
void PageView::updateAllPagesSize()
|
||||
{
|
||||
Size selfSize = getSize();
|
||||
Size selfSize = getContentSize();
|
||||
for (auto& page : _pages)
|
||||
{
|
||||
page->setSize(selfSize);
|
||||
page->setContentSize(selfSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ void PageView::updateAllPagesPosition()
|
|||
_curPageIdx = pageCount-1;
|
||||
}
|
||||
|
||||
float pageWidth = getSize().width;
|
||||
float pageWidth = getContentSize().width;
|
||||
for (int i=0; i<pageCount; i++)
|
||||
{
|
||||
Layout* page = _pages.at(i);
|
||||
|
@ -467,7 +467,7 @@ void PageView::handleReleaseLogic(Touch *touch)
|
|||
Vec2 curPagePos = curPage->getPosition();
|
||||
ssize_t pageCount = this->getPageCount();
|
||||
float curPageLocation = curPagePos.x;
|
||||
float pageWidth = getSize().width;
|
||||
float pageWidth = getContentSize().width;
|
||||
float boundary = pageWidth/2.0f;
|
||||
if (curPageLocation <= -boundary)
|
||||
{
|
||||
|
|
|
@ -74,7 +74,7 @@ bool RelativeBox::initWithSize(const Size& size)
|
|||
{
|
||||
if (init())
|
||||
{
|
||||
setSize(size);
|
||||
setContentSize(size);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -414,7 +414,7 @@ void RichText::formarRenderers()
|
|||
nextPosX += l->getContentSize().width;
|
||||
}
|
||||
}
|
||||
_elementRenderersContainer->setContentSize(_size);
|
||||
_elementRenderersContainer->setContentSize(_contentSize);
|
||||
delete [] maxHeights;
|
||||
}
|
||||
|
||||
|
@ -430,13 +430,13 @@ void RichText::formarRenderers()
|
|||
if (_ignoreSize)
|
||||
{
|
||||
Size s = getVirtualRendererSize();
|
||||
_size = s;
|
||||
this->setContentSize(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
_size = _customSize;
|
||||
this->setContentSize(_customSize);
|
||||
}
|
||||
updateContentSizeWithTextureSize(_size);
|
||||
updateContentSizeWithTextureSize(_contentSize);
|
||||
_elementRenderersContainer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
|
|
|
@ -128,29 +128,29 @@ void ScrollView::initRenderer()
|
|||
void ScrollView::onSizeChanged()
|
||||
{
|
||||
Layout::onSizeChanged();
|
||||
_topBoundary = _size.height;
|
||||
_rightBoundary = _size.width;
|
||||
float bounceBoundaryParameterX = _size.width / 3.0f;
|
||||
float bounceBoundaryParameterY = _size.height / 3.0f;
|
||||
_bounceTopBoundary = _size.height - bounceBoundaryParameterY;
|
||||
_topBoundary = _contentSize.height;
|
||||
_rightBoundary = _contentSize.width;
|
||||
float bounceBoundaryParameterX = _contentSize.width / 3.0f;
|
||||
float bounceBoundaryParameterY = _contentSize.height / 3.0f;
|
||||
_bounceTopBoundary = _contentSize.height - bounceBoundaryParameterY;
|
||||
_bounceBottomBoundary = bounceBoundaryParameterY;
|
||||
_bounceLeftBoundary = bounceBoundaryParameterX;
|
||||
_bounceRightBoundary = _size.width - bounceBoundaryParameterX;
|
||||
Size innerSize = _innerContainer->getSize();
|
||||
_bounceRightBoundary = _contentSize.width - bounceBoundaryParameterX;
|
||||
Size innerSize = _innerContainer->getContentSize();
|
||||
float orginInnerSizeWidth = innerSize.width;
|
||||
float orginInnerSizeHeight = innerSize.height;
|
||||
float innerSizeWidth = MAX(orginInnerSizeWidth, _size.width);
|
||||
float innerSizeHeight = MAX(orginInnerSizeHeight, _size.height);
|
||||
_innerContainer->setSize(Size(innerSizeWidth, innerSizeHeight));
|
||||
_innerContainer->setPosition(Vec2(0, _size.height - _innerContainer->getSize().height));
|
||||
float innerSizeWidth = MAX(orginInnerSizeWidth, _contentSize.width);
|
||||
float innerSizeHeight = MAX(orginInnerSizeHeight, _contentSize.height);
|
||||
_innerContainer->setContentSize(Size(innerSizeWidth, innerSizeHeight));
|
||||
_innerContainer->setPosition(Vec2(0, _contentSize.height - _innerContainer->getContentSize().height));
|
||||
}
|
||||
|
||||
void ScrollView::setInnerContainerSize(const Size &size)
|
||||
{
|
||||
float innerSizeWidth = _size.width;
|
||||
float innerSizeHeight = _size.height;
|
||||
Size originalInnerSize = _innerContainer->getSize();
|
||||
if (size.width < _size.width)
|
||||
float innerSizeWidth = _contentSize.width;
|
||||
float innerSizeHeight = _contentSize.height;
|
||||
Size originalInnerSize = _innerContainer->getContentSize();
|
||||
if (size.width < _contentSize.width)
|
||||
{
|
||||
CCLOG("Inner width <= scrollview width, it will be force sized!");
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ void ScrollView::setInnerContainerSize(const Size &size)
|
|||
{
|
||||
innerSizeWidth = size.width;
|
||||
}
|
||||
if (size.height < _size.height)
|
||||
if (size.height < _contentSize.height)
|
||||
{
|
||||
CCLOG("Inner height <= scrollview height, it will be force sized!");
|
||||
}
|
||||
|
@ -166,22 +166,22 @@ void ScrollView::setInnerContainerSize(const Size &size)
|
|||
{
|
||||
innerSizeHeight = size.height;
|
||||
}
|
||||
_innerContainer->setSize(Size(innerSizeWidth, innerSizeHeight));
|
||||
_innerContainer->setContentSize(Size(innerSizeWidth, innerSizeHeight));
|
||||
|
||||
switch (_direction)
|
||||
{
|
||||
case Direction::VERTICAL:
|
||||
{
|
||||
Size newInnerSize = _innerContainer->getSize();
|
||||
Size newInnerSize = _innerContainer->getContentSize();
|
||||
float offset = originalInnerSize.height - newInnerSize.height;
|
||||
scrollChildren(0.0f, offset);
|
||||
break;
|
||||
}
|
||||
case Direction::HORIZONTAL:
|
||||
{
|
||||
if (_innerContainer->getRightBoundary() <= _size.width)
|
||||
if (_innerContainer->getRightBoundary() <= _contentSize.width)
|
||||
{
|
||||
Size newInnerSize = _innerContainer->getSize();
|
||||
Size newInnerSize = _innerContainer->getContentSize();
|
||||
float offset = originalInnerSize.width - newInnerSize.width;
|
||||
scrollChildren(offset, 0.0f);
|
||||
}
|
||||
|
@ -189,10 +189,10 @@ void ScrollView::setInnerContainerSize(const Size &size)
|
|||
}
|
||||
case Direction::BOTH:
|
||||
{
|
||||
Size newInnerSize = _innerContainer->getSize();
|
||||
Size newInnerSize = _innerContainer->getContentSize();
|
||||
float offsetY = originalInnerSize.height - newInnerSize.height;
|
||||
float offsetX = 0.0f;
|
||||
if (_innerContainer->getRightBoundary() <= _size.width)
|
||||
if (_innerContainer->getRightBoundary() <= _contentSize.width)
|
||||
{
|
||||
offsetX = originalInnerSize.width - newInnerSize.width;
|
||||
}
|
||||
|
@ -204,25 +204,29 @@ void ScrollView::setInnerContainerSize(const Size &size)
|
|||
}
|
||||
if (_innerContainer->getLeftBoundary() > 0.0f)
|
||||
{
|
||||
_innerContainer->setPosition(Vec2(_innerContainer->getAnchorPoint().x * _innerContainer->getSize().width, _innerContainer->getPosition().y));
|
||||
_innerContainer->setPosition(Vec2(_innerContainer->getAnchorPoint().x * _innerContainer->getContentSize().width,
|
||||
_innerContainer->getPosition().y));
|
||||
}
|
||||
if (_innerContainer->getRightBoundary() < _size.width)
|
||||
if (_innerContainer->getRightBoundary() < _contentSize.width)
|
||||
{
|
||||
_innerContainer->setPosition(Vec2(_size.width - ((1.0f - _innerContainer->getAnchorPoint().x) * _innerContainer->getSize().width), _innerContainer->getPosition().y));
|
||||
_innerContainer->setPosition(Vec2(_contentSize.width - ((1.0f - _innerContainer->getAnchorPoint().x) * _innerContainer->getContentSize().width),
|
||||
_innerContainer->getPosition().y));
|
||||
}
|
||||
if (_innerContainer->getPosition().y > 0.0f)
|
||||
{
|
||||
_innerContainer->setPosition(Vec2(_innerContainer->getPosition().x, _innerContainer->getAnchorPoint().y * _innerContainer->getSize().height));
|
||||
_innerContainer->setPosition(Vec2(_innerContainer->getPosition().x,
|
||||
_innerContainer->getAnchorPoint().y * _innerContainer->getContentSize().height));
|
||||
}
|
||||
if (_innerContainer->getTopBoundary() < _size.height)
|
||||
if (_innerContainer->getTopBoundary() < _contentSize.height)
|
||||
{
|
||||
_innerContainer->setPosition(Vec2(_innerContainer->getPosition().x, _size.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getSize().height));
|
||||
_innerContainer->setPosition(Vec2(_innerContainer->getPosition().x,
|
||||
_contentSize.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getContentSize().height));
|
||||
}
|
||||
}
|
||||
|
||||
const Size& ScrollView::getInnerContainerSize() const
|
||||
{
|
||||
return _innerContainer->getSize();
|
||||
return _innerContainer->getContentSize();
|
||||
}
|
||||
|
||||
void ScrollView::addChild(Node *child)
|
||||
|
@ -359,14 +363,14 @@ bool ScrollView::checkNeedBounce()
|
|||
{
|
||||
if (_topBounceNeeded && _leftBounceNeeded)
|
||||
{
|
||||
Vec2 scrollVector = Vec2(0.0f, _size.height) - Vec2(_innerContainer->getLeftBoundary(), _innerContainer->getTopBoundary());
|
||||
Vec2 scrollVector = Vec2(0.0f, _contentSize.height) - Vec2(_innerContainer->getLeftBoundary(), _innerContainer->getTopBoundary());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.getNormalized();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_topBounceNeeded && _rightBounceNeeded)
|
||||
{
|
||||
Vec2 scrollVector = Vec2(_size.width, _size.height) - Vec2(_innerContainer->getRightBoundary(), _innerContainer->getTopBoundary());
|
||||
Vec2 scrollVector = Vec2(_contentSize.width, _contentSize.height) - Vec2(_innerContainer->getRightBoundary(), _innerContainer->getTopBoundary());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.getNormalized();
|
||||
startBounceChildren(orSpeed);
|
||||
|
@ -380,14 +384,14 @@ bool ScrollView::checkNeedBounce()
|
|||
}
|
||||
else if (_bottomBounceNeeded && _rightBounceNeeded)
|
||||
{
|
||||
Vec2 scrollVector = Vec2(_size.width, 0.0f) - Vec2(_innerContainer->getRightBoundary(), _innerContainer->getBottomBoundary());
|
||||
Vec2 scrollVector = Vec2(_contentSize.width, 0.0f) - Vec2(_innerContainer->getRightBoundary(), _innerContainer->getBottomBoundary());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.getNormalized();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_topBounceNeeded)
|
||||
{
|
||||
Vec2 scrollVector = Vec2(0.0f, _size.height) - Vec2(0.0f, _innerContainer->getTopBoundary());
|
||||
Vec2 scrollVector = Vec2(0.0f, _contentSize.height) - Vec2(0.0f, _innerContainer->getTopBoundary());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.getNormalized();
|
||||
startBounceChildren(orSpeed);
|
||||
|
@ -408,7 +412,7 @@ bool ScrollView::checkNeedBounce()
|
|||
}
|
||||
else if (_rightBounceNeeded)
|
||||
{
|
||||
Vec2 scrollVector = Vec2(_size.width, 0.0f) - Vec2(_innerContainer->getRightBoundary(), 0.0f);
|
||||
Vec2 scrollVector = Vec2(_contentSize.width, 0.0f) - Vec2(_innerContainer->getRightBoundary(), 0.0f);
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.getNormalized();
|
||||
startBounceChildren(orSpeed);
|
||||
|
@ -518,23 +522,23 @@ void ScrollView::jumpToDestination(const Vec2 &des)
|
|||
case Direction::VERTICAL:
|
||||
if (des.y <= 0)
|
||||
{
|
||||
finalOffsetY = MAX(des.y, _size.height - _innerContainer->getSize().height);
|
||||
finalOffsetY = MAX(des.y, _contentSize.height - _innerContainer->getContentSize().height);
|
||||
}
|
||||
break;
|
||||
case Direction::HORIZONTAL:
|
||||
if (des.x <= 0)
|
||||
{
|
||||
finalOffsetX = MAX(des.x, _size.width - _innerContainer->getSize().width);
|
||||
finalOffsetX = MAX(des.x, _contentSize.width - _innerContainer->getContentSize().width);
|
||||
}
|
||||
break;
|
||||
case Direction::BOTH:
|
||||
if (des.y <= 0)
|
||||
{
|
||||
finalOffsetY = MAX(des.y, _size.height - _innerContainer->getSize().height);
|
||||
finalOffsetY = MAX(des.y, _contentSize.height - _innerContainer->getContentSize().height);
|
||||
}
|
||||
if (des.x <= 0)
|
||||
{
|
||||
finalOffsetX = MAX(des.x, _size.width - _innerContainer->getSize().width);
|
||||
finalOffsetX = MAX(des.x, _contentSize.width - _innerContainer->getContentSize().width);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -1217,7 +1221,8 @@ void ScrollView::scrollToBottom(float time, bool attenuated)
|
|||
|
||||
void ScrollView::scrollToTop(float time, bool attenuated)
|
||||
{
|
||||
startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x, _size.height - _innerContainer->getSize().height), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x,
|
||||
_contentSize.height - _innerContainer->getContentSize().height), time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::scrollToLeft(float time, bool attenuated)
|
||||
|
@ -1227,7 +1232,8 @@ void ScrollView::scrollToLeft(float time, bool attenuated)
|
|||
|
||||
void ScrollView::scrollToRight(float time, bool attenuated)
|
||||
{
|
||||
startAutoScrollChildrenWithDestination(Vec2(_size.width - _innerContainer->getSize().width, _innerContainer->getPosition().y), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width,
|
||||
_innerContainer->getPosition().y), time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::scrollToTopLeft(float time, bool attenuated)
|
||||
|
@ -1237,7 +1243,7 @@ void ScrollView::scrollToTopLeft(float time, bool attenuated)
|
|||
CCLOG("Scroll diretion is not both!");
|
||||
return;
|
||||
}
|
||||
startAutoScrollChildrenWithDestination(Vec2(0.0f, _size.height - _innerContainer->getSize().height), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vec2(0.0f, _contentSize.height - _innerContainer->getContentSize().height), time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::scrollToTopRight(float time, bool attenuated)
|
||||
|
@ -1247,7 +1253,8 @@ void ScrollView::scrollToTopRight(float time, bool attenuated)
|
|||
CCLOG("Scroll diretion is not both!");
|
||||
return;
|
||||
}
|
||||
startAutoScrollChildrenWithDestination(Vec2(_size.width - _innerContainer->getSize().width, _size.height - _innerContainer->getSize().height), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width,
|
||||
_contentSize.height - _innerContainer->getContentSize().height), time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::scrollToBottomLeft(float time, bool attenuated)
|
||||
|
@ -1267,19 +1274,19 @@ void ScrollView::scrollToBottomRight(float time, bool attenuated)
|
|||
CCLOG("Scroll diretion is not both!");
|
||||
return;
|
||||
}
|
||||
startAutoScrollChildrenWithDestination(Vec2(_size.width - _innerContainer->getSize().width, 0.0f), time, attenuated);
|
||||
startAutoScrollChildrenWithDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width, 0.0f), time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::scrollToPercentVertical(float percent, float time, bool attenuated)
|
||||
{
|
||||
float minY = _size.height - _innerContainer->getSize().height;
|
||||
float minY = _contentSize.height - _innerContainer->getContentSize().height;
|
||||
float h = - minY;
|
||||
startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x, minY + percent * h / 100.0f), time, attenuated);
|
||||
}
|
||||
|
||||
void ScrollView::scrollToPercentHorizontal(float percent, float time, bool attenuated)
|
||||
{
|
||||
float w = _innerContainer->getSize().width - _size.width;
|
||||
float w = _innerContainer->getContentSize().width - _contentSize.width;
|
||||
startAutoScrollChildrenWithDestination(Vec2(-(percent * w / 100.0f), _innerContainer->getPosition().y), time, attenuated);
|
||||
}
|
||||
|
||||
|
@ -1289,9 +1296,9 @@ void ScrollView::scrollToPercentBothDirection(const Vec2& percent, float time, b
|
|||
{
|
||||
return;
|
||||
}
|
||||
float minY = _size.height - _innerContainer->getSize().height;
|
||||
float minY = _contentSize.height - _innerContainer->getContentSize().height;
|
||||
float h = - minY;
|
||||
float w = _innerContainer->getSize().width - _size.width;
|
||||
float w = _innerContainer->getContentSize().width - _contentSize.width;
|
||||
startAutoScrollChildrenWithDestination(Vec2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f), time, attenuated);
|
||||
}
|
||||
|
||||
|
@ -1302,7 +1309,8 @@ void ScrollView::jumpToBottom()
|
|||
|
||||
void ScrollView::jumpToTop()
|
||||
{
|
||||
jumpToDestination(Vec2(_innerContainer->getPosition().x, _size.height - _innerContainer->getSize().height));
|
||||
jumpToDestination(Vec2(_innerContainer->getPosition().x,
|
||||
_contentSize.height - _innerContainer->getContentSize().height));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToLeft()
|
||||
|
@ -1312,7 +1320,7 @@ void ScrollView::jumpToLeft()
|
|||
|
||||
void ScrollView::jumpToRight()
|
||||
{
|
||||
jumpToDestination(Vec2(_size.width - _innerContainer->getSize().width, _innerContainer->getPosition().y));
|
||||
jumpToDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width, _innerContainer->getPosition().y));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToTopLeft()
|
||||
|
@ -1322,7 +1330,7 @@ void ScrollView::jumpToTopLeft()
|
|||
CCLOG("Scroll diretion is not both!");
|
||||
return;
|
||||
}
|
||||
jumpToDestination(Vec2(0.0f, _size.height - _innerContainer->getSize().height));
|
||||
jumpToDestination(Vec2(0.0f, _contentSize.height - _innerContainer->getContentSize().height));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToTopRight()
|
||||
|
@ -1332,7 +1340,8 @@ void ScrollView::jumpToTopRight()
|
|||
CCLOG("Scroll diretion is not both!");
|
||||
return;
|
||||
}
|
||||
jumpToDestination(Vec2(_size.width - _innerContainer->getSize().width, _size.height - _innerContainer->getSize().height));
|
||||
jumpToDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width,
|
||||
_contentSize.height - _innerContainer->getContentSize().height));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToBottomLeft()
|
||||
|
@ -1352,19 +1361,19 @@ void ScrollView::jumpToBottomRight()
|
|||
CCLOG("Scroll diretion is not both!");
|
||||
return;
|
||||
}
|
||||
jumpToDestination(Vec2(_size.width - _innerContainer->getSize().width, 0.0f));
|
||||
jumpToDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width, 0.0f));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToPercentVertical(float percent)
|
||||
{
|
||||
float minY = _size.height - _innerContainer->getSize().height;
|
||||
float minY = _contentSize.height - _innerContainer->getContentSize().height;
|
||||
float h = - minY;
|
||||
jumpToDestination(Vec2(_innerContainer->getPosition().x, minY + percent * h / 100.0f));
|
||||
}
|
||||
|
||||
void ScrollView::jumpToPercentHorizontal(float percent)
|
||||
{
|
||||
float w = _innerContainer->getSize().width - _size.width;
|
||||
float w = _innerContainer->getContentSize().width - _contentSize.width;
|
||||
jumpToDestination(Vec2(-(percent * w / 100.0f), _innerContainer->getPosition().y));
|
||||
}
|
||||
|
||||
|
@ -1374,9 +1383,9 @@ void ScrollView::jumpToPercentBothDirection(const Vec2& percent)
|
|||
{
|
||||
return;
|
||||
}
|
||||
float minY = _size.height - _innerContainer->getSize().height;
|
||||
float minY = _contentSize.height - _innerContainer->getContentSize().height;
|
||||
float h = - minY;
|
||||
float w = _innerContainer->getSize().width - _size.width;
|
||||
float w = _innerContainer->getContentSize().width - _contentSize.width;
|
||||
jumpToDestination(Vec2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f));
|
||||
}
|
||||
|
||||
|
|
|
@ -500,14 +500,14 @@ void Slider::barRendererScaleChangedWithSize()
|
|||
{
|
||||
|
||||
_barRenderer->setScale(1.0f);
|
||||
_barLength = _size.width;
|
||||
_barLength = _contentSize.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
_barLength = _size.width;
|
||||
_barLength = _contentSize.width;
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
static_cast<extension::Scale9Sprite*>(_barRenderer)->setPreferredSize(_size);
|
||||
static_cast<extension::Scale9Sprite*>(_barRenderer)->setPreferredSize(_contentSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -517,8 +517,8 @@ void Slider::barRendererScaleChangedWithSize()
|
|||
_barRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float bscaleX = _size.width / btextureSize.width;
|
||||
float bscaleY = _size.height / btextureSize.height;
|
||||
float bscaleX = _contentSize.width / btextureSize.width;
|
||||
float bscaleY = _contentSize.height / btextureSize.height;
|
||||
_barRenderer->setScaleX(bscaleX);
|
||||
_barRenderer->setScaleY(bscaleY);
|
||||
}
|
||||
|
@ -534,8 +534,8 @@ void Slider::progressBarRendererScaleChangedWithSize()
|
|||
if (!_scale9Enabled)
|
||||
{
|
||||
Size ptextureSize = _progressBarTextureSize;
|
||||
float pscaleX = _size.width / ptextureSize.width;
|
||||
float pscaleY = _size.height / ptextureSize.height;
|
||||
float pscaleX = _contentSize.width / ptextureSize.width;
|
||||
float pscaleY = _contentSize.height / ptextureSize.height;
|
||||
_progressBarRenderer->setScaleX(pscaleX);
|
||||
_progressBarRenderer->setScaleY(pscaleY);
|
||||
}
|
||||
|
@ -544,7 +544,7 @@ void Slider::progressBarRendererScaleChangedWithSize()
|
|||
{
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
static_cast<extension::Scale9Sprite*>(_progressBarRenderer)->setPreferredSize(_size);
|
||||
static_cast<extension::Scale9Sprite*>(_progressBarRenderer)->setPreferredSize(_contentSize);
|
||||
_progressBarTextureSize = _progressBarRenderer->getContentSize();
|
||||
}
|
||||
else
|
||||
|
@ -555,8 +555,8 @@ void Slider::progressBarRendererScaleChangedWithSize()
|
|||
_progressBarRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float pscaleX = _size.width / ptextureSize.width;
|
||||
float pscaleY = _size.height / ptextureSize.height;
|
||||
float pscaleX = _contentSize.width / ptextureSize.width;
|
||||
float pscaleY = _contentSize.height / ptextureSize.height;
|
||||
_progressBarRenderer->setScaleX(pscaleX);
|
||||
_progressBarRenderer->setScaleY(pscaleY);
|
||||
}
|
||||
|
|
|
@ -302,15 +302,15 @@ void Text::labelScaleChangedWithSize()
|
|||
}
|
||||
else
|
||||
{
|
||||
_labelRenderer->setDimensions(_size.width,_size.height);
|
||||
_labelRenderer->setDimensions(_contentSize.width,_contentSize.height);
|
||||
Size textureSize = _labelRenderer->getContentSize();
|
||||
if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
|
||||
{
|
||||
_labelRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float scaleX = _size.width / textureSize.width;
|
||||
float scaleY = _size.height / textureSize.height;
|
||||
float scaleX = _contentSize.width / textureSize.width;
|
||||
float scaleY = _contentSize.height / textureSize.height;
|
||||
_labelRenderer->setScaleX(scaleX);
|
||||
_labelRenderer->setScaleY(scaleY);
|
||||
_normalScaleValueX = scaleX;
|
||||
|
|
|
@ -159,8 +159,8 @@ void TextAtlas::labelAtlasScaleChangedWithSize()
|
|||
_labelAtlasRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float scaleX = _size.width / textureSize.width;
|
||||
float scaleY = _size.height / textureSize.height;
|
||||
float scaleX = _contentSize.width / textureSize.width;
|
||||
float scaleY = _contentSize.height / textureSize.height;
|
||||
_labelAtlasRenderer->setScaleX(scaleX);
|
||||
_labelAtlasRenderer->setScaleY(scaleY);
|
||||
}
|
||||
|
|
|
@ -155,8 +155,8 @@ void TextBMFont::labelBMFontScaleChangedWithSize()
|
|||
_labelBMFontRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float scaleX = _size.width / textureSize.width;
|
||||
float scaleY = _size.height / textureSize.height;
|
||||
float scaleX = _contentSize.width / textureSize.width;
|
||||
float scaleY = _contentSize.height / textureSize.height;
|
||||
_labelBMFontRenderer->setScaleX(scaleX);
|
||||
_labelBMFontRenderer->setScaleY(scaleY);
|
||||
}
|
||||
|
|
|
@ -783,15 +783,15 @@ void TextField::textfieldRendererScaleChangedWithSize()
|
|||
}
|
||||
else
|
||||
{
|
||||
_textFieldRenderer->setDimensions(_size.width,_size.height);
|
||||
_textFieldRenderer->setDimensions(_contentSize.width, _contentSize.height);
|
||||
Size textureSize = getContentSize();
|
||||
if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
|
||||
{
|
||||
_textFieldRenderer->setScale(1.0f);
|
||||
return;
|
||||
}
|
||||
float scaleX = _size.width / textureSize.width;
|
||||
float scaleY = _size.height / textureSize.height;
|
||||
float scaleX = _contentSize.width / textureSize.width;
|
||||
float scaleY = _contentSize.height / textureSize.height;
|
||||
_textFieldRenderer->setScaleX(scaleX);
|
||||
_textFieldRenderer->setScaleY(scaleY);
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ bool VBox::initWithSize(const Size& size)
|
|||
{
|
||||
if (init())
|
||||
{
|
||||
setSize(size);
|
||||
setContentSize(size);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -145,7 +145,6 @@ _touchEndPosition(Vec2::ZERO),
|
|||
_touchEventListener(nullptr),
|
||||
_touchEventSelector(nullptr),
|
||||
_actionTag(0),
|
||||
_size(Size::ZERO),
|
||||
_customSize(Size::ZERO),
|
||||
_ignoreSize(false),
|
||||
_affectByClipping(false),
|
||||
|
@ -204,11 +203,10 @@ bool Widget::init()
|
|||
{
|
||||
initRenderer();
|
||||
setBright(true);
|
||||
//TODO: need refactor
|
||||
ignoreContentAdaptWithSize(true);
|
||||
onFocusChanged = CC_CALLBACK_2(Widget::onFocusChange,this);
|
||||
onNextFocusedWidget = nullptr;
|
||||
this->setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
ignoreContentAdaptWithSize(true);
|
||||
this->setTouchEnabled(true);
|
||||
this->setCascadeColorEnabled(true);
|
||||
this->setCascadeOpacityEnabled(true);
|
||||
|
@ -252,17 +250,19 @@ void Widget::setEnabled(bool enabled)
|
|||
void Widget::initRenderer()
|
||||
{
|
||||
}
|
||||
|
||||
void Widget::setSize(const Size &size)
|
||||
|
||||
void Widget::setContentSize(const cocos2d::Size &contentSize)
|
||||
{
|
||||
_customSize = size;
|
||||
ProtectedNode::setContentSize(contentSize);
|
||||
|
||||
_customSize = contentSize;
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_size = getVirtualRendererSize();
|
||||
_contentSize = getVirtualRendererSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
_size = size;
|
||||
_contentSize = contentSize;
|
||||
}
|
||||
if (_running)
|
||||
{
|
||||
|
@ -270,7 +270,7 @@ void Widget::setSize(const Size &size)
|
|||
Size pSize;
|
||||
if (widgetParent)
|
||||
{
|
||||
pSize = widgetParent->getSize();
|
||||
pSize = widgetParent->getContentSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -291,6 +291,11 @@ void Widget::setSize(const Size &size)
|
|||
onSizeChanged();
|
||||
}
|
||||
|
||||
void Widget::setSize(const Size &size)
|
||||
{
|
||||
this->setContentSize(size);
|
||||
}
|
||||
|
||||
void Widget::setSizePercent(const Vec2 &percent)
|
||||
{
|
||||
_sizePercent = percent;
|
||||
|
@ -300,7 +305,7 @@ void Widget::setSizePercent(const Vec2 &percent)
|
|||
Widget* widgetParent = getWidgetParent();
|
||||
if (widgetParent)
|
||||
{
|
||||
cSize = Size(widgetParent->getSize().width * percent.x , widgetParent->getSize().height * percent.y);
|
||||
cSize = Size(widgetParent->getContentSize().width * percent.x , widgetParent->getContentSize().height * percent.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -309,11 +314,11 @@ void Widget::setSizePercent(const Vec2 &percent)
|
|||
}
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_size = getVirtualRendererSize();
|
||||
this->setContentSize(getVirtualRendererSize());
|
||||
}
|
||||
else
|
||||
{
|
||||
_size = cSize;
|
||||
this->setContentSize(cSize);
|
||||
}
|
||||
_customSize = cSize;
|
||||
onSizeChanged();
|
||||
|
@ -321,16 +326,8 @@ void Widget::setSizePercent(const Vec2 &percent)
|
|||
|
||||
void Widget::updateSizeAndPosition()
|
||||
{
|
||||
Widget* widgetParent = getWidgetParent();
|
||||
Size pSize;
|
||||
if (widgetParent)
|
||||
{
|
||||
pSize = widgetParent->getLayoutSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
pSize = _parent->getContentSize();
|
||||
}
|
||||
Size pSize = _parent->getContentSize();
|
||||
|
||||
updateSizeAndPosition(pSize);
|
||||
}
|
||||
|
||||
|
@ -342,11 +339,11 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize)
|
|||
{
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_size = getVirtualRendererSize();
|
||||
this->setContentSize(getVirtualRendererSize());
|
||||
}
|
||||
else
|
||||
{
|
||||
_size = _customSize;
|
||||
this->setContentSize(_customSize);
|
||||
}
|
||||
float spx = 0.0f;
|
||||
float spy = 0.0f;
|
||||
|
@ -366,11 +363,11 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize)
|
|||
Size cSize = Size(parentSize.width * _sizePercent.x , parentSize.height * _sizePercent.y);
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_size = getVirtualRendererSize();
|
||||
this->setContentSize(getVirtualRendererSize());
|
||||
}
|
||||
else
|
||||
{
|
||||
_size = cSize;
|
||||
this->setContentSize(cSize);
|
||||
}
|
||||
_customSize = cSize;
|
||||
break;
|
||||
|
@ -425,11 +422,11 @@ void Widget::ignoreContentAdaptWithSize(bool ignore)
|
|||
if (_ignoreSize)
|
||||
{
|
||||
Size s = getVirtualRendererSize();
|
||||
_size = s;
|
||||
this->setContentSize(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
_size = _customSize;
|
||||
this->setContentSize(_customSize);
|
||||
}
|
||||
onSizeChanged();
|
||||
}
|
||||
|
@ -441,7 +438,7 @@ bool Widget::isIgnoreContentAdaptWithSize() const
|
|||
|
||||
const Size& Widget::getSize() const
|
||||
{
|
||||
return _size;
|
||||
return this->getContentSize();
|
||||
}
|
||||
|
||||
const Size& Widget::getCustomSize() const
|
||||
|
@ -466,7 +463,6 @@ Node* Widget::getVirtualRenderer()
|
|||
|
||||
void Widget::onSizeChanged()
|
||||
{
|
||||
setContentSize(_size);
|
||||
for (auto& child : getChildren())
|
||||
{
|
||||
Widget* widgetChild = dynamic_cast<Widget*>(child);
|
||||
|
@ -486,11 +482,11 @@ void Widget::updateContentSizeWithTextureSize(const cocos2d::Size &size)
|
|||
{
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_size = size;
|
||||
this->setContentSize(size);
|
||||
}
|
||||
else
|
||||
{
|
||||
_size = _customSize;
|
||||
this->setContentSize(_customSize);
|
||||
}
|
||||
onSizeChanged();
|
||||
}
|
||||
|
@ -856,7 +852,7 @@ void Widget::setPosition(const Vec2 &pos)
|
|||
Widget* widgetParent = getWidgetParent();
|
||||
if (widgetParent)
|
||||
{
|
||||
Size pSize = widgetParent->getSize();
|
||||
Size pSize = widgetParent->getContentSize();
|
||||
if (pSize.width <= 0.0f || pSize.height <= 0.0f)
|
||||
{
|
||||
_positionPercent = Vec2::ZERO;
|
||||
|
@ -878,7 +874,7 @@ void Widget::setPositionPercent(const Vec2 &percent)
|
|||
Widget* widgetParent = getWidgetParent();
|
||||
if (widgetParent)
|
||||
{
|
||||
Size parentSize = widgetParent->getSize();
|
||||
Size parentSize = widgetParent->getContentSize();
|
||||
Vec2 absPos = Vec2(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y);
|
||||
setPosition(absPos);
|
||||
}
|
||||
|
@ -911,22 +907,22 @@ bool Widget::isEnabled() const
|
|||
|
||||
float Widget::getLeftBoundary() const
|
||||
{
|
||||
return getPosition().x - getAnchorPoint().x * _size.width;
|
||||
return getPosition().x - getAnchorPoint().x * _contentSize.width;
|
||||
}
|
||||
|
||||
float Widget::getBottomBoundary() const
|
||||
{
|
||||
return getPosition().y - getAnchorPoint().y * _size.height;
|
||||
return getPosition().y - getAnchorPoint().y * _contentSize.height;
|
||||
}
|
||||
|
||||
float Widget::getRightBoundary() const
|
||||
{
|
||||
return getLeftBoundary() + _size.width;
|
||||
return getLeftBoundary() + _contentSize.width;
|
||||
}
|
||||
|
||||
float Widget::getTopBoundary() const
|
||||
{
|
||||
return getBottomBoundary() + _size.height;
|
||||
return getBottomBoundary() + _contentSize.height;
|
||||
}
|
||||
|
||||
const Vec2& Widget::getTouchBeganPosition()const
|
||||
|
@ -1012,7 +1008,7 @@ void Widget::copyProperties(Widget *widget)
|
|||
setName(widget->getName());
|
||||
setActionTag(widget->getActionTag());
|
||||
_ignoreSize = widget->_ignoreSize;
|
||||
_size = widget->_size;
|
||||
this->setContentSize(widget->_contentSize);
|
||||
_customSize = widget->_customSize;
|
||||
_sizeType = widget->getSizeType();
|
||||
_sizePercent = widget->_sizePercent;
|
||||
|
|
|
@ -371,7 +371,8 @@ public:
|
|||
*
|
||||
* @param size that is widget's size
|
||||
*/
|
||||
virtual void setSize(const Size &size);
|
||||
CC_DEPRECATED_ATTRIBUTE virtual void setSize(const Size &size);
|
||||
virtual void setContentSize(const Size& contentSize) override;
|
||||
|
||||
/**
|
||||
* Changes the percent that is widget's percent size
|
||||
|
@ -403,11 +404,11 @@ public:
|
|||
*
|
||||
* @return size
|
||||
*/
|
||||
const Size& getSize() const;
|
||||
CC_DEPRECATED_ATTRIBUTE const Size& getSize() const;
|
||||
|
||||
const Size& getCustomSize() const;
|
||||
|
||||
virtual const Size& getLayoutSize() {return _size;};
|
||||
virtual const Size& getLayoutSize() {return _contentSize;};
|
||||
|
||||
/**
|
||||
* Returns size percent of widget
|
||||
|
@ -658,7 +659,6 @@ protected:
|
|||
//use
|
||||
int _actionTag;
|
||||
|
||||
Size _size;
|
||||
Size _customSize;
|
||||
|
||||
Vec2 _sizePercent;
|
||||
|
|
|
@ -1329,7 +1329,7 @@ LabelShadowTest::LabelShadowTest()
|
|||
slider->loadBarTexture("cocosui/sliderTrack.png");
|
||||
slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
|
||||
slider->loadProgressBarTexture("cocosui/sliderProgress.png");
|
||||
slider->setPosition(Vec2(size.width / 2.0f, size.height * 0.15f + slider->getSize().height * 2.0f));
|
||||
slider->setPosition(Vec2(size.width / 2.0f, size.height * 0.15f + slider->getContentSize().height * 2.0f));
|
||||
slider->setPercent(52);
|
||||
slider->addEventListener(CC_CALLBACK_2(LabelShadowTest::sliderEvent, this));
|
||||
addChild(slider);
|
||||
|
@ -1795,7 +1795,7 @@ LabelLineHeightTest::LabelLineHeightTest()
|
|||
slider->loadBarTexture("cocosui/sliderTrack.png");
|
||||
slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
|
||||
slider->loadProgressBarTexture("cocosui/sliderProgress.png");
|
||||
slider->setPosition(Vec2(size.width / 2.0f, size.height * 0.15f + slider->getSize().height * 2.0f));
|
||||
slider->setPosition(Vec2(size.width / 2.0f, size.height * 0.15f + slider->getContentSize().height * 2.0f));
|
||||
slider->setPercent(label->getLineHeight());
|
||||
slider->addEventListener(CC_CALLBACK_2(LabelLineHeightTest::sliderEvent, this));
|
||||
addChild(slider);
|
||||
|
@ -1839,7 +1839,7 @@ LabelAdditionalKerningTest::LabelAdditionalKerningTest()
|
|||
slider->loadBarTexture("cocosui/sliderTrack.png");
|
||||
slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
|
||||
slider->loadProgressBarTexture("cocosui/sliderProgress.png");
|
||||
slider->setPosition(Vec2(size.width / 2.0f, size.height * 0.15f + slider->getSize().height * 2.0f));
|
||||
slider->setPosition(Vec2(size.width / 2.0f, size.height * 0.15f + slider->getContentSize().height * 2.0f));
|
||||
slider->setPercent(0);
|
||||
slider->addEventListener(CC_CALLBACK_2(LabelAdditionalKerningTest::sliderEvent, this));
|
||||
addChild(slider);
|
||||
|
|
|
@ -18,7 +18,7 @@ bool UIButtonTest::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add a label in which the button events will be displayed
|
||||
_displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf",32);
|
||||
|
@ -31,7 +31,7 @@ bool UIButtonTest::init()
|
|||
alert->setColor(Color3B(159, 168, 176));
|
||||
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
|
@ -90,7 +90,7 @@ bool UIButtonTest_Scale9::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add a label in which the button events will be displayed
|
||||
_displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32);
|
||||
|
@ -102,7 +102,7 @@ bool UIButtonTest_Scale9::init()
|
|||
Text* alert = Text::create("Button scale9 render", "fonts/Marker Felt.ttf",30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the button
|
||||
|
@ -110,7 +110,7 @@ bool UIButtonTest_Scale9::init()
|
|||
// open scale9 render
|
||||
button->setScale9Enabled(true);
|
||||
button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||
button->setSize(Size(150, 70));
|
||||
button->setContentSize(Size(150, 70));
|
||||
// button->addTouchEventListener(this, toucheventselector(UIButtonTest_Scale9::touchEvent));
|
||||
button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Scale9::touchEvent, this));
|
||||
_uiLayer->addChild(button);
|
||||
|
@ -159,7 +159,7 @@ bool UIButtonTest_PressedAction::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add a label in which the button events will be displayed
|
||||
_displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf",32);
|
||||
|
@ -172,7 +172,7 @@ bool UIButtonTest_PressedAction::init()
|
|||
alert->setColor(Color3B(159, 168, 176));
|
||||
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
|
@ -229,7 +229,7 @@ bool UIButtonTest_Title::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add a label in which the text button events will be displayed
|
||||
_displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32);
|
||||
|
@ -241,7 +241,7 @@ bool UIButtonTest_Title::init()
|
|||
Text* alert = Text::create("Button with title", "fonts/Marker Felt.ttf", 30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ bool UIButtonTest_Editor::init()
|
|||
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -53,8 +53,8 @@ bool UIButtonTest_Editor::init()
|
|||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
||||
_displayValueLabel->setFontSize(30);
|
||||
_displayValueLabel->setString("No event");
|
||||
_displayValueLabel->setPosition(Vec2(_layout->getSize().width / 2,
|
||||
_layout->getSize().height - _displayValueLabel->getSize().height * 1.75f));
|
||||
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
||||
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
||||
_touchGroup->addChild(_displayValueLabel);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -18,7 +18,7 @@ bool UICheckBoxTest::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();;
|
||||
Size widgetSize = _widget->getContentSize();;
|
||||
|
||||
// Add a label in which the checkbox events will be displayed
|
||||
_displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32);
|
||||
|
@ -29,7 +29,7 @@ bool UICheckBoxTest::init()
|
|||
// Add the alert
|
||||
Text* alert = Text::create("CheckBox","fonts/Marker Felt.ttf",30 );
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the checkbox
|
||||
|
|
|
@ -24,7 +24,7 @@ bool UICheckBoxTest_Editor::init()
|
|||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UICheckBox_Editor/ui_checkbox_editor_2.json"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -42,8 +42,8 @@ bool UICheckBoxTest_Editor::init()
|
|||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
||||
_displayValueLabel->setFontSize(30);
|
||||
_displayValueLabel->setString("No event");
|
||||
_displayValueLabel->setPosition(Vec2(_layout->getSize().width / 2,
|
||||
_layout->getSize().height - _displayValueLabel->getSize().height * 1.75f));
|
||||
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
||||
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
||||
_touchGroup->addChild(_displayValueLabel);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -598,7 +598,7 @@ bool UIFocusTestListView::init()
|
|||
_listView->setBounceEnabled(true);
|
||||
_listView->setBackGroundImage("cocosui/green_edit.png");
|
||||
_listView->setBackGroundImageScale9Enabled(true);
|
||||
_listView->setSize(Size(240, 130));
|
||||
_listView->setContentSize(Size(240, 130));
|
||||
|
||||
_listView->setPosition(Vec2(40, 70));
|
||||
_uiLayer->addChild(_listView);
|
||||
|
|
|
@ -9,12 +9,12 @@ bool UIImageViewTest::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
Text* alert = Text::create("ImageView", "fonts/Marker Felt.ttf", 30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
|
@ -39,19 +39,19 @@ bool UIImageViewTest_Scale9::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
Text* alert = Text::create("ImageView scale9 render", "fonts/Marker Felt.ttf", 26);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f - alert->getSize().height * 2.125f));
|
||||
widgetSize.height / 2.0f - alert->getContentSize().height * 2.125f));
|
||||
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the imageview
|
||||
ImageView* imageView = ImageView::create("cocosui/buttonHighlighted.png");
|
||||
imageView->setScale9Enabled(true);
|
||||
imageView->setSize(Size(300, 115));
|
||||
imageView->setContentSize(Size(300, 115));
|
||||
imageView->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f));
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ bool UIImageViewTest_Editor::init()
|
|||
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ bool UILayoutTest::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("Layout", "fonts/Marker Felt.ttf", 30 );
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||
widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
|
||||
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
|
@ -33,29 +33,29 @@ bool UILayoutTest::init()
|
|||
|
||||
// Create the layout
|
||||
Layout* layout = Layout::create();
|
||||
layout->setSize(Size(280, 150));
|
||||
Size backgroundSize = background->getSize();
|
||||
layout->setContentSize(Size(280, 150));
|
||||
Size backgroundSize = background->getContentSize();
|
||||
layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - layout->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - layout->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - layout->getContentSize().height) / 2.0f));
|
||||
_uiLayer->addChild(layout);
|
||||
|
||||
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||
button->setPosition(Vec2(button->getSize().width / 2.0f,
|
||||
layout->getSize().height - button->getSize().height / 2.0f));
|
||||
button->setPosition(Vec2(button->getContentSize().width / 2.0f,
|
||||
layout->getContentSize().height - button->getContentSize().height / 2.0f));
|
||||
layout->addChild(button);
|
||||
|
||||
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||
titleButton->setTitleText("Title Button");
|
||||
titleButton->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
||||
titleButton->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
|
||||
layout->addChild(titleButton);
|
||||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||
button_scale9->getSize().height / 2.0f));
|
||||
button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(layout->getContentSize().width - button_scale9->getContentSize().width / 2.0f,
|
||||
button_scale9->getContentSize().height / 2.0f));
|
||||
|
||||
layout->addChild(button_scale9);
|
||||
|
||||
|
@ -79,13 +79,13 @@ bool UILayoutTest_Color::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("Layout color render", "fonts/Marker Felt.ttf", 30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||
widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
|
||||
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
|
@ -97,30 +97,30 @@ bool UILayoutTest_Color::init()
|
|||
Layout* layout = Layout::create();
|
||||
layout->setBackGroundColorType(Layout::BackGroundColorType::SOLID);
|
||||
layout->setBackGroundColor(Color3B(128, 128, 128));
|
||||
layout->setSize(Size(280, 150));
|
||||
layout->setContentSize(Size(280, 150));
|
||||
Size backgroundSize = background->getContentSize();
|
||||
layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - layout->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - layout->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - layout->getContentSize().height) / 2.0f));
|
||||
_uiLayer->addChild(layout);
|
||||
|
||||
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||
button->setPosition(Vec2(button->getSize().width / 2.0f,
|
||||
layout->getSize().height - button->getSize().height / 2.0f));
|
||||
button->setPosition(Vec2(button->getContentSize().width / 2.0f,
|
||||
layout->getContentSize().height - button->getContentSize().height / 2.0f));
|
||||
|
||||
layout->addChild(button);
|
||||
|
||||
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||
titleButton->setTitleText("Title Button");
|
||||
titleButton->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
||||
titleButton->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
|
||||
layout->addChild(titleButton);
|
||||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||
button_scale9->getSize().height / 2.0f));
|
||||
button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(layout->getContentSize().width - button_scale9->getContentSize().width / 2.0f,
|
||||
button_scale9->getContentSize().height / 2.0f));
|
||||
|
||||
layout->addChild(button_scale9);
|
||||
|
||||
|
@ -143,13 +143,13 @@ bool UILayoutTest_Gradient::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("Layout gradient render", "fonts/Marker Felt.ttf", 30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||
widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
|
||||
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
|
@ -161,30 +161,30 @@ bool UILayoutTest_Gradient::init()
|
|||
Layout* layout = Layout::create();
|
||||
layout->setBackGroundColorType(Layout::BackGroundColorType::GRADIENT);
|
||||
layout->setBackGroundColor(Color3B(64, 64, 64), Color3B(192, 192, 192));
|
||||
layout->setSize(Size(280, 150));
|
||||
layout->setContentSize(Size(280, 150));
|
||||
Size backgroundSize = background->getContentSize();
|
||||
layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - layout->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - layout->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - layout->getContentSize().height) / 2.0f));
|
||||
_uiLayer->addChild(layout);
|
||||
|
||||
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||
button->setPosition(Vec2(button->getSize().width / 2.0f,
|
||||
layout->getSize().height - button->getSize().height / 2.0f));
|
||||
button->setPosition(Vec2(button->getContentSize().width / 2.0f,
|
||||
layout->getContentSize().height - button->getContentSize().height / 2.0f));
|
||||
|
||||
layout->addChild(button);
|
||||
|
||||
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||
titleButton->setTitleText("Title Button");
|
||||
titleButton->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
||||
titleButton->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
|
||||
layout->addChild(titleButton);
|
||||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||
button_scale9->getSize().height / 2.0f));
|
||||
button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(layout->getContentSize().width - button_scale9->getContentSize().width / 2.0f,
|
||||
button_scale9->getContentSize().height / 2.0f));
|
||||
|
||||
layout->addChild(button_scale9);
|
||||
|
||||
|
@ -207,12 +207,12 @@ bool UILayoutTest_BackGroundImage::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("Layout background image", "fonts/Marker Felt.ttf", 20);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 4.5f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||
|
@ -223,29 +223,29 @@ bool UILayoutTest_BackGroundImage::init()
|
|||
Layout* layout = Layout::create();
|
||||
layout->setClippingEnabled(true);
|
||||
layout->setBackGroundImage("cocosui/Hello.png");
|
||||
layout->setSize(Size(280, 150));
|
||||
layout->setContentSize(Size(280, 150));
|
||||
Size backgroundSize = background->getContentSize();
|
||||
layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - layout->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - layout->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - layout->getContentSize().height) / 2.0f));
|
||||
_uiLayer->addChild(layout);
|
||||
|
||||
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||
button->setPosition(Vec2(button->getSize().width / 2.0f,
|
||||
layout->getSize().height - button->getSize().height / 2.0f));
|
||||
button->setPosition(Vec2(button->getContentSize().width / 2.0f,
|
||||
layout->getContentSize().height - button->getContentSize().height / 2.0f));
|
||||
layout->addChild(button);
|
||||
|
||||
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||
titleButton->setTitleText("Title Button");
|
||||
titleButton->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
||||
titleButton->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
|
||||
layout->addChild(titleButton);
|
||||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||
button_scale9->getSize().height / 2.0f));
|
||||
button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(layout->getContentSize().width - button_scale9->getContentSize().width / 2.0f,
|
||||
button_scale9->getContentSize().height / 2.0f));
|
||||
|
||||
layout->addChild(button_scale9);
|
||||
|
||||
|
@ -268,12 +268,12 @@ bool UILayoutTest_BackGroundImage_Scale9::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("Layout background image scale9", "fonts/Marker Felt.ttf", 20);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 4.5f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||
|
@ -284,30 +284,30 @@ bool UILayoutTest_BackGroundImage_Scale9::init()
|
|||
Layout* layout = Layout::create();
|
||||
layout->setBackGroundImageScale9Enabled(true);
|
||||
layout->setBackGroundImage("cocosui/green_edit.png");
|
||||
layout->setSize(Size(280, 150));
|
||||
layout->setContentSize(Size(280, 150));
|
||||
Size backgroundSize = background->getContentSize();
|
||||
layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - layout->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - layout->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - layout->getContentSize().height) / 2.0f));
|
||||
_uiLayer->addChild(layout);
|
||||
|
||||
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||
button->setPosition(Vec2(button->getSize().width / 2.0f,
|
||||
layout->getSize().height - button->getSize().height / 2.0f));
|
||||
button->setPosition(Vec2(button->getContentSize().width / 2.0f,
|
||||
layout->getContentSize().height - button->getContentSize().height / 2.0f));
|
||||
|
||||
layout->addChild(button);
|
||||
|
||||
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||
titleButton->setTitleText("Title Button");
|
||||
titleButton->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
||||
titleButton->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
|
||||
layout->addChild(titleButton);
|
||||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||
button_scale9->getSize().height / 2.0f));
|
||||
button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(layout->getContentSize().width - button_scale9->getContentSize().width / 2.0f,
|
||||
button_scale9->getContentSize().height / 2.0f));
|
||||
layout->addChild(button_scale9);
|
||||
|
||||
return true;
|
||||
|
@ -329,13 +329,13 @@ bool UILayoutTest_Layout_Linear_Vertical::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("Layout Linear Vertical", "fonts/Marker Felt.ttf", 20);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
||||
widgetSize.height / 2.0f - alert->getContentSize().height * 4.5f));
|
||||
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
|
@ -346,12 +346,12 @@ bool UILayoutTest_Layout_Linear_Vertical::init()
|
|||
// Create the layout
|
||||
Layout* layout = Layout::create();
|
||||
layout->setLayoutType(LayoutType::VERTICAL);
|
||||
layout->setSize(Size(280, 150));
|
||||
Size backgroundSize = background->getSize();
|
||||
layout->setContentSize(Size(280, 150));
|
||||
Size backgroundSize = background->getContentSize();
|
||||
layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - layout->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - layout->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - layout->getContentSize().height) / 2.0f));
|
||||
_uiLayer->addChild(layout);
|
||||
|
||||
|
||||
|
@ -376,7 +376,7 @@ bool UILayoutTest_Layout_Linear_Vertical::init()
|
|||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
layout->addChild(button_scale9);
|
||||
|
||||
LinearLayoutParameter* lp3 = LinearLayoutParameter::create();
|
||||
|
@ -405,12 +405,12 @@ bool UILayoutTest_Layout_Linear_Horizontal::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("Layout Linear Horizontal", "fonts/Marker Felt.ttf", 20);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 4.5f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||
|
@ -421,12 +421,12 @@ bool UILayoutTest_Layout_Linear_Horizontal::init()
|
|||
Layout* layout = Layout::create();
|
||||
layout->setLayoutType(LayoutType::HORIZONTAL);
|
||||
layout->setClippingEnabled(true);
|
||||
layout->setSize(Size(280, 150));
|
||||
Size backgroundSize = background->getSize();
|
||||
layout->setContentSize(Size(280, 150));
|
||||
Size backgroundSize = background->getContentSize();
|
||||
layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - layout->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - layout->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - layout->getContentSize().height) / 2.0f));
|
||||
_uiLayer->addChild(layout);
|
||||
|
||||
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||
|
@ -450,7 +450,7 @@ bool UILayoutTest_Layout_Linear_Horizontal::init()
|
|||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
layout->addChild(button_scale9);
|
||||
|
||||
LinearLayoutParameter* lp3 = LinearLayoutParameter::create();
|
||||
|
@ -479,12 +479,12 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("Layout Relative Align Parent", "fonts/Marker Felt.ttf", 20);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 4.5f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||
|
@ -494,14 +494,14 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init()
|
|||
// Create the layout
|
||||
Layout* layout = Layout::create();
|
||||
layout->setLayoutType(LayoutType::RELATIVE);
|
||||
layout->setSize(Size(280, 150));
|
||||
layout->setContentSize(Size(280, 150));
|
||||
layout->setBackGroundColorType(Layout::BackGroundColorType::SOLID);
|
||||
layout->setBackGroundColor(Color3B::GREEN);
|
||||
Size backgroundSize = background->getSize();
|
||||
Size backgroundSize = background->getContentSize();
|
||||
layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - layout->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - layout->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - layout->getContentSize().height) / 2.0f));
|
||||
_uiLayer->addChild(layout);
|
||||
|
||||
// top left
|
||||
|
@ -614,12 +614,12 @@ bool UILayoutTest_Layout_Relative_Location::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("Layout Relative Location", "fonts/Marker Felt.ttf", 20);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 4.5f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||
|
@ -629,12 +629,12 @@ bool UILayoutTest_Layout_Relative_Location::init()
|
|||
// Create the layout
|
||||
Layout* layout = Layout::create();
|
||||
layout->setLayoutType(LayoutType::RELATIVE);
|
||||
layout->setSize(Size(280, 150));
|
||||
Size backgroundSize = background->getSize();
|
||||
layout->setContentSize(Size(280, 150));
|
||||
Size backgroundSize = background->getContentSize();
|
||||
layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - layout->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - layout->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - layout->getContentSize().height) / 2.0f));
|
||||
_uiLayer->addChild(layout);
|
||||
|
||||
// center
|
||||
|
|
|
@ -23,7 +23,7 @@ bool UILayoutTest_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/ui_layout_editor_1.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -36,8 +36,8 @@ bool UILayoutTest_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
|
@ -45,8 +45,8 @@ bool UILayoutTest_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||
|
@ -79,7 +79,7 @@ bool UILayoutTest_Color_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/ui_layout_color_editor_1.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -92,8 +92,8 @@ bool UILayoutTest_Color_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
|
@ -101,8 +101,8 @@ bool UILayoutTest_Color_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||
|
@ -135,7 +135,7 @@ bool UILayoutTest_Gradient_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/ui_layout_gradient_color_editor_1_0.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -148,8 +148,8 @@ bool UILayoutTest_Gradient_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
|
@ -157,8 +157,8 @@ bool UILayoutTest_Gradient_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||
|
@ -191,7 +191,7 @@ bool UILayoutTest_BackGroundImage_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/ui_layout_backgroundimage_editor_1_0_0.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -204,8 +204,8 @@ bool UILayoutTest_BackGroundImage_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height * 0.625));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
|
@ -213,8 +213,8 @@ bool UILayoutTest_BackGroundImage_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||
|
@ -247,7 +247,7 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/ui_layout_scale9_backgroundimage_editor.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -260,8 +260,8 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
|
@ -269,8 +269,8 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||
|
@ -303,7 +303,7 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/ui_layout_linear_vertical_layout_editor.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -316,8 +316,8 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height * 0.625));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
|
@ -325,8 +325,8 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||
|
@ -359,7 +359,7 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/ui_layout_linear_horizontal_layout_editor.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -372,8 +372,8 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height * 0.625));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
|
@ -381,8 +381,8 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||
|
@ -416,7 +416,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/ui_layout_relative_align_parent_editor.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -429,8 +429,8 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height * 0.625));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
|
@ -438,8 +438,8 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||
|
@ -472,7 +472,7 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/ui_layout_relative_align_location_editor.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -485,8 +485,8 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height * 0.625));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
|
@ -494,8 +494,8 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||
|
|
|
@ -22,7 +22,7 @@ bool UIListViewTest_Vertical::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
_displayValueLabel = Text::create("Move by vertical direction", "fonts/Marker Felt.ttf", 32);
|
||||
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
|
||||
|
@ -34,7 +34,7 @@ bool UIListViewTest_Vertical::init()
|
|||
Text* alert = Text::create("ListView vertical", "fonts/Marker Felt.ttf", 30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||
widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||
|
@ -62,9 +62,9 @@ bool UIListViewTest_Vertical::init()
|
|||
listView->setBackGroundImageScale9Enabled(true);
|
||||
listView->setSize(Size(240, 130));
|
||||
listView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - listView->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - listView->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - listView->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - listView->getContentSize().height) / 2.0f));
|
||||
listView->addEventListener((ui::ListView::ccListViewCallback)CC_CALLBACK_2(UIListViewTest_Vertical::selectedItemEvent, this));
|
||||
listView->addEventListener((ui::ListView::ccScrollViewCallback)CC_CALLBACK_2(UIListViewTest_Vertical::selectedItemEventScrollView,this));
|
||||
|
||||
|
@ -77,9 +77,9 @@ bool UIListViewTest_Vertical::init()
|
|||
|
||||
Layout* default_item = Layout::create();
|
||||
default_item->setTouchEnabled(true);
|
||||
default_item->setSize(default_button->getSize());
|
||||
default_button->setPosition(Vec2(default_item->getSize().width / 2.0f,
|
||||
default_item->getSize().height / 2.0f));
|
||||
default_item->setSize(default_button->getContentSize());
|
||||
default_button->setPosition(Vec2(default_item->getContentSize().width / 2.0f,
|
||||
default_item->getContentSize().height / 2.0f));
|
||||
default_item->addChild(default_button);
|
||||
|
||||
// set model
|
||||
|
@ -109,11 +109,11 @@ bool UIListViewTest_Vertical::init()
|
|||
Button* custom_button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
custom_button->setName("Title Button");
|
||||
custom_button->setScale9Enabled(true);
|
||||
custom_button->setSize(default_button->getSize());
|
||||
custom_button->setSize(default_button->getContentSize());
|
||||
|
||||
Layout *custom_item = Layout::create();
|
||||
custom_item->setSize(custom_button->getSize());
|
||||
custom_button->setPosition(Vec2(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f));
|
||||
custom_item->setSize(custom_button->getContentSize());
|
||||
custom_button->setPosition(Vec2(custom_item->getContentSize().width / 2.0f, custom_item->getContentSize().height / 2.0f));
|
||||
custom_item->addChild(custom_button);
|
||||
|
||||
listView->addChild(custom_item);
|
||||
|
@ -126,11 +126,11 @@ bool UIListViewTest_Vertical::init()
|
|||
Button* custom_button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
custom_button->setName("Title Button");
|
||||
custom_button->setScale9Enabled(true);
|
||||
custom_button->setSize(default_button->getSize());
|
||||
custom_button->setSize(default_button->getContentSize());
|
||||
|
||||
Layout *custom_item = Layout::create();
|
||||
custom_item->setSize(custom_button->getSize());
|
||||
custom_button->setPosition(Vec2(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f));
|
||||
custom_item->setSize(custom_button->getContentSize());
|
||||
custom_button->setPosition(Vec2(custom_item->getContentSize().width / 2.0f, custom_item->getContentSize().height / 2.0f));
|
||||
custom_item->addChild(custom_button);
|
||||
custom_item->setTag(1);
|
||||
|
||||
|
@ -221,7 +221,7 @@ bool UIListViewTest_Horizontal::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
_displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32);
|
||||
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
|
||||
|
@ -234,7 +234,7 @@ bool UIListViewTest_Horizontal::init()
|
|||
|
||||
Text* alert = Text::create("ListView horizontal", "fonts/Marker Felt.ttf", 30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||
|
@ -263,9 +263,9 @@ bool UIListViewTest_Horizontal::init()
|
|||
listView->setBackGroundImageScale9Enabled(true);
|
||||
listView->setSize(Size(240, 130));
|
||||
listView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - listView->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - listView->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - listView->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - listView->getContentSize().height) / 2.0f));
|
||||
listView->addEventListener((ui::ListView::ccListViewCallback)CC_CALLBACK_2(UIListViewTest_Horizontal::selectedItemEvent, this));
|
||||
_uiLayer->addChild(listView);
|
||||
|
||||
|
@ -276,8 +276,8 @@ bool UIListViewTest_Horizontal::init()
|
|||
|
||||
Layout *default_item = Layout::create();
|
||||
default_item->setTouchEnabled(true);
|
||||
default_item->setSize(default_button->getSize());
|
||||
default_button->setPosition(Vec2(default_item->getSize().width / 2.0f, default_item->getSize().height / 2.0f));
|
||||
default_item->setSize(default_button->getContentSize());
|
||||
default_button->setPosition(Vec2(default_item->getContentSize().width / 2.0f, default_item->getContentSize().height / 2.0f));
|
||||
default_item->addChild(default_button);
|
||||
|
||||
// set model
|
||||
|
@ -301,11 +301,11 @@ bool UIListViewTest_Horizontal::init()
|
|||
Button* custom_button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
custom_button->setName("Title Button");
|
||||
custom_button->setScale9Enabled(true);
|
||||
custom_button->setSize(default_button->getSize());
|
||||
custom_button->setSize(default_button->getContentSize());
|
||||
|
||||
Layout* custom_item = Layout::create();
|
||||
custom_item->setSize(custom_button->getSize());
|
||||
custom_button->setPosition(Vec2(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f));
|
||||
custom_item->setSize(custom_button->getContentSize());
|
||||
custom_button->setPosition(Vec2(custom_item->getContentSize().width / 2.0f, custom_item->getContentSize().height / 2.0f));
|
||||
custom_item->addChild(custom_button);
|
||||
|
||||
listView->pushBackCustomItem(custom_item);
|
||||
|
@ -318,11 +318,11 @@ bool UIListViewTest_Horizontal::init()
|
|||
Button* custom_button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
custom_button->setName("Title Button");
|
||||
custom_button->setScale9Enabled(true);
|
||||
custom_button->setSize(default_button->getSize());
|
||||
custom_button->setSize(default_button->getContentSize());
|
||||
|
||||
Layout* custom_item = Layout::create();
|
||||
custom_item->setSize(custom_button->getSize());
|
||||
custom_button->setPosition(Vec2(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f));
|
||||
custom_item->setSize(custom_button->getContentSize());
|
||||
custom_button->setPosition(Vec2(custom_item->getContentSize().width / 2.0f, custom_item->getContentSize().height / 2.0f));
|
||||
custom_item->addChild(custom_button);
|
||||
|
||||
listView->insertCustomItem(custom_item, items_count);
|
||||
|
|
|
@ -23,7 +23,7 @@ bool UIListViewTest_Vertical_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/ui_listview_editor_1.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -39,8 +39,8 @@ bool UIListViewTest_Vertical_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height * 0.625));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback,this));
|
||||
|
||||
|
@ -50,8 +50,8 @@ bool UIListViewTest_Vertical_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback,this));
|
||||
|
@ -85,7 +85,7 @@ bool UIListViewTest_Horizontal_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/ui_listview_horizontal_editor_1.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -98,8 +98,8 @@ bool UIListViewTest_Horizontal_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height * 0.625));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback,this));
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
|
@ -107,8 +107,8 @@ bool UIListViewTest_Horizontal_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||
|
|
|
@ -22,19 +22,19 @@ bool UILoadingBarTest_Left::init()
|
|||
{
|
||||
scheduleUpdate();
|
||||
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("LoadingBar left", "fonts/Marker Felt.ttf", 30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the loading bar
|
||||
LoadingBar* loadingBar = LoadingBar::create("cocosui/sliderProgress.png");
|
||||
loadingBar->setTag(0);
|
||||
loadingBar->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
|
||||
widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f));
|
||||
|
||||
_uiLayer->addChild(loadingBar);
|
||||
|
||||
|
@ -100,12 +100,12 @@ bool UILoadingBarTest_Right::init()
|
|||
{
|
||||
scheduleUpdate();
|
||||
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text *alert = Text::create("LoadingBar right", "fonts/Marker Felt.ttf", 30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the loading bar
|
||||
|
@ -114,7 +114,7 @@ bool UILoadingBarTest_Right::init()
|
|||
loadingBar->setDirection(LoadingBar::Direction::RIGHT);
|
||||
|
||||
loadingBar->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
|
||||
widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f));
|
||||
|
||||
_uiLayer->addChild(loadingBar);
|
||||
|
||||
|
@ -180,12 +180,12 @@ bool UILoadingBarTest_Left_Scale9::init()
|
|||
{
|
||||
scheduleUpdate();
|
||||
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("LoadingBar left scale9 render", "fonts/Marker Felt.ttf", 20);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 2.7f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the loading bar
|
||||
|
@ -193,10 +193,10 @@ bool UILoadingBarTest_Left_Scale9::init()
|
|||
loadingBar->setTag(0);
|
||||
loadingBar->setScale9Enabled(true);
|
||||
loadingBar->setCapInsets(Rect(0, 0, 0, 0));
|
||||
loadingBar->setSize(Size(300, 13));
|
||||
loadingBar->setContentSize(Size(300, 13));
|
||||
|
||||
loadingBar->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
|
||||
widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f));
|
||||
|
||||
_uiLayer->addChild(loadingBar);
|
||||
|
||||
|
@ -262,12 +262,12 @@ bool UILoadingBarTest_Right_Scale9::init()
|
|||
{
|
||||
scheduleUpdate();
|
||||
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text *alert = Text::create("LoadingBar right scale9 render", "fonts/Marker Felt.ttf", 20);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 2.7f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the loading bar
|
||||
|
@ -275,11 +275,11 @@ bool UILoadingBarTest_Right_Scale9::init()
|
|||
loadingBar->setTag(0);
|
||||
loadingBar->setScale9Enabled(true);
|
||||
loadingBar->setCapInsets(Rect(0, 0, 0, 0));
|
||||
loadingBar->setSize(Size(300, 13));
|
||||
loadingBar->setContentSize(Size(300, 13));
|
||||
loadingBar->setDirection(LoadingBar::Direction::RIGHT);
|
||||
|
||||
loadingBar->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
|
||||
widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f));
|
||||
|
||||
_uiLayer->addChild(loadingBar);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ bool UILoadingBarTest_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILoadingBar_Editor/ui_loadingbar_editor_1.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ bool UIPageViewTest::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add a label in which the dragpanel events will be displayed
|
||||
_displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32);
|
||||
|
@ -31,7 +31,7 @@ bool UIPageViewTest::init()
|
|||
// Add the black background
|
||||
Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||
|
@ -40,12 +40,12 @@ bool UIPageViewTest::init()
|
|||
|
||||
// Create the page view
|
||||
PageView* pageView = PageView::create();
|
||||
pageView->setSize(Size(240.0f, 130.0f));
|
||||
pageView->setContentSize(Size(240.0f, 130.0f));
|
||||
Size backgroundSize = background->getContentSize();
|
||||
pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - pageView->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - pageView->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - pageView->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - pageView->getContentSize().height) / 2.0f));
|
||||
|
||||
pageView->removeAllPages();
|
||||
|
||||
|
@ -53,17 +53,17 @@ bool UIPageViewTest::init()
|
|||
for (int i = 0; i < pageCount; ++i)
|
||||
{
|
||||
Layout* layout = Layout::create();
|
||||
layout->setSize(Size(240.0f, 130.0f));
|
||||
layout->setContentSize(Size(240.0f, 130.0f));
|
||||
|
||||
ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png");
|
||||
imageView->setScale9Enabled(true);
|
||||
imageView->setSize(Size(240, 130));
|
||||
imageView->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
||||
imageView->setContentSize(Size(240, 130));
|
||||
imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
|
||||
layout->addChild(imageView);
|
||||
|
||||
Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30);
|
||||
label->setColor(Color3B(192, 192, 192));
|
||||
label->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
||||
label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
|
||||
layout->addChild(label);
|
||||
|
||||
pageView->insertPage(layout,i);
|
||||
|
|
|
@ -24,7 +24,7 @@ bool UIPageViewTest_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIPageView_Editor/ui_pageview_editor_1.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -37,8 +37,8 @@ bool UIPageViewTest_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height * 0.625));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
|
@ -46,8 +46,8 @@ bool UIPageViewTest_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||
|
|
|
@ -18,19 +18,19 @@ bool UIRichTextTest::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text *alert = Text::create("RichText", "fonts/Marker Felt.ttf", 30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.125));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.125));
|
||||
_widget->addChild(alert);
|
||||
|
||||
|
||||
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||
button->setTouchEnabled(true);
|
||||
button->setTitleText("switch");
|
||||
button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + button->getSize().height * 2.5));
|
||||
button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + button->getContentSize().height * 2.5));
|
||||
// button->addTouchEventListener(this, toucheventselector(UIRichTextTest::touchEvent));
|
||||
button->addTouchEventListener(CC_CALLBACK_2(UIRichTextTest::touchEvent, this));
|
||||
button->setLocalZOrder(10);
|
||||
|
@ -40,7 +40,7 @@ bool UIRichTextTest::init()
|
|||
// RichText
|
||||
_richText = RichText::create();
|
||||
_richText->ignoreContentAdaptWithSize(false);
|
||||
_richText->setSize(Size(100, 100));
|
||||
_richText->setContentSize(Size(100, 100));
|
||||
|
||||
RichElementText* re1 = RichElementText::create(1, Color3B::WHITE, 255, "This color is white. ", "Helvetica", 10);
|
||||
RichElementText* re2 = RichElementText::create(2, Color3B::YELLOW, 255, "And this is yellow. ", "Helvetica", 10);
|
||||
|
@ -85,7 +85,7 @@ void UIRichTextTest::touchEvent(Ref *pSender, Widget::TouchEventType type)
|
|||
if (_richText->isIgnoreContentAdaptWithSize())
|
||||
{
|
||||
_richText->ignoreContentAdaptWithSize(false);
|
||||
_richText->setSize(Size(100, 100));
|
||||
_richText->setContentSize(Size(100, 100));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ bool UIScene::init()
|
|||
_uiLayer->addChild(_widget);
|
||||
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _widget->getSize();
|
||||
Size rootSize = _widget->getContentSize();
|
||||
_uiLayer->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ bool UIScrollViewTest_Vertical::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add a label in which the scrollview alert will be displayed
|
||||
_displayValueLabel = Text::create("Move by vertical direction", "fonts/Marker Felt.ttf", 32);
|
||||
|
@ -30,7 +30,7 @@ bool UIScrollViewTest_Vertical::init()
|
|||
// Add the alert
|
||||
Text* alert = Text::create("ScrollView vertical", "fonts/Marker Felt.ttf", 30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||
|
@ -39,37 +39,37 @@ bool UIScrollViewTest_Vertical::init()
|
|||
|
||||
// Create the scrollview by vertical
|
||||
ui::ScrollView* scrollView = ui::ScrollView::create();
|
||||
scrollView->setSize(Size(280.0f, 150.0f));
|
||||
scrollView->setContentSize(Size(280.0f, 150.0f));
|
||||
Size backgroundSize = background->getContentSize();
|
||||
scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - scrollView->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - scrollView->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - scrollView->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - scrollView->getContentSize().height) / 2.0f));
|
||||
_uiLayer->addChild(scrollView);
|
||||
|
||||
ImageView* imageView = ImageView::create("cocosui/ccicon.png");
|
||||
|
||||
float innerWidth = scrollView->getSize().width;
|
||||
float innerHeight = scrollView->getSize().height + imageView->getSize().height;
|
||||
float innerWidth = scrollView->getContentSize().width;
|
||||
float innerHeight = scrollView->getContentSize().height + imageView->getContentSize().height;
|
||||
|
||||
scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));
|
||||
|
||||
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||
button->setPosition(Vec2(innerWidth / 2.0f, scrollView->getInnerContainerSize().height - button->getSize().height / 2.0f));
|
||||
button->setPosition(Vec2(innerWidth / 2.0f, scrollView->getInnerContainerSize().height - button->getContentSize().height / 2.0f));
|
||||
scrollView->addChild(button);
|
||||
|
||||
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||
titleButton->setTitleText("Title Button");
|
||||
titleButton->setPosition(Vec2(innerWidth / 2.0f, button->getBottomBoundary() - button->getSize().height));
|
||||
titleButton->setPosition(Vec2(innerWidth / 2.0f, button->getBottomBoundary() - button->getContentSize().height));
|
||||
scrollView->addChild(titleButton);
|
||||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(innerWidth / 2.0f, titleButton->getBottomBoundary() - titleButton->getSize().height));
|
||||
button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(innerWidth / 2.0f, titleButton->getBottomBoundary() - titleButton->getContentSize().height));
|
||||
scrollView->addChild(button_scale9);
|
||||
|
||||
imageView->setPosition(Vec2(innerWidth / 2.0f, imageView->getSize().height / 2.0f));
|
||||
imageView->setPosition(Vec2(innerWidth / 2.0f, imageView->getContentSize().height / 2.0f));
|
||||
scrollView->addChild(imageView);
|
||||
|
||||
return true;
|
||||
|
@ -93,7 +93,7 @@ bool UIScrollViewTest_Horizontal::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add a label in which the scrollview alert will be displayed
|
||||
_displayValueLabel = Text::create("Move by horizontal direction","fonts/Marker Felt.ttf",32);
|
||||
|
@ -103,7 +103,7 @@ bool UIScrollViewTest_Horizontal::init()
|
|||
|
||||
Text* alert = Text::create("ScrollView horizontal","fonts/Marker Felt.ttf",30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||
|
@ -114,42 +114,42 @@ bool UIScrollViewTest_Horizontal::init()
|
|||
ui::ScrollView* scrollView = ui::ScrollView::create();
|
||||
scrollView->setBounceEnabled(true);
|
||||
scrollView->setDirection(ui::ScrollView::Direction::HORIZONTAL);
|
||||
scrollView->setSize(Size(280.0f, 150.0f));
|
||||
scrollView->setInnerContainerSize(scrollView->getSize());
|
||||
scrollView->setContentSize(Size(280.0f, 150.0f));
|
||||
scrollView->setInnerContainerSize(scrollView->getContentSize());
|
||||
Size backgroundSize = background->getContentSize();
|
||||
scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - scrollView->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - scrollView->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - scrollView->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - scrollView->getContentSize().height) / 2.0f));
|
||||
_uiLayer->addChild(scrollView);
|
||||
|
||||
ImageView* imageView = ImageView::create("cocosui/ccicon.png");
|
||||
|
||||
float innerWidth = scrollView->getSize().width + imageView->getSize().width;
|
||||
float innerHeight = scrollView->getSize().height;
|
||||
float innerWidth = scrollView->getContentSize().width + imageView->getContentSize().width;
|
||||
float innerHeight = scrollView->getContentSize().height;
|
||||
|
||||
scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));
|
||||
|
||||
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||
button->setPosition(Vec2(button->getSize().width / 2.0f,
|
||||
scrollView->getInnerContainerSize().height - button->getSize().height / 2.0f));
|
||||
button->setPosition(Vec2(button->getContentSize().width / 2.0f,
|
||||
scrollView->getInnerContainerSize().height - button->getContentSize().height / 2.0f));
|
||||
scrollView->addChild(button);
|
||||
|
||||
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||
titleButton->setTitleText("Title Button");
|
||||
titleButton->setPosition(Vec2(button->getRightBoundary() + button->getSize().width / 2.0f,
|
||||
button->getBottomBoundary() - button->getSize().height / 2.0f));
|
||||
titleButton->setPosition(Vec2(button->getRightBoundary() + button->getContentSize().width / 2.0f,
|
||||
button->getBottomBoundary() - button->getContentSize().height / 2.0f));
|
||||
scrollView->addChild(titleButton);
|
||||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(titleButton->getRightBoundary() + titleButton->getSize().width / 2.0f,
|
||||
titleButton->getBottomBoundary() - titleButton->getSize().height / 2.0f));
|
||||
button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(titleButton->getRightBoundary() + titleButton->getContentSize().width / 2.0f,
|
||||
titleButton->getBottomBoundary() - titleButton->getContentSize().height / 2.0f));
|
||||
scrollView->addChild(button_scale9);
|
||||
|
||||
imageView->setPosition(Vec2(innerWidth - imageView->getSize().width / 2.0f,
|
||||
button_scale9->getBottomBoundary() - button_scale9->getSize().height / 2.0f));
|
||||
imageView->setPosition(Vec2(innerWidth - imageView->getContentSize().width / 2.0f,
|
||||
button_scale9->getBottomBoundary() - button_scale9->getContentSize().height / 2.0f));
|
||||
scrollView->addChild(imageView);
|
||||
|
||||
return true;
|
||||
|
@ -173,18 +173,18 @@ bool UIScrollViewTest_Both::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();;
|
||||
Size widgetSize = _widget->getContentSize();;
|
||||
|
||||
// Add a label in which the dragpanel events will be displayed
|
||||
_displayValueLabel = Text::create("Move by any direction","fonts/Marker Felt.ttf",32);
|
||||
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
|
||||
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
||||
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
|
||||
_uiLayer->addChild(_displayValueLabel);
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("ScrollView both","fonts/Marker Felt.ttf",30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||
|
@ -198,12 +198,12 @@ bool UIScrollViewTest_Both::init()
|
|||
scrollView->setBounceEnabled(true);
|
||||
scrollView->setBackGroundImageScale9Enabled(true);
|
||||
scrollView->setBackGroundImage("cocosui/green_edit.png");
|
||||
scrollView->setSize(Size(210, 122.5));
|
||||
scrollView->setContentSize(Size(210, 122.5));
|
||||
Size backgroundSize = background->getContentSize();
|
||||
scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - scrollView->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - scrollView->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - scrollView->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - scrollView->getContentSize().height) / 2.0f));
|
||||
ImageView* imageView = ImageView::create("Hello.png");
|
||||
scrollView->addChild(imageView);
|
||||
|
||||
|
@ -234,18 +234,18 @@ bool UIScrollViewTest_ScrollToPercentBothDirection::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add a label in which the dragpanel events will be displayed
|
||||
_displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf",30);
|
||||
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
|
||||
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
||||
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
|
||||
_uiLayer->addChild(_displayValueLabel);
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("ScrollView scroll to percent both directrion","fonts/Marker Felt.ttf",20);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 4.5));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||
|
@ -257,12 +257,12 @@ bool UIScrollViewTest_ScrollToPercentBothDirection::init()
|
|||
sc->setBackGroundColorType(Layout::BackGroundColorType::SOLID);
|
||||
sc->setDirection(ui::ScrollView::Direction::BOTH);
|
||||
sc->setInnerContainerSize(Size(480, 320));
|
||||
sc->setSize(Size(100,100));
|
||||
sc->setContentSize(Size(100,100));
|
||||
Size backgroundSize = background->getContentSize();
|
||||
sc->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - sc->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - sc->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - sc->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - sc->getContentSize().height) / 2.0f));
|
||||
sc->scrollToPercentBothDirection(Vec2(50, 50), 1, true);
|
||||
ImageView* iv = ImageView::create("cocosui/Hello.png");
|
||||
iv->setPosition(Vec2(240, 160));
|
||||
|
@ -289,18 +289,18 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add a label in which the dragpanel events will be displayed
|
||||
_displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",32);
|
||||
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
|
||||
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
||||
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
|
||||
_uiLayer->addChild(_displayValueLabel);
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("ScrollView scroll to percent both directrion bounce","fonts/Marker Felt.ttf",20);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 4.5));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||
|
@ -313,12 +313,12 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce::init()
|
|||
sc->setBounceEnabled(true);
|
||||
sc->setDirection(ui::ScrollView::Direction::BOTH);
|
||||
sc->setInnerContainerSize(Size(480, 320));
|
||||
sc->setSize(Size(100,100));
|
||||
sc->setContentSize(Size(100,100));
|
||||
Size backgroundSize = background->getContentSize();
|
||||
sc->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||
(backgroundSize.width - sc->getSize().width) / 2.0f,
|
||||
(backgroundSize.width - sc->getContentSize().width) / 2.0f,
|
||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||
(backgroundSize.height - sc->getSize().height) / 2.0f));
|
||||
(backgroundSize.height - sc->getContentSize().height) / 2.0f));
|
||||
sc->scrollToPercentBothDirection(Vec2(50, 50), 1, true);
|
||||
ImageView* iv = ImageView::create("cocosui/Hello.png");
|
||||
iv->setPosition(Vec2(240, 160));
|
||||
|
|
|
@ -23,7 +23,7 @@ bool UIScrollViewTest_Vertical_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/ui_scrollview_editor_1.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -36,8 +36,8 @@ bool UIScrollViewTest_Vertical_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height * 0.625));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
|
@ -45,8 +45,8 @@ bool UIScrollViewTest_Vertical_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||
|
@ -79,7 +79,7 @@ bool UIScrollViewTest_Horizontal_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/ui_scrollview_horizontal_editor_1.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -92,8 +92,8 @@ bool UIScrollViewTest_Horizontal_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height * 0.625));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
|
@ -101,8 +101,8 @@ bool UIScrollViewTest_Horizontal_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||
|
@ -135,7 +135,7 @@ bool UIScrollViewTest_Both_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/ui_scrollview_both_editor_1.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -148,8 +148,8 @@ bool UIScrollViewTest_Both_Editor::init()
|
|||
|
||||
Button* left_button = Button::create();
|
||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||
left_button->setPosition(Vec2(_layout->getSize().width / 2 - left_button->getSize().width,
|
||||
left_button->getSize().height * 0.625));
|
||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||
left_button->getContentSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
|
@ -157,8 +157,8 @@ bool UIScrollViewTest_Both_Editor::init()
|
|||
|
||||
Button* right_button = Button::create();
|
||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||
right_button->setPosition(Vec2(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||
right_button->getContentSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||
|
@ -191,7 +191,7 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UITest/UITest.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -238,7 +238,7 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UITest/UITest.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ bool UISliderTest::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add a label in which the slider alert will be displayed
|
||||
_displayValueLabel = Text::create("Move the slider thumb","Move the slider thumb",32);
|
||||
|
@ -30,7 +30,7 @@ bool UISliderTest::init()
|
|||
// Add the alert
|
||||
Text* alert = Text::create("Slider","fonts/Marker Felt.ttf",30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the slider
|
||||
|
@ -74,7 +74,7 @@ bool UISliderTest_Scale9::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add a label in which the slider alert will be displayed
|
||||
_displayValueLabel = Text::create("Move the slider thumb","fonts/Marker Felt.ttf",32);
|
||||
|
@ -85,7 +85,7 @@ bool UISliderTest_Scale9::init()
|
|||
// Add the alert
|
||||
Text *alert = Text::create("Slider scale9 render","fonts/Marker Felt.ttf",30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the slider
|
||||
|
@ -95,7 +95,7 @@ bool UISliderTest_Scale9::init()
|
|||
slider->loadProgressBarTexture("cocosui/slider_bar_active_9patch.png");
|
||||
slider->setScale9Enabled(true);
|
||||
slider->setCapInsets(Rect(0, 0, 0, 0));
|
||||
slider->setSize(Size(250.0f, 19));
|
||||
slider->setContentSize(Size(250.0f, 19));
|
||||
slider->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f/* + slider->getSize().height * 3.0f*/));
|
||||
slider->addEventListener(CC_CALLBACK_2(UISliderTest_Scale9::sliderEvent, this));
|
||||
_uiLayer->addChild(slider);
|
||||
|
|
|
@ -24,7 +24,7 @@ bool UISliderTest_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -47,8 +47,8 @@ bool UISliderTest_Editor::init()
|
|||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
||||
_displayValueLabel->setFontSize(30);
|
||||
_displayValueLabel->setString("No event");
|
||||
_displayValueLabel->setPosition(Vec2(_layout->getSize().width / 2,
|
||||
_layout->getSize().height - _displayValueLabel->getSize().height * 1.75f));
|
||||
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
||||
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
||||
_touchGroup->addChild(_displayValueLabel);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -9,12 +9,12 @@ bool UITextAtlasTest::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("TextAtlas","fonts/Marker Felt.ttf",30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the text atlas
|
||||
|
|
|
@ -12,7 +12,7 @@ bool UITextAtlasTest_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
|
|
@ -9,16 +9,16 @@ bool UITextBMFontTest::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
Text* alert = Text::create("TextBMFont","TextBMFont",30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the TextBMFont
|
||||
TextBMFont* textBMFont = TextBMFont::create("BMFont", "cocosui/bitmapFontTest2.fnt");
|
||||
textBMFont->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2.0f + textBMFont->getSize().height / 8.0f));
|
||||
textBMFont->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2.0f + textBMFont->getContentSize().height / 8.0f));
|
||||
_uiLayer->addChild(textBMFont);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -13,7 +13,7 @@ bool UITextBMFontTest_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
|
|
@ -17,18 +17,18 @@ bool UITextFieldTest::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add a label in which the textfield events will be displayed
|
||||
_displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",32);
|
||||
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
|
||||
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
||||
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
|
||||
_uiLayer->addChild(_displayValueLabel);
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create("TextField","fonts/Marker Felt.ttf",30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the textfield
|
||||
|
@ -100,13 +100,13 @@ bool UITextFieldTest_MaxLength::init()
|
|||
// Add a label in which the textfield events will be displayed
|
||||
_displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",32);
|
||||
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
|
||||
_displayValueLabel->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
||||
_displayValueLabel->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
|
||||
_uiLayer->addChild(_displayValueLabel);
|
||||
|
||||
// Add the alert
|
||||
Text *alert = Text::create("TextField max length","fonts/Marker Felt.ttf",30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||
alert->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getContentSize().height * 3.075f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the textfield
|
||||
|
@ -184,13 +184,13 @@ bool UITextFieldTest_Password::init()
|
|||
// Add a label in which the textfield events will be displayed
|
||||
_displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",32);
|
||||
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
|
||||
_displayValueLabel->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
||||
_displayValueLabel->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
|
||||
_uiLayer->addChild(_displayValueLabel);
|
||||
|
||||
// Add the alert
|
||||
Text *alert = Text::create("TextField password","fonts/Marker Felt.ttf",30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||
alert->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getContentSize().height * 3.075f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the textfield
|
||||
|
@ -258,24 +258,24 @@ bool UITextFieldTest_LineWrap::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add a label in which the textfield events will be displayed
|
||||
_displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",30);
|
||||
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1));
|
||||
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5));
|
||||
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5));
|
||||
_uiLayer->addChild(_displayValueLabel);
|
||||
|
||||
// Add the alert
|
||||
Text *alert = Text::create("TextField line wrap","fonts/Marker Felt.ttf",30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the textfield
|
||||
TextField* textField = TextField::create("input words here","fonts/Marker Felt.ttf",30);
|
||||
textField->ignoreContentAdaptWithSize(false);
|
||||
textField->setSize(Size(240, 160));
|
||||
textField->setContentSize(Size(240, 160));
|
||||
textField->setTextHorizontalAlignment(TextHAlignment::CENTER);
|
||||
textField->setTextVerticalAlignment(TextVAlignment::CENTER);
|
||||
textField->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||
|
@ -294,7 +294,7 @@ void UITextFieldTest_LineWrap::textFieldEvent(Ref *pSender, TextField::EventType
|
|||
case TextField::EventType::ATTACH_WITH_IME:
|
||||
{
|
||||
TextField* textField = dynamic_cast<TextField*>(pSender);
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
textField->runAction(CCMoveTo::create(0.225f,
|
||||
Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + textField->getContentSize().height / 2)));
|
||||
textField->setTextHorizontalAlignment(TextHAlignment::LEFT);
|
||||
|
@ -307,7 +307,7 @@ void UITextFieldTest_LineWrap::textFieldEvent(Ref *pSender, TextField::EventType
|
|||
case TextField::EventType::DETACH_WITH_IME:
|
||||
{
|
||||
TextField* textField = dynamic_cast<TextField*>(pSender);
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
textField->runAction(CCMoveTo::create(0.175f, Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)));
|
||||
textField->setTextHorizontalAlignment(TextHAlignment::CENTER);
|
||||
textField->setTextVerticalAlignment(TextVAlignment::CENTER);
|
||||
|
|
|
@ -24,7 +24,7 @@ bool UITextFieldTest_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
@ -48,8 +48,8 @@ bool UITextFieldTest_Editor::init()
|
|||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
||||
_displayValueLabel->setFontSize(30);
|
||||
_displayValueLabel->setString("No event");
|
||||
_displayValueLabel->setPosition(Vec2(_layout->getSize().width / 2,
|
||||
_layout->getSize().height - _displayValueLabel->getSize().height * 1.75f));
|
||||
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
||||
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
||||
_touchGroup->addChild(_displayValueLabel);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -9,16 +9,16 @@ bool UITextTest::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
Text* alert = Text::create("Text","fonts/Marker Felt.ttf", 30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the text
|
||||
Text* text = Text::create("Text", "AmericanTypewriter", 30);
|
||||
text->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + text->getSize().height / 4.0f));
|
||||
text->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + text->getContentSize().height / 4.0f));
|
||||
_uiLayer->addChild(text);
|
||||
|
||||
return true;
|
||||
|
@ -32,19 +32,19 @@ bool UITextTest_LineWrap::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
Text* alert = Text::create("Text line wrap","fonts/Marker Felt.ttf",30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the line wrap
|
||||
Text* text = Text::create("Text can line wrap","AmericanTypewriter",32);
|
||||
text->ignoreContentAdaptWithSize(false);
|
||||
text->setSize(Size(280, 150));
|
||||
text->setContentSize(Size(280, 150));
|
||||
text->setTextHorizontalAlignment(TextHAlignment::CENTER);
|
||||
text->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - text->getSize().height / 8.0f));
|
||||
text->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - text->getContentSize().height / 8.0f));
|
||||
_uiLayer->addChild(text);
|
||||
|
||||
return true;
|
||||
|
@ -59,14 +59,14 @@ bool UILabelTest_Effect::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
Text* alert = Text::create();
|
||||
alert->setString("Label Effect");
|
||||
alert->setFontName("fonts/Marker Felt.ttf");
|
||||
alert->setFontSize(30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.05f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.05f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
|
||||
|
@ -75,7 +75,7 @@ bool UILabelTest_Effect::init()
|
|||
|
||||
shadow_label->enableShadow();
|
||||
shadow_label->setString("Shadow");
|
||||
shadow_label->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + shadow_label->getSize().height));
|
||||
shadow_label->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + shadow_label->getContentSize().height));
|
||||
|
||||
_uiLayer->addChild(shadow_label);
|
||||
|
||||
|
@ -97,7 +97,7 @@ bool UILabelTest_Effect::init()
|
|||
Text* outline_label = Text::create();
|
||||
outline_label->enableOutline(Color4B::BLUE, 2);
|
||||
outline_label->setString("Outline");
|
||||
outline_label->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - shadow_label->getSize().height));
|
||||
outline_label->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - shadow_label->getContentSize().height));
|
||||
|
||||
_uiLayer->addChild(outline_label);
|
||||
|
||||
|
@ -114,16 +114,16 @@ bool UITextTest_TTF::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
Text* alert = Text::create("Text set TTF font","fonts/Marker Felt.ttf",30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the text, and set font with .ttf
|
||||
Text* text = Text::create("Text","fonts/A Damn Mess.ttf",30);
|
||||
text->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + text->getSize().height / 4.0f));
|
||||
text->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + text->getContentSize().height / 4.0f));
|
||||
_uiLayer->addChild(text);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -15,7 +15,7 @@ bool UITextTest_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ void VideoPlayerTest::createVideo()
|
|||
{
|
||||
auto centerPos = Vec2(_visibleRect.origin.x + _visibleRect.size.width / 2,_visibleRect.origin.y + _visibleRect.size.height /2);
|
||||
|
||||
auto widgetSize = _widget->getSize();
|
||||
auto widgetSize = _widget->getContentSize();
|
||||
|
||||
_videoPlayer = VideoPlayer::create();
|
||||
_videoPlayer->setPosition(centerPos);
|
||||
|
|
|
@ -18,7 +18,7 @@ bool UIWidgetAddNodeTest::init()
|
|||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getSize();
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
// Add the alert
|
||||
Text* alert = Text::create();
|
||||
|
@ -26,7 +26,7 @@ bool UIWidgetAddNodeTest::init()
|
|||
alert->setFontName("fonts/Marker Felt.ttf");
|
||||
alert->setFontSize(30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75));
|
||||
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 1.75));
|
||||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the ui node container
|
||||
|
|
|
@ -23,7 +23,7 @@ bool UIWidgetAddNodeTest_Editor::init()
|
|||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.csb"));
|
||||
_touchGroup->addChild(_layout);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
Size rootSize = _layout->getSize();
|
||||
Size rootSize = _layout->getContentSize();
|
||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||
(screenSize.height - rootSize.height) / 2));
|
||||
|
||||
|
|
Loading…
Reference in New Issue