axmol/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp

817 lines
24 KiB
C++
Raw Normal View History

/****************************************************************************
Copyright (c) 2012 cocos2d-x.org
http://www.cocos2d-x.org
Created by Jung Sang-Taik on 12. 3. 16..
Copyright (c) 2012 Neofect. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
2012-04-16 18:58:43 +08:00
#include "CCScale9Sprite.h"
#include "base/CCPlatformMacros.h"
#include "2d/CCSprite.h"
#include "2d/CCSpriteFrameCache.h"
NS_CC_EXT_BEGIN
2012-04-16 18:58:43 +08:00
Scale9Sprite::Scale9Sprite()
: _spritesGenerated(false)
, _spriteFrameRotated(false)
, _positionsAreDirty(false)
, _scale9Image(nullptr)
, _topLeft(nullptr)
, _top(nullptr)
, _topRight(nullptr)
, _left(nullptr)
, _centre(nullptr)
, _right(nullptr)
, _bottomLeft(nullptr)
, _bottom(nullptr)
, _bottomRight(nullptr)
, _opacityModifyRGB(false)
, _insetLeft(0)
, _insetTop(0)
, _insetRight(0)
, _insetBottom(0)
2012-04-16 18:58:43 +08:00
{
2012-04-16 18:58:43 +08:00
}
Scale9Sprite::~Scale9Sprite()
2012-04-16 18:58:43 +08:00
{
CC_SAFE_RELEASE(_topLeft);
CC_SAFE_RELEASE(_top);
CC_SAFE_RELEASE(_topRight);
CC_SAFE_RELEASE(_left);
CC_SAFE_RELEASE(_centre);
CC_SAFE_RELEASE(_right);
CC_SAFE_RELEASE(_bottomLeft);
CC_SAFE_RELEASE(_bottom);
CC_SAFE_RELEASE(_bottomRight);
CC_SAFE_RELEASE(_scale9Image);
2012-04-16 18:58:43 +08:00
}
bool Scale9Sprite::init()
{
return this->initWithBatchNode(nullptr, Rect::ZERO, Rect::ZERO);
}
bool Scale9Sprite::initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, const Rect& capInsets)
{
return this->initWithBatchNode(batchnode, rect, false, capInsets);
}
bool Scale9Sprite::initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, bool rotated, const Rect& capInsets)
2012-04-16 18:58:43 +08:00
{
if(batchnode)
{
this->updateWithBatchNode(batchnode, rect, rotated, capInsets);
}
this->setCascadeColorEnabled(true);
this->setCascadeOpacityEnabled(true);
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
this->setAnchorPoint(Vec2(0.5f, 0.5f));
this->_positionsAreDirty = true;
return true;
}
#define TRANSLATE_X(x, y, xtranslate) \
x+=xtranslate; \
#define TRANSLATE_Y(x, y, ytranslate) \
y+=ytranslate; \
bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, const Rect& originalRect, bool rotated, const Rect& capInsets)
{
2013-02-28 11:55:36 +08:00
GLubyte opacity = getOpacity();
Color3B color = getColor();
Rect rect(originalRect);
// Release old sprites
this->removeAllChildrenWithCleanup(true);
CC_SAFE_RELEASE(this->_centre);
CC_SAFE_RELEASE(this->_top);
CC_SAFE_RELEASE(this->_topLeft);
CC_SAFE_RELEASE(this->_topRight);
CC_SAFE_RELEASE(this->_left);
CC_SAFE_RELEASE(this->_right);
CC_SAFE_RELEASE(this->_bottomLeft);
CC_SAFE_RELEASE(this->_bottom);
CC_SAFE_RELEASE(this->_bottomRight);
if(this->_scale9Image != batchnode)
{
CC_SAFE_RELEASE(this->_scale9Image);
_scale9Image = batchnode;
CC_SAFE_RETAIN(_scale9Image);
}
2013-09-16 20:54:13 +08:00
if (!_scale9Image)
{
return false;
}
_capInsets = capInsets;
_spriteFrameRotated = rotated;
// If there is no given rect
if ( rect.equals(Rect::ZERO) )
{
// Get the texture size as original
Size textureSize = _scale9Image->getTextureAtlas()->getTexture()->getContentSize();
rect = Rect(0, 0, textureSize.width, textureSize.height);
}
// Set the given rect's size as original size
_spriteRect = rect;
_originalSize = rect.size;
_preferredSize = _originalSize;
_capInsetsInternal = capInsets;
float w = rect.size.width;
float h = rect.size.height;
// If there is no specified center region
if ( _capInsetsInternal.equals(Rect::ZERO) )
{
// log("... cap insets not specified : using default cap insets ...");
_capInsetsInternal = Rect(w/3, h/3, w/3, h/3);
}
float left_w = _capInsetsInternal.origin.x;
float center_w = _capInsetsInternal.size.width;
float right_w = rect.size.width - (left_w + center_w);
float top_h = _capInsetsInternal.origin.y;
float center_h = _capInsetsInternal.size.height;
float bottom_h = rect.size.height - (top_h + center_h);
// calculate rects
// ... top row
float x = 0.0;
float y = 0.0;
// top left
2013-07-12 15:07:44 +08:00
Rect lefttopbounds = Rect(x, y, left_w, top_h);
// top center
TRANSLATE_X(x, y, left_w);
2013-07-12 15:07:44 +08:00
Rect centertopbounds = Rect(x, y, center_w, top_h);
// top right
TRANSLATE_X(x, y, center_w);
2013-07-12 15:07:44 +08:00
Rect righttopbounds = Rect(x, y, right_w, top_h);
// ... center row
x = 0.0;
y = 0.0;
TRANSLATE_Y(x, y, top_h);
// center left
2013-07-12 15:07:44 +08:00
Rect leftcenterbounds = Rect(x, y, left_w, center_h);
// center center
TRANSLATE_X(x, y, left_w);
2013-07-12 15:07:44 +08:00
Rect centerbounds = Rect(x, y, center_w, center_h);
// center right
TRANSLATE_X(x, y, center_w);
2013-07-12 15:07:44 +08:00
Rect rightcenterbounds = Rect(x, y, right_w, center_h);
// ... bottom row
x = 0.0;
y = 0.0;
TRANSLATE_Y(x, y, top_h);
TRANSLATE_Y(x, y, center_h);
// bottom left
2013-07-12 15:07:44 +08:00
Rect leftbottombounds = Rect(x, y, left_w, bottom_h);
// bottom center
TRANSLATE_X(x, y, left_w);
2013-07-12 15:07:44 +08:00
Rect centerbottombounds = Rect(x, y, center_w, bottom_h);
// bottom right
TRANSLATE_X(x, y, center_w);
2013-07-12 15:07:44 +08:00
Rect rightbottombounds = Rect(x, y, right_w, bottom_h);
if (!rotated) {
// log("!rotated");
AffineTransform t = AffineTransform::IDENTITY;
t = AffineTransformTranslate(t, rect.origin.x, rect.origin.y);
centerbounds = RectApplyAffineTransform(centerbounds, t);
rightbottombounds = RectApplyAffineTransform(rightbottombounds, t);
leftbottombounds = RectApplyAffineTransform(leftbottombounds, t);
righttopbounds = RectApplyAffineTransform(righttopbounds, t);
lefttopbounds = RectApplyAffineTransform(lefttopbounds, t);
rightcenterbounds = RectApplyAffineTransform(rightcenterbounds, t);
leftcenterbounds = RectApplyAffineTransform(leftcenterbounds, t);
centerbottombounds = RectApplyAffineTransform(centerbottombounds, t);
centertopbounds = RectApplyAffineTransform(centertopbounds, t);
// Centre
2013-11-14 07:55:36 +08:00
_centre = Sprite::createWithTexture(_scale9Image->getTexture(), centerbounds);
_centre->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_centre);
2013-11-14 07:55:36 +08:00
// Top
2013-11-14 07:55:36 +08:00
_top = Sprite::createWithTexture(_scale9Image->getTexture(), centertopbounds);
_top->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_top);
// Bottom
2013-11-14 07:55:36 +08:00
_bottom = Sprite::createWithTexture(_scale9Image->getTexture(), centerbottombounds);
_bottom->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_bottom);
// Left
2013-11-14 07:55:36 +08:00
_left = Sprite::createWithTexture(_scale9Image->getTexture(), leftcenterbounds);
_left->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_left);
// Right
2013-11-14 07:55:36 +08:00
_right = Sprite::createWithTexture(_scale9Image->getTexture(), rightcenterbounds);
_right->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_right);
// Top left
2013-11-14 07:55:36 +08:00
_topLeft = Sprite::createWithTexture(_scale9Image->getTexture(), lefttopbounds);
_topLeft->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_topLeft);
// Top right
2013-11-14 07:55:36 +08:00
_topRight = Sprite::createWithTexture(_scale9Image->getTexture(), righttopbounds);
_topRight->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_topRight);
// Bottom left
2013-11-14 07:55:36 +08:00
_bottomLeft = Sprite::createWithTexture(_scale9Image->getTexture(), leftbottombounds);
_bottomLeft->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_bottomLeft);
// Bottom right
2013-11-14 07:55:36 +08:00
_bottomRight = Sprite::createWithTexture(_scale9Image->getTexture(), rightbottombounds);
_bottomRight->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_bottomRight);
} else {
// set up transformation of coordinates
// to handle the case where the sprite is stored rotated
// in the spritesheet
// log("rotated");
AffineTransform t = AffineTransform::IDENTITY;
Rect rotatedcenterbounds = centerbounds;
Rect rotatedrightbottombounds = rightbottombounds;
Rect rotatedleftbottombounds = leftbottombounds;
Rect rotatedrighttopbounds = righttopbounds;
Rect rotatedlefttopbounds = lefttopbounds;
Rect rotatedrightcenterbounds = rightcenterbounds;
Rect rotatedleftcenterbounds = leftcenterbounds;
Rect rotatedcenterbottombounds = centerbottombounds;
Rect rotatedcentertopbounds = centertopbounds;
t = AffineTransformTranslate(t, rect.size.height+rect.origin.x, rect.origin.y);
t = AffineTransformRotate(t, 1.57079633f);
centerbounds = RectApplyAffineTransform(centerbounds, t);
rightbottombounds = RectApplyAffineTransform(rightbottombounds, t);
leftbottombounds = RectApplyAffineTransform(leftbottombounds, t);
righttopbounds = RectApplyAffineTransform(righttopbounds, t);
lefttopbounds = RectApplyAffineTransform(lefttopbounds, t);
rightcenterbounds = RectApplyAffineTransform(rightcenterbounds, t);
leftcenterbounds = RectApplyAffineTransform(leftcenterbounds, t);
centerbottombounds = RectApplyAffineTransform(centerbottombounds, t);
centertopbounds = RectApplyAffineTransform(centertopbounds, t);
rotatedcenterbounds.origin = centerbounds.origin;
rotatedrightbottombounds.origin = rightbottombounds.origin;
rotatedleftbottombounds.origin = leftbottombounds.origin;
rotatedrighttopbounds.origin = righttopbounds.origin;
rotatedlefttopbounds.origin = lefttopbounds.origin;
rotatedrightcenterbounds.origin = rightcenterbounds.origin;
rotatedleftcenterbounds.origin = leftcenterbounds.origin;
rotatedcenterbottombounds.origin = centerbottombounds.origin;
rotatedcentertopbounds.origin = centertopbounds.origin;
// Centre
2013-11-14 07:55:36 +08:00
_centre = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedcenterbounds, true);
_centre->retain();
2014-06-25 11:27:48 +08:00
this->addChild(_centre, 0);
// Top
2013-11-14 07:55:36 +08:00
_top = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedcentertopbounds, true);
_top->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_top);
// Bottom
_bottom = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedcenterbottombounds, true);
2013-11-14 07:55:36 +08:00
_bottom->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_bottom);
// Left
2013-11-14 07:55:36 +08:00
_left = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedleftcenterbounds, true);
_left->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_left);
// Right
2013-11-14 07:55:36 +08:00
_right = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedrightcenterbounds, true);
_right->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_right);
// Top left
2013-11-14 07:55:36 +08:00
_topLeft = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedlefttopbounds, true);
_topLeft->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_topLeft);
// Top right
2013-11-14 07:55:36 +08:00
_topRight = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedrighttopbounds, true);
_topRight->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_topRight);
// Bottom left
2013-11-14 07:55:36 +08:00
_bottomLeft = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedleftbottombounds, true);
_bottomLeft->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_bottomLeft);
// Bottom right
2013-11-14 07:55:36 +08:00
_bottomRight = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedrightbottombounds, true);
_bottomRight->retain();
2014-07-22 16:26:40 +08:00
this->addChild(_bottomRight);
}
this->setContentSize(rect.size);
2014-07-22 16:26:40 +08:00
// this->addChild(_scale9Image);
if (_spritesGenerated)
2013-07-11 17:07:41 +08:00
{
// Restore color and opacity
this->setOpacity(opacity);
this->setColor(color);
}
_spritesGenerated = true;
return true;
2012-04-16 18:58:43 +08:00
}
void Scale9Sprite::setContentSize(const Size &size)
2012-04-16 18:58:43 +08:00
{
Node::setContentSize(size);
this->_positionsAreDirty = true;
}
void Scale9Sprite::updatePositions()
{
// Check that instances are non-nullptr
if(!((_topLeft) &&
(_topRight) &&
(_bottomRight) &&
(_bottomLeft) &&
(_centre))) {
// if any of the above sprites are nullptr, return
2013-01-25 07:43:10 +08:00
return;
}
Size size = this->_contentSize;
float sizableWidth = size.width - _topLeft->getContentSize().width - _topRight->getContentSize().width;
float sizableHeight = size.height - _topLeft->getContentSize().height - _bottomRight->getContentSize().height;
float horizontalScale = sizableWidth/_centre->getContentSize().width;
float verticalScale = sizableHeight/_centre->getContentSize().height;
_centre->setScaleX(horizontalScale);
_centre->setScaleY(verticalScale);
float rescaledWidth = _centre->getContentSize().width * horizontalScale;
float rescaledHeight = _centre->getContentSize().height * verticalScale;
float leftWidth = _bottomLeft->getContentSize().width;
float bottomHeight = _bottomLeft->getContentSize().height;
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
_bottomLeft->setAnchorPoint(Vec2(0,0));
_bottomRight->setAnchorPoint(Vec2(0,0));
_topLeft->setAnchorPoint(Vec2(0,0));
_topRight->setAnchorPoint(Vec2(0,0));
_left->setAnchorPoint(Vec2(0,0));
_right->setAnchorPoint(Vec2(0,0));
_top->setAnchorPoint(Vec2(0,0));
_bottom->setAnchorPoint(Vec2(0,0));
_centre->setAnchorPoint(Vec2(0,0));
// Position corners
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
_bottomLeft->setPosition(Vec2(0,0));
_bottomRight->setPosition(Vec2(leftWidth+rescaledWidth,0));
_topLeft->setPosition(Vec2(0, bottomHeight+rescaledHeight));
_topRight->setPosition(Vec2(leftWidth+rescaledWidth, bottomHeight+rescaledHeight));
// Scale and position borders
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
_left->setPosition(Vec2(0, bottomHeight));
_left->setScaleY(verticalScale);
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
_right->setPosition(Vec2(leftWidth+rescaledWidth,bottomHeight));
_right->setScaleY(verticalScale);
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
_bottom->setPosition(Vec2(leftWidth,0));
_bottom->setScaleX(horizontalScale);
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
_top->setPosition(Vec2(leftWidth,bottomHeight+rescaledHeight));
_top->setScaleX(horizontalScale);
// Position centre
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
_centre->setPosition(Vec2(leftWidth, bottomHeight));
2012-04-16 18:58:43 +08:00
}
2014-04-02 18:35:08 +08:00
bool Scale9Sprite::initWithFile(const std::string& file, const Rect& rect, const Rect& capInsets)
{
SpriteBatchNode *batchnode = SpriteBatchNode::create(file, 9);
2012-04-16 18:58:43 +08:00
bool pReturn = this->initWithBatchNode(batchnode, rect, capInsets);
return pReturn;
}
2014-04-02 18:35:08 +08:00
Scale9Sprite* Scale9Sprite::create(const std::string& file, const Rect& rect, const Rect& capInsets)
2012-04-16 18:58:43 +08:00
{
Scale9Sprite* pReturn = new Scale9Sprite();
if ( pReturn && pReturn->initWithFile(file, rect, capInsets) )
{
pReturn->autorelease();
return pReturn;
}
CC_SAFE_DELETE(pReturn);
return nullptr;
2012-04-16 18:58:43 +08:00
}
2014-04-02 18:35:08 +08:00
bool Scale9Sprite::initWithFile(const std::string& file, const Rect& rect)
2012-04-16 18:58:43 +08:00
{
bool pReturn = this->initWithFile(file, rect, Rect::ZERO);
2012-04-16 18:58:43 +08:00
return pReturn;
}
2014-04-02 18:35:08 +08:00
Scale9Sprite* Scale9Sprite::create(const std::string& file, const Rect& rect)
2012-04-16 18:58:43 +08:00
{
Scale9Sprite* pReturn = new Scale9Sprite();
if ( pReturn && pReturn->initWithFile(file, rect) )
{
pReturn->autorelease();
return pReturn;
}
CC_SAFE_DELETE(pReturn);
return nullptr;
2012-04-16 18:58:43 +08:00
}
2014-04-02 18:35:08 +08:00
bool Scale9Sprite::initWithFile(const Rect& capInsets, const std::string& file)
2012-04-16 18:58:43 +08:00
{
bool pReturn = this->initWithFile(file, Rect::ZERO, capInsets);
2012-04-16 18:58:43 +08:00
return pReturn;
}
2014-04-02 18:35:08 +08:00
Scale9Sprite* Scale9Sprite::create(const Rect& capInsets, const std::string& file)
2012-04-16 18:58:43 +08:00
{
Scale9Sprite* pReturn = new Scale9Sprite();
if ( pReturn && pReturn->initWithFile(capInsets, file) )
{
pReturn->autorelease();
return pReturn;
}
CC_SAFE_DELETE(pReturn);
return nullptr;
2012-04-16 18:58:43 +08:00
}
2014-04-02 18:35:08 +08:00
bool Scale9Sprite::initWithFile(const std::string& file)
2012-04-16 18:58:43 +08:00
{
bool pReturn = this->initWithFile(file, Rect::ZERO);
2012-04-16 18:58:43 +08:00
return pReturn;
2012-04-16 18:58:43 +08:00
}
2014-04-02 18:35:08 +08:00
Scale9Sprite* Scale9Sprite::create(const std::string& file)
2012-04-16 18:58:43 +08:00
{
Scale9Sprite* pReturn = new Scale9Sprite();
if ( pReturn && pReturn->initWithFile(file) )
{
pReturn->autorelease();
return pReturn;
}
CC_SAFE_DELETE(pReturn);
return nullptr;
2012-04-16 18:58:43 +08:00
}
bool Scale9Sprite::initWithSpriteFrame(SpriteFrame* spriteFrame, const Rect& capInsets)
2012-04-16 18:58:43 +08:00
{
Texture2D* texture = spriteFrame->getTexture();
CCASSERT(texture != nullptr, "CCTexture must be not nil");
SpriteBatchNode *batchnode = SpriteBatchNode::createWithTexture(texture, 9);
CCASSERT(batchnode != nullptr, "CCSpriteBatchNode must be not nil");
bool pReturn = this->initWithBatchNode(batchnode, spriteFrame->getRect(), spriteFrame->isRotated(), capInsets);
2012-04-16 18:58:43 +08:00
return pReturn;
}
Scale9Sprite* Scale9Sprite::createWithSpriteFrame(SpriteFrame* spriteFrame, const Rect& capInsets)
2012-04-16 18:58:43 +08:00
{
Scale9Sprite* pReturn = new Scale9Sprite();
if ( pReturn && pReturn->initWithSpriteFrame(spriteFrame, capInsets) )
{
pReturn->autorelease();
return pReturn;
}
CC_SAFE_DELETE(pReturn);
return nullptr;
2012-04-16 18:58:43 +08:00
}
bool Scale9Sprite::initWithSpriteFrame(SpriteFrame* spriteFrame)
2012-04-16 18:58:43 +08:00
{
CCASSERT(spriteFrame != nullptr, "Invalid spriteFrame for sprite");
bool pReturn = this->initWithSpriteFrame(spriteFrame, Rect::ZERO);
2012-04-16 18:58:43 +08:00
return pReturn;
}
Scale9Sprite* Scale9Sprite::createWithSpriteFrame(SpriteFrame* spriteFrame)
2012-04-16 18:58:43 +08:00
{
Scale9Sprite* pReturn = new Scale9Sprite();
if ( pReturn && pReturn->initWithSpriteFrame(spriteFrame) )
{
pReturn->autorelease();
return pReturn;
}
CC_SAFE_DELETE(pReturn);
return nullptr;
2012-04-16 18:58:43 +08:00
}
2014-04-02 18:35:08 +08:00
bool Scale9Sprite::initWithSpriteFrameName(const std::string& spriteFrameName, const Rect& capInsets)
2012-04-16 18:58:43 +08:00
{
CCASSERT((SpriteFrameCache::getInstance()) != nullptr, "SpriteFrameCache::getInstance() must be non-nullptr");
SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName);
CCASSERT(frame != nullptr, "CCSpriteFrame must be non-nullptr");
if (nullptr == frame) return false;
2012-04-16 18:58:43 +08:00
bool pReturn = this->initWithSpriteFrame(frame, capInsets);
return pReturn;
}
2014-04-02 18:35:08 +08:00
Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const std::string& spriteFrameName, const Rect& capInsets)
2012-04-16 18:58:43 +08:00
{
Scale9Sprite* pReturn = new Scale9Sprite();
if ( pReturn && pReturn->initWithSpriteFrameName(spriteFrameName, capInsets) )
{
pReturn->autorelease();
return pReturn;
}
CC_SAFE_DELETE(pReturn);
return nullptr;
2012-04-16 18:58:43 +08:00
}
2014-04-02 18:35:08 +08:00
bool Scale9Sprite::initWithSpriteFrameName(const std::string& spriteFrameName)
2012-04-16 18:58:43 +08:00
{
bool pReturn = this->initWithSpriteFrameName(spriteFrameName, Rect::ZERO);
2012-04-16 18:58:43 +08:00
return pReturn;
}
2014-04-02 18:35:08 +08:00
Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const std::string& spriteFrameName)
2012-04-16 18:58:43 +08:00
{
Scale9Sprite* pReturn = new Scale9Sprite();
if ( pReturn && pReturn->initWithSpriteFrameName(spriteFrameName) )
{
pReturn->autorelease();
return pReturn;
}
CC_SAFE_DELETE(pReturn);
log("Could not allocate Scale9Sprite()");
return nullptr;
2012-04-16 18:58:43 +08:00
}
Scale9Sprite* Scale9Sprite::resizableSpriteWithCapInsets(const Rect& capInsets)
2012-04-16 18:58:43 +08:00
{
Scale9Sprite* pReturn = new Scale9Sprite();
if ( pReturn && pReturn->initWithBatchNode(_scale9Image, _spriteRect, capInsets) )
{
pReturn->autorelease();
return pReturn;
}
CC_SAFE_DELETE(pReturn);
return nullptr;
2012-04-16 18:58:43 +08:00
}
Scale9Sprite* Scale9Sprite::create()
{
Scale9Sprite *pReturn = new Scale9Sprite();
if (pReturn && pReturn->init())
{
pReturn->autorelease();
return pReturn;
2012-04-16 18:58:43 +08:00
}
CC_SAFE_DELETE(pReturn);
return nullptr;
2012-04-16 18:58:43 +08:00
}
/** sets the opacity.
@warning If the the texture has premultiplied alpha then, the R, G and B channels will be modifed.
Values goes from 0 to 255, where 255 means fully opaque.
*/
void Scale9Sprite::setPreferredSize(Size preferedSize)
{
this->setContentSize(preferedSize);
this->_preferredSize = preferedSize;
}
Size Scale9Sprite::getPreferredSize()
{
return this->_preferredSize;
}
2012-04-16 18:58:43 +08:00
void Scale9Sprite::setCapInsets(Rect capInsets)
2012-04-16 18:58:43 +08:00
{
Size contentSize = this->_contentSize;
this->updateWithBatchNode(this->_scale9Image, this->_spriteRect, _spriteFrameRotated, capInsets);
this->setContentSize(contentSize);
2012-04-16 18:58:43 +08:00
}
Rect Scale9Sprite::getCapInsets()
2012-04-16 18:58:43 +08:00
{
return _capInsets;
2012-04-16 18:58:43 +08:00
}
void Scale9Sprite::updateCapInset()
{
Rect insets;
if (this->_insetLeft == 0 && this->_insetTop == 0 && this->_insetRight == 0 && this->_insetBottom == 0)
{
insets = Rect::ZERO;
}
else
{
2013-07-12 15:07:44 +08:00
insets = Rect(_insetLeft,
_insetTop,
_spriteRect.size.width-_insetLeft-_insetRight,
_spriteRect.size.height-_insetTop-_insetBottom);
}
this->setCapInsets(insets);
}
void Scale9Sprite::setOpacityModifyRGB(bool var)
2012-04-16 18:58:43 +08:00
{
2013-09-16 20:54:13 +08:00
if (!_scale9Image)
{
return;
}
_opacityModifyRGB = var;
for(auto child : _scale9Image->getChildren()){
child->setOpacityModifyRGB(_opacityModifyRGB);
}
2012-04-16 18:58:43 +08:00
}
bool Scale9Sprite::isOpacityModifyRGB() const
2012-04-16 18:58:43 +08:00
{
return _opacityModifyRGB;
2012-04-16 18:58:43 +08:00
}
void Scale9Sprite::setSpriteFrame(SpriteFrame * spriteFrame)
{
SpriteBatchNode * batchnode = SpriteBatchNode::createWithTexture(spriteFrame->getTexture(), 9);
this->updateWithBatchNode(batchnode, spriteFrame->getRect(), spriteFrame->isRotated(), Rect::ZERO);
// Reset insets
this->_insetLeft = 0;
this->_insetTop = 0;
this->_insetRight = 0;
this->_insetBottom = 0;
}
float Scale9Sprite::getInsetLeft()
{
return this->_insetLeft;
}
float Scale9Sprite::getInsetTop()
{
return this->_insetTop;
}
float Scale9Sprite::getInsetRight()
{
return this->_insetRight;
}
float Scale9Sprite::getInsetBottom()
{
return this->_insetBottom;
}
void Scale9Sprite::setInsetLeft(float insetLeft)
{
this->_insetLeft = insetLeft;
this->updateCapInset();
}
void Scale9Sprite::setInsetTop(float insetTop)
{
this->_insetTop = insetTop;
this->updateCapInset();
}
void Scale9Sprite::setInsetRight(float insetRight)
{
this->_insetRight = insetRight;
this->updateCapInset();
}
void Scale9Sprite::setInsetBottom(float insetBottom)
{
this->_insetBottom = insetBottom;
this->updateCapInset();
}
void Scale9Sprite::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
if(this->_positionsAreDirty)
{
this->updatePositions();
this->_positionsAreDirty = false;
}
Node::visit(renderer, parentTransform, parentFlags);
}
void Scale9Sprite::setColor(const Color3B& color)
{
2013-09-16 20:54:13 +08:00
if (!_scale9Image)
{
return;
}
Node::setColor(color);
for(auto child : _scale9Image->getChildren()){
child->setColor(color);
}
}
void Scale9Sprite::setOpacity(GLubyte opacity)
{
2013-09-16 20:54:13 +08:00
if (!_scale9Image)
{
return;
}
Node::setOpacity(opacity);
for(auto child : _scale9Image->getChildren()){
child->setOpacity(opacity);
}
}
void Scale9Sprite::updateDisplayedColor(const cocos2d::Color3B &parentColor)
{
2013-09-16 20:54:13 +08:00
if (!_scale9Image)
{
return;
}
Node::updateDisplayedColor(parentColor);
for(auto child : _scale9Image->getChildren()){
child->updateDisplayedColor(parentColor);
}
}
void Scale9Sprite::updateDisplayedOpacity(GLubyte parentOpacity)
{
2013-09-16 20:54:13 +08:00
if (!_scale9Image)
{
return;
}
Node::updateDisplayedOpacity(parentOpacity);
for(auto child : _scale9Image->getChildren()){
child->updateDisplayedOpacity(parentOpacity);
}
}
NS_CC_EXT_END