2013-09-13 22:20:20 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-10-16 16:48:39 +08:00
|
|
|
#include "gui/UIWidget.h"
|
|
|
|
#include "gui/UILayer.h"
|
2013-11-06 16:04:06 +08:00
|
|
|
#include "gui/UILayout.h"
|
2013-10-16 16:48:39 +08:00
|
|
|
#include "gui/UIHelper.h"
|
2013-09-13 22:20:20 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
namespace gui {
|
2013-09-13 22:20:20 +08:00
|
|
|
|
2013-09-16 15:32:52 +08:00
|
|
|
#define DYNAMIC_CAST_CCBLENDPROTOCOL dynamic_cast<cocos2d::BlendProtocol*>(_renderer)
|
2013-09-13 22:20:20 +08:00
|
|
|
|
2013-09-16 15:32:52 +08:00
|
|
|
#define DYNAMIC_CAST_CCRGBAPROTOCOL dynamic_cast<cocos2d::RGBAProtocol*>(_renderer)
|
2013-09-13 22:20:20 +08:00
|
|
|
|
2013-09-16 15:32:52 +08:00
|
|
|
#define DYNAMIC_CAST_CCNODERGBA dynamic_cast<GUIRenderer*>(_renderer)
|
2013-09-13 22:20:20 +08:00
|
|
|
|
|
|
|
UIWidget::UIWidget():
|
2013-09-16 15:32:52 +08:00
|
|
|
_enabled(true),
|
|
|
|
_visible(true),
|
|
|
|
_bright(true),
|
|
|
|
_touchEnabled(false),
|
|
|
|
_touchPassedEnabled(false),
|
|
|
|
_focus(false),
|
|
|
|
_widgetZOrder(0),
|
2013-11-06 16:04:06 +08:00
|
|
|
_anchorPoint(cocos2d::Point(0.5f, 0.5f)),
|
2013-09-16 15:32:52 +08:00
|
|
|
_widgetParent(NULL),
|
|
|
|
_brightStyle(BRIGHT_NONE),
|
|
|
|
_updateEnabled(false),
|
|
|
|
_renderer(NULL),
|
2013-11-06 16:04:06 +08:00
|
|
|
_touchStartPos(cocos2d::Point::ZERO),
|
|
|
|
_touchMovePos(cocos2d::Point::ZERO),
|
|
|
|
_touchEndPos(cocos2d::Point::ZERO),
|
2013-09-16 15:32:52 +08:00
|
|
|
_touchEventListener(NULL),
|
|
|
|
_touchEventSelector(NULL),
|
|
|
|
_widgetTag(-1),
|
|
|
|
_name("default"),
|
|
|
|
_widgetType(WidgetTypeWidget),
|
|
|
|
_actionTag(0),
|
2013-11-06 16:04:06 +08:00
|
|
|
_size(cocos2d::Size::ZERO),
|
|
|
|
_customSize(cocos2d::Size::ZERO),
|
|
|
|
_layoutParameterDictionary(NULL),
|
2013-09-16 15:32:52 +08:00
|
|
|
_ignoreSize(false),
|
|
|
|
_children(NULL),
|
|
|
|
_affectByClipping(false),
|
|
|
|
_scheduler(NULL),
|
|
|
|
_sizeType(SIZE_ABSOLUTE),
|
2013-11-06 16:04:06 +08:00
|
|
|
_sizePercent(cocos2d::Point::ZERO),
|
2013-09-16 15:32:52 +08:00
|
|
|
_positionType(POSITION_ABSOLUTE),
|
2013-11-06 16:04:06 +08:00
|
|
|
_positionPercent(cocos2d::Point::ZERO),
|
2013-11-08 14:58:20 +08:00
|
|
|
_isRunning(false),
|
|
|
|
_userObject(NULL)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIWidget::~UIWidget()
|
|
|
|
{
|
2013-11-07 16:46:41 +08:00
|
|
|
_touchEventListener = NULL;
|
|
|
|
_touchEventSelector = NULL;
|
|
|
|
removeAllChildren();
|
|
|
|
_children->release();
|
|
|
|
_renderer->removeAllChildrenWithCleanup(true);
|
|
|
|
_renderer->removeFromParentAndCleanup(true);
|
|
|
|
_renderer->release();
|
2013-09-13 22:20:20 +08:00
|
|
|
setParent(NULL);
|
2013-11-06 16:04:06 +08:00
|
|
|
_layoutParameterDictionary->removeAllObjects();
|
|
|
|
CC_SAFE_RELEASE(_layoutParameterDictionary);
|
2013-09-16 15:32:52 +08:00
|
|
|
CC_SAFE_RELEASE(_scheduler);
|
2013-11-08 14:58:20 +08:00
|
|
|
CC_SAFE_RELEASE(_userObject);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
UIWidget* UIWidget::create()
|
|
|
|
{
|
|
|
|
UIWidget* widget = new UIWidget();
|
|
|
|
if (widget && widget->init())
|
|
|
|
{
|
|
|
|
widget->autorelease();
|
|
|
|
return widget;
|
|
|
|
}
|
|
|
|
CC_SAFE_DELETE(widget);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UIWidget::init()
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
_children = cocos2d::Array::create();
|
2013-09-16 15:32:52 +08:00
|
|
|
_children->retain();
|
2013-11-06 16:04:06 +08:00
|
|
|
_layoutParameterDictionary = cocos2d::Dictionary::create();
|
|
|
|
CC_SAFE_RETAIN(_layoutParameterDictionary);
|
2013-09-13 22:20:20 +08:00
|
|
|
initRenderer();
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->retain();
|
|
|
|
_renderer->setZOrder(_widgetZOrder);
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::RGBAProtocol* renderRGBA = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
2013-09-13 22:20:20 +08:00
|
|
|
if (renderRGBA)
|
|
|
|
{
|
|
|
|
renderRGBA->setCascadeColorEnabled(true);
|
|
|
|
renderRGBA->setCascadeOpacityEnabled(true);
|
|
|
|
}
|
|
|
|
setBright(true);
|
|
|
|
ignoreContentAdaptWithSize(true);
|
2013-11-06 16:04:06 +08:00
|
|
|
_scheduler = cocos2d::Director::getInstance()->getScheduler();
|
2013-09-16 15:32:52 +08:00
|
|
|
CC_SAFE_RETAIN(_scheduler);
|
2013-09-13 22:20:20 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::onEnter()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
arrayMakeObjectsPerformSelector(_children, onEnter, UIWidget*);
|
|
|
|
_isRunning = true;
|
2013-09-13 22:20:20 +08:00
|
|
|
updateSizeAndPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::onExit()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_isRunning = false;
|
|
|
|
arrayMakeObjectsPerformSelector(_children, onExit, UIWidget*);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
2013-11-08 14:58:20 +08:00
|
|
|
|
|
|
|
void UIWidget::setUserObject(cocos2d::Object *pUserObject)
|
|
|
|
{
|
|
|
|
CC_SAFE_RETAIN(pUserObject);
|
|
|
|
CC_SAFE_RELEASE(_userObject);
|
|
|
|
_userObject = pUserObject;
|
|
|
|
}
|
2013-09-13 22:20:20 +08:00
|
|
|
|
|
|
|
bool UIWidget::addChild(UIWidget *child)
|
|
|
|
{
|
|
|
|
if (!child)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_children->containsObject(child))
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
child->setParent(this);
|
2013-09-16 15:32:52 +08:00
|
|
|
int childrenCount = _children->data->num;
|
2013-09-13 22:20:20 +08:00
|
|
|
if (childrenCount <= 0)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_children->addObject(child);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bool seekSucceed = false;
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::ccArray* arrayChildren = _children->data;
|
2013-09-13 22:20:20 +08:00
|
|
|
for (int i=childrenCount-1; i>=0; --i)
|
|
|
|
{
|
|
|
|
UIWidget* widget = (UIWidget*)(arrayChildren->arr[i]);
|
|
|
|
if (child->getZOrder() >= widget->getZOrder())
|
|
|
|
{
|
|
|
|
if (i == childrenCount-1)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_children->addObject(child);
|
2013-09-13 22:20:20 +08:00
|
|
|
seekSucceed = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_children->insertObject(child, i+1);
|
2013-09-13 22:20:20 +08:00
|
|
|
seekSucceed = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!seekSucceed)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_children->insertObject(child,0);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
child->getRenderer()->setZOrder(child->getZOrder());
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->addChild(child->getRenderer());
|
|
|
|
if (_isRunning)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
child->onEnter();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UIWidget::removeChild(UIWidget *child)
|
|
|
|
{
|
|
|
|
if (!child)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_children->containsObject(child))
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_isRunning)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
child->onExit();
|
|
|
|
}
|
2013-11-06 16:04:06 +08:00
|
|
|
child->setUpdateEnabled(false);
|
2013-09-13 22:20:20 +08:00
|
|
|
child->setParent(NULL);
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->removeChild(child->getRenderer());
|
|
|
|
_children->removeObject(child);
|
2013-09-13 22:20:20 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::removeFromParent()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_widgetParent)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_widgetParent->removeChild(this);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::removeAllChildren()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (!_children || _children->count() <= 0)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-09-16 15:32:52 +08:00
|
|
|
int times = _children->data->num;
|
2013-09-13 22:20:20 +08:00
|
|
|
for (int i=0; i<times; ++i)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
UIWidget* lastChild = (UIWidget*)(_children->getLastObject());
|
2013-09-13 22:20:20 +08:00
|
|
|
removeChild(lastChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::reorderChild(UIWidget* child)
|
|
|
|
{
|
|
|
|
CC_SAFE_RETAIN(child);
|
2013-09-16 15:32:52 +08:00
|
|
|
_children->removeObject(child);
|
|
|
|
int childrenCount = _children->data->num;
|
2013-09-13 22:20:20 +08:00
|
|
|
if (childrenCount <= 0)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_children->addObject(child);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bool seekSucceed = false;
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::ccArray* arrayChildren = _children->data;
|
2013-09-13 22:20:20 +08:00
|
|
|
for (int i=childrenCount-1; i>=0; --i)
|
|
|
|
{
|
|
|
|
UIWidget* widget = (UIWidget*)(arrayChildren->arr[i]);
|
|
|
|
if (child->getZOrder() >= widget->getZOrder())
|
|
|
|
{
|
|
|
|
if (i == childrenCount-1)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_children->addObject(child);
|
2013-09-13 22:20:20 +08:00
|
|
|
seekSucceed = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_children->insertObject(child, i+1);
|
2013-09-13 22:20:20 +08:00
|
|
|
seekSucceed = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!seekSucceed)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_children->insertObject(child,0);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CC_SAFE_RELEASE(child);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setEnabled(bool enabled)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_enabled = enabled;
|
2013-09-13 22:20:20 +08:00
|
|
|
GUIRenderer* renderer = DYNAMIC_CAST_CCNODERGBA;
|
|
|
|
if (renderer)
|
|
|
|
{
|
|
|
|
renderer->setEnabled(enabled);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
dynamic_cast<UIRectClippingNode*>(_renderer)->setEnabled(enabled);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::ccArray* arrayChildren = _children->data;
|
2013-09-13 22:20:20 +08:00
|
|
|
int childrenCount = arrayChildren->num;
|
|
|
|
for (int i = 0; i < childrenCount; i++)
|
|
|
|
{
|
|
|
|
UIWidget* child = dynamic_cast<UIWidget*>(arrayChildren->arr[i]);
|
|
|
|
child->setEnabled(enabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UIWidget* UIWidget::getChildByName(const char *name)
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
return UIHelper::seekWidgetByName(this, name);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
UIWidget* UIWidget::getChildByTag(int tag)
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
return UIHelper::seekWidgetByTag(this, tag);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::Array* UIWidget::getChildren()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _children;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::initRenderer()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer = GUIRenderer::create();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::setSize(const cocos2d::Size &size)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_customSize = size;
|
|
|
|
if (_ignoreSize)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_size = getContentSize();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_size = size;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_isRunning)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
_sizePercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(_customSize.width / _widgetParent->getSize().width, _customSize.height / _widgetParent->getSize().height);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
onSizeChanged();
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::setSizePercent(const cocos2d::Point &percent)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_sizePercent = percent;
|
2013-11-13 20:01:57 +08:00
|
|
|
cocos2d::Size cSize = _customSize;
|
|
|
|
if (_isRunning)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-11-13 20:01:57 +08:00
|
|
|
cSize = (_widgetParent == NULL) ? cocos2d::Size::ZERO : cocos2d::Size(_widgetParent->getSize().width * percent.x , _widgetParent->getSize().height * percent.y);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_ignoreSize)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_size = getContentSize();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_size = cSize;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
2013-09-16 15:32:52 +08:00
|
|
|
_customSize = cSize;
|
2013-09-13 22:20:20 +08:00
|
|
|
onSizeChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::updateSizeAndPosition()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
switch (_sizeType)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
case SIZE_ABSOLUTE:
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_ignoreSize)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_size = getContentSize();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_size = _customSize;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
2013-11-06 16:04:06 +08:00
|
|
|
_sizePercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(_customSize.width / _widgetParent->getSize().width, _customSize.height / _widgetParent->getSize().height);
|
2013-09-13 22:20:20 +08:00
|
|
|
break;
|
|
|
|
case SIZE_PERCENT:
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::Size cSize = (_widgetParent == NULL) ? cocos2d::Size::ZERO : cocos2d::Size(_widgetParent->getSize().width * _sizePercent.x , _widgetParent->getSize().height * _sizePercent.y);
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_ignoreSize)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_size = getContentSize();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_size = cSize;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
2013-09-16 15:32:52 +08:00
|
|
|
_customSize = cSize;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
onSizeChanged();
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::Point absPos = getPosition();
|
2013-09-16 15:32:52 +08:00
|
|
|
switch (_positionType)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
case POSITION_ABSOLUTE:
|
2013-11-06 16:04:06 +08:00
|
|
|
_positionPercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(absPos.x / _widgetParent->getSize().width, absPos.y / _widgetParent->getSize().height);
|
2013-09-13 22:20:20 +08:00
|
|
|
break;
|
|
|
|
case POSITION_PERCENT:
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::Size parentSize = _widgetParent->getSize();
|
|
|
|
absPos = cocos2d::Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->setPosition(absPos);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setSizeType(SizeType type)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_sizeType = type;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SizeType UIWidget::getSizeType() const
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _sizeType;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::ignoreContentAdaptWithSize(bool ignore)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_ignoreSize = ignore;
|
|
|
|
if (_ignoreSize)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::Size s = getContentSize();
|
2013-09-16 15:32:52 +08:00
|
|
|
_size = s;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_size = _customSize;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
onSizeChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UIWidget::isIgnoreContentAdaptWithSize() const
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _ignoreSize;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
const cocos2d::Size& UIWidget::getSize() const
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _size;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
const cocos2d::Point& UIWidget::getSizePercent() const
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _sizePercent;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::Point UIWidget::getWorldPosition()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
return _renderer->convertToWorldSpace(cocos2d::Point::ZERO);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::Point UIWidget::convertToWorldSpace(const cocos2d::Point& pt)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _renderer->convertToWorldSpace(pt);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::Node* UIWidget::getVirtualRenderer()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _renderer;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::onSizeChanged()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
const cocos2d::Size& UIWidget::getContentSize() const
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _size;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setZOrder(int z)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_widgetZOrder = z;
|
|
|
|
_renderer->setZOrder(z);
|
|
|
|
if (_widgetParent)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_widgetParent->reorderChild(this);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int UIWidget::getZOrder()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _widgetZOrder;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setTouchEnabled(bool enable)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_touchEnabled = enable;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool UIWidget::isTouchEnabled() const
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _touchEnabled;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setUpdateEnabled(bool enable)
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
if (enable == _updateEnabled)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-09-16 15:32:52 +08:00
|
|
|
_updateEnabled = enable;
|
2013-09-13 22:20:20 +08:00
|
|
|
if (enable)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_scheduler)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_scheduler->scheduleUpdateForTarget(this, 0, false);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_scheduler)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_scheduler->unscheduleUpdateForTarget(this);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UIWidget::isUpdateEnabled()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _updateEnabled;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool UIWidget::isFocused() const
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _focus;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setFocused(bool fucos)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (fucos == _focus)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-09-16 15:32:52 +08:00
|
|
|
_focus = fucos;
|
|
|
|
if (_bright)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_focus)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
setBrightStyle(BRIGHT_HIGHLIGHT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setBrightStyle(BRIGHT_NORMAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
onPressStateChangedToDisabled();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setBright(bool bright)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_bright = bright;
|
|
|
|
if (_bright)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_brightStyle = BRIGHT_NONE;
|
2013-09-13 22:20:20 +08:00
|
|
|
setBrightStyle(BRIGHT_NORMAL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
onPressStateChangedToDisabled();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setBrightStyle(BrightStyle style)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_brightStyle == style)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-09-16 15:32:52 +08:00
|
|
|
_brightStyle = style;
|
|
|
|
switch (_brightStyle)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
case BRIGHT_NORMAL:
|
|
|
|
onPressStateChangedToNormal();
|
|
|
|
break;
|
|
|
|
case BRIGHT_HIGHLIGHT:
|
|
|
|
onPressStateChangedToPressed();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::onPressStateChangedToNormal()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::onPressStateChangedToPressed()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::onPressStateChangedToDisabled()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::didNotSelectSelf()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
bool UIWidget::onTouchBegan(const cocos2d::Point &touchPoint)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
setFocused(true);
|
2013-09-16 15:32:52 +08:00
|
|
|
_touchStartPos.x = touchPoint.x;
|
|
|
|
_touchStartPos.y = touchPoint.y;
|
|
|
|
if (_widgetParent)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_widgetParent->checkChildInfo(0,this,touchPoint);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
pushDownEvent();
|
2013-09-16 15:32:52 +08:00
|
|
|
return _touchPassedEnabled;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::onTouchMoved(const cocos2d::Point &touchPoint)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_touchMovePos.x = touchPoint.x;
|
|
|
|
_touchMovePos.y = touchPoint.y;
|
2013-09-13 22:20:20 +08:00
|
|
|
setFocused(hitTest(touchPoint));
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_widgetParent)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_widgetParent->checkChildInfo(1,this,touchPoint);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
moveEvent();
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::onTouchEnded(const cocos2d::Point &touchPoint)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_touchEndPos.x = touchPoint.x;
|
|
|
|
_touchEndPos.y = touchPoint.y;
|
|
|
|
bool focus = _focus;
|
2013-09-13 22:20:20 +08:00
|
|
|
setFocused(false);
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_widgetParent)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_widgetParent->checkChildInfo(2,this,touchPoint);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
if (focus)
|
|
|
|
{
|
|
|
|
releaseUpEvent();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cancelUpEvent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::onTouchCancelled(const cocos2d::Point &touchPoint)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
setFocused(false);
|
|
|
|
cancelUpEvent();
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::onTouchLongClicked(const cocos2d::Point &touchPoint)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
longClickEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::pushDownEvent()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_touchEventListener && _touchEventSelector)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
(_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_BEGAN);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::moveEvent()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_touchEventListener && _touchEventSelector)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
(_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_MOVED);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::releaseUpEvent()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_touchEventListener && _touchEventSelector)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
(_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_ENDED);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::cancelUpEvent()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_touchEventListener && _touchEventSelector)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
(_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_CANCELED);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::longClickEvent()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::addTouchEventListener(cocos2d::Object *target, SEL_TouchEvent selector)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_touchEventListener = target;
|
|
|
|
_touchEventSelector = selector;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::Node* UIWidget::getRenderer()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _renderer;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::addRenderer(cocos2d::Node* renderer, int zOrder)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->addChild(renderer, zOrder);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::removeRenderer(cocos2d::Node* renderer, bool cleanup)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->removeChild(renderer,cleanup);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
bool UIWidget::hitTest(const cocos2d::Point &pt)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::Point nsp = _renderer->convertToNodeSpace(pt);
|
|
|
|
cocos2d::Rect bb = cocos2d::Rect(-_size.width * _anchorPoint.x, -_size.height * _anchorPoint.y, _size.width, _size.height);
|
2013-09-13 22:20:20 +08:00
|
|
|
if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
bool UIWidget::clippingParentAreaContainPoint(const cocos2d::Point &pt)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_affectByClipping = false;
|
2013-09-13 22:20:20 +08:00
|
|
|
UIWidget* parent = getParent();
|
|
|
|
UIWidget* clippingParent = NULL;
|
|
|
|
while (parent)
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
UILayout* layoutParent = dynamic_cast<UILayout*>(parent);
|
2013-09-13 22:20:20 +08:00
|
|
|
if (layoutParent)
|
|
|
|
{
|
|
|
|
if (layoutParent->isClippingEnabled())
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_affectByClipping = true;
|
2013-09-13 22:20:20 +08:00
|
|
|
clippingParent = layoutParent;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
parent = parent->getParent();
|
|
|
|
}
|
|
|
|
|
2013-09-16 15:32:52 +08:00
|
|
|
if (!_affectByClipping)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (clippingParent)
|
|
|
|
{
|
|
|
|
bool bRet = false;
|
|
|
|
if (clippingParent->hitTest(pt))
|
|
|
|
{
|
|
|
|
bRet = true;
|
|
|
|
}
|
|
|
|
if (bRet)
|
|
|
|
{
|
|
|
|
return clippingParent->clippingParentAreaContainPoint(pt);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::checkChildInfo(int handleState, UIWidget *sender, const cocos2d::Point &touchPoint)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_widgetParent)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_widgetParent->checkChildInfo(handleState,sender,touchPoint);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::setPosition(const cocos2d::Point &pos)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (_isRunning)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
_positionPercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(pos.x / _widgetParent->getSize().width, pos.y / _widgetParent->getSize().height);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->setPosition(pos);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::setPositionPercent(const cocos2d::Point &percent)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_positionPercent = percent;
|
|
|
|
if (_isRunning)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::Size parentSize = _widgetParent->getSize();
|
|
|
|
cocos2d::Point absPos = cocos2d::Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y);
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->setPosition(absPos);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::setAnchorPoint(const cocos2d::Point &pt)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_anchorPoint = pt;
|
|
|
|
_renderer->setAnchorPoint(pt);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::updateAnchorPoint()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
setAnchorPoint(_anchorPoint);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
const cocos2d::Point& UIWidget::getPosition()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _renderer->getPosition();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
const cocos2d::Point& UIWidget::getPositionPercent()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _positionPercent;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setPositionType(PositionType type)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_positionType = type;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
PositionType UIWidget::getPositionType() const
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _positionType;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
const cocos2d::Point& UIWidget::getAnchorPoint()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _anchorPoint;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setScale(float scale)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->setScale(scale);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float UIWidget::getScale()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _renderer->getScale();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setScaleX(float scaleX)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->setScaleX(scaleX);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float UIWidget::getScaleX()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _renderer->getScaleX();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setScaleY(float scaleY)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->setScaleY(scaleY);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float UIWidget::getScaleY()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _renderer->getScaleY();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setRotation(float rotation)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->setRotation(rotation);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float UIWidget::getRotation()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _renderer->getRotation();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setRotationX(float rotationX)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->setRotationX(rotationX);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float UIWidget::getRotationX()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _renderer->getRotationX();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setRotationY(float rotationY)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->setRotationY(rotationY);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float UIWidget::getRotationY()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _renderer->getRotationY();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setVisible(bool visible)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_visible = visible;
|
|
|
|
_renderer->setVisible(visible);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool UIWidget::isVisible() const
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _visible;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool UIWidget::isBright() const
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _bright;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool UIWidget::isEnabled() const
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _enabled;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float UIWidget::getLeftInParent()
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
return getPosition().x - getAnchorPoint().x * _size.width;;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float UIWidget::getBottomInParent()
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
return getPosition().y - getAnchorPoint().y * _size.height;;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float UIWidget::getRightInParent()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return getLeftInParent() + _size.width;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float UIWidget::getTopInParent()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return getBottomInParent() + _size.height;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
UIWidget* UIWidget::getParent()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _widgetParent;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setParent(UIWidget* parent)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_widgetParent = parent;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::Action* UIWidget::runAction(cocos2d::Action *action)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _renderer->runAction(action);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::setActionManager(cocos2d::ActionManager *actionManager)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->setActionManager(actionManager);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::ActionManager* UIWidget::getActionManager()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _renderer->getActionManager();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::stopAllActions()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->stopAllActions();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::stopAction(cocos2d::Action *action)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->stopAction(action);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::stopActionByTag(int tag)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_renderer->stopActionByTag(tag);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::Action* UIWidget::getActionByTag(int tag)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _renderer->getActionByTag(tag);
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::setColor(const cocos2d::Color3B &color)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
2013-09-13 22:20:20 +08:00
|
|
|
if (rgbap)
|
|
|
|
{
|
|
|
|
rgbap->setColor(color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
const cocos2d::Color3B& UIWidget::getColor()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
2013-09-13 22:20:20 +08:00
|
|
|
if (rgbap)
|
|
|
|
{
|
|
|
|
return rgbap->getColor();
|
|
|
|
}
|
2013-11-06 16:04:06 +08:00
|
|
|
return cocos2d::Color3B::WHITE;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setOpacity(int opacity)
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
2013-09-13 22:20:20 +08:00
|
|
|
if (rgbap)
|
|
|
|
{
|
|
|
|
rgbap->setOpacity(opacity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int UIWidget::getOpacity()
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
2013-09-13 22:20:20 +08:00
|
|
|
if (rgbap)
|
|
|
|
{
|
|
|
|
return rgbap->getOpacity();
|
|
|
|
}
|
|
|
|
return 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UIWidget::isCascadeOpacityEnabled()
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
2013-09-13 22:20:20 +08:00
|
|
|
if (rgbap)
|
|
|
|
{
|
|
|
|
return rgbap->isCascadeOpacityEnabled();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
2013-09-13 22:20:20 +08:00
|
|
|
if (rgbap)
|
|
|
|
{
|
|
|
|
rgbap->setCascadeOpacityEnabled(cascadeOpacityEnabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UIWidget::isCascadeColorEnabled()
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
2013-09-13 22:20:20 +08:00
|
|
|
if (rgbap)
|
|
|
|
{
|
|
|
|
return rgbap->isCascadeColorEnabled();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setCascadeColorEnabled(bool cascadeColorEnabled)
|
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
2013-09-13 22:20:20 +08:00
|
|
|
if (rgbap)
|
|
|
|
{
|
|
|
|
rgbap->setCascadeColorEnabled(cascadeColorEnabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::setBlendFunc(cocos2d::BlendFunc blendFunc)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::BlendProtocol * blendNode = DYNAMIC_CAST_CCBLENDPROTOCOL;
|
2013-09-13 22:20:20 +08:00
|
|
|
if (blendNode)
|
|
|
|
{
|
|
|
|
blendNode->setBlendFunc(blendFunc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
const cocos2d::Point& UIWidget::getTouchStartPos()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _touchStartPos;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
const cocos2d::Point& UIWidget::getTouchMovePos()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _touchMovePos;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
const cocos2d::Point& UIWidget::getTouchEndPos()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _touchEndPos;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setTag(int tag)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_widgetTag = tag;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int UIWidget::getTag() const
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _widgetTag;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::setName(const char* name)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_name = name;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* UIWidget::getName() const
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _name.c_str();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
WidgetType UIWidget::getWidgetType() const
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _widgetType;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
void UIWidget::setLayoutParameter(UILayoutParameter *parameter)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-11-13 20:01:57 +08:00
|
|
|
if (!parameter)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-11-06 16:04:06 +08:00
|
|
|
_layoutParameterDictionary->setObject(parameter, parameter->getLayoutType());
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
UILayoutParameter* UIWidget::getLayoutParameter(LayoutParameterType type)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-11-06 16:04:06 +08:00
|
|
|
return dynamic_cast<UILayoutParameter*>(_layoutParameterDictionary->objectForKey(type));
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-09-17 17:59:20 +08:00
|
|
|
const char* UIWidget::getDescription() const
|
|
|
|
{
|
|
|
|
return "Widget";
|
|
|
|
}
|
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
UIWidget* UIWidget::clone()
|
|
|
|
{
|
|
|
|
UIWidget* clonedWidget = createCloneInstance();
|
|
|
|
clonedWidget->copyProperties(this);
|
|
|
|
clonedWidget->copyClonedWidgetChildren(this);
|
|
|
|
return clonedWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
UIWidget* UIWidget::createCloneInstance()
|
|
|
|
{
|
|
|
|
return UIWidget::create();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::copyClonedWidgetChildren(UIWidget* model)
|
|
|
|
{
|
|
|
|
cocos2d::ccArray* arrayWidgetChildren = model->getChildren()->data;
|
|
|
|
int length = arrayWidgetChildren->num;
|
|
|
|
for (int i=0; i<length; i++)
|
|
|
|
{
|
|
|
|
UIWidget* child = (UIWidget*)(arrayWidgetChildren->arr[i]);
|
|
|
|
addChild(child->clone());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::copySpecialProperties(UIWidget* model)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIWidget::copyProperties(UIWidget *widget)
|
|
|
|
{
|
|
|
|
setEnabled(widget->isEnabled());
|
|
|
|
setVisible(widget->isVisible());
|
|
|
|
setBright(widget->isBright());
|
|
|
|
setTouchEnabled(widget->isTouchEnabled());
|
|
|
|
_touchPassedEnabled = false;
|
|
|
|
setZOrder(widget->getZOrder());
|
|
|
|
setUpdateEnabled(widget->isUpdateEnabled());
|
|
|
|
setTag(widget->getTag());
|
|
|
|
setName(widget->getName());
|
|
|
|
setActionTag(widget->getActionTag());
|
|
|
|
_ignoreSize = widget->_ignoreSize;
|
|
|
|
_size = widget->_size;
|
|
|
|
_customSize = widget->_customSize;
|
|
|
|
copySpecialProperties(widget);
|
|
|
|
_sizeType = widget->getSizeType();
|
|
|
|
_sizePercent = widget->_sizePercent;
|
|
|
|
_positionType = widget->_positionType;
|
|
|
|
_positionPercent = widget->_positionPercent;
|
|
|
|
setPosition(widget->getPosition());
|
|
|
|
setAnchorPoint(widget->getAnchorPoint());
|
|
|
|
setScaleX(widget->getScaleX());
|
|
|
|
setScaleY(widget->getScaleY());
|
|
|
|
setRotation(widget->getRotation());
|
|
|
|
setRotationX(widget->getRotationX());
|
|
|
|
setRotationY(widget->getRotationY());
|
|
|
|
setFlipX(widget->isFlipX());
|
|
|
|
setFlipY(widget->isFlipY());
|
|
|
|
setColor(widget->getColor());
|
|
|
|
setOpacity(widget->getOpacity());
|
|
|
|
setCascadeOpacityEnabled(widget->isCascadeOpacityEnabled());
|
|
|
|
setCascadeColorEnabled(widget->isCascadeColorEnabled());
|
|
|
|
onSizeChanged();
|
|
|
|
}
|
|
|
|
|
2013-09-13 22:20:20 +08:00
|
|
|
/*temp action*/
|
|
|
|
void UIWidget::setActionTag(int tag)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_actionTag = tag;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int UIWidget::getActionTag()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _actionTag;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GUIRenderer::GUIRenderer():
|
2013-09-16 15:32:52 +08:00
|
|
|
_enabled(true)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
GUIRenderer::~GUIRenderer()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
GUIRenderer* GUIRenderer::create()
|
|
|
|
{
|
|
|
|
GUIRenderer* renderer = new GUIRenderer();
|
|
|
|
if (renderer && renderer->init())
|
|
|
|
{
|
|
|
|
renderer->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(renderer);
|
|
|
|
}
|
|
|
|
return renderer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUIRenderer::setEnabled(bool enabled)
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
_enabled = enabled;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GUIRenderer::isEnabled() const
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
return _enabled;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUIRenderer::visit()
|
|
|
|
{
|
2013-09-16 15:32:52 +08:00
|
|
|
if (!_enabled)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-11-06 16:04:06 +08:00
|
|
|
cocos2d::NodeRGBA::visit();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
2013-11-06 16:04:06 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
}
|