Merge pull request #4345 from dumganhar/develop

Don't deprecate callback functions in Layer.
This commit is contained in:
James Chen 2013-11-19 20:19:21 -08:00
commit 8f0063aa26
9 changed files with 35 additions and 26 deletions

View File

@ -86,21 +86,25 @@ public:
CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesEnded(Set *pTouches, Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesCancelled(Set *pTouches, Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
// Deprecated touch callbacks.There not have add CC_DEPRECATED_ATTRIBUTE because of menu still use these api
virtual bool onTouchBegan(Touch *touch, Event *unused_event);
/* Callback function should not be deprecated, it will generate lots of warnings.
Since 'setTouchEnabled' was deprecated, it will make warnings if developer overrides onTouchXXX and invokes setTouchEnabled(true) instead of using EventDispatcher::addEventListenerWithXXX.
*/
virtual bool onTouchBegan(Touch *touch, Event *unused_event);
virtual void onTouchMoved(Touch *touch, Event *unused_event);
virtual void onTouchEnded(Touch *touch, Event *unused_event);
virtual void onTouchCancelled(Touch *touch, Event *unused_event);
// Deprecated touch callbacks.
CC_DEPRECATED_ATTRIBUTE virtual void onTouchesBegan(const std::vector<Touch*>& touches, Event *unused_event);
CC_DEPRECATED_ATTRIBUTE virtual void onTouchesMoved(const std::vector<Touch*>& touches, Event *unused_event);
CC_DEPRECATED_ATTRIBUTE virtual void onTouchesEnded(const std::vector<Touch*>& touches, Event *unused_event);
CC_DEPRECATED_ATTRIBUTE virtual void onTouchesCancelled(const std::vector<Touch*>&touches, Event *unused_event);
virtual void onTouchesBegan(const std::vector<Touch*>& touches, Event *unused_event);
virtual void onTouchesMoved(const std::vector<Touch*>& touches, Event *unused_event);
virtual void onTouchesEnded(const std::vector<Touch*>& touches, Event *unused_event);
virtual void onTouchesCancelled(const std::vector<Touch*>&touches, Event *unused_event);
/** @deprecated Please override onAcceleration */
CC_DEPRECATED_ATTRIBUTE virtual void didAccelerate(Acceleration* accelerationValue) final {};
CC_DEPRECATED_ATTRIBUTE virtual void onAcceleration(Acceleration* acc, Event* unused_event);
/* Callback function should not be deprecated, it will generate lots of warnings.
Since 'setAccelerometerEnabled' was deprecated, it will make warnings if developer overrides onAcceleration and invokes setAccelerometerEnabled(true) instead of using EventDispatcher::addEventListenerWithXXX.
*/
virtual void onAcceleration(Acceleration* acc, Event* unused_event);
/** If isTouchEnabled, this method is called onEnter. Override it to change the
way Layer receives touch events.
@ -119,8 +123,8 @@ public:
Only the touches of this node will be affected. This "method" is not propagated to it's children.
@since v0.8.1
*/
CC_DEPRECATED_ATTRIBUTE virtual bool isTouchEnabled() const;
CC_DEPRECATED_ATTRIBUTE virtual void setTouchEnabled(bool value);
CC_DEPRECATED_ATTRIBUTE bool isTouchEnabled() const;
CC_DEPRECATED_ATTRIBUTE void setTouchEnabled(bool value);
CC_DEPRECATED_ATTRIBUTE virtual void setTouchMode(Touch::DispatchMode mode);
CC_DEPRECATED_ATTRIBUTE virtual Touch::DispatchMode getTouchMode() const;
@ -146,13 +150,16 @@ public:
CC_DEPRECATED_ATTRIBUTE virtual void setKeyboardEnabled(bool value);
/** Please use onKeyPressed instead. */
virtual void keyPressed(int keyCode) final {};
CC_DEPRECATED_ATTRIBUTE virtual void keyPressed(int keyCode) final {};
/** Please use onKeyReleased instead. */
virtual void keyReleased(int keyCode) final {};
CC_DEPRECATED_ATTRIBUTE virtual void keyReleased(int keyCode) final {};
CC_DEPRECATED_ATTRIBUTE virtual void onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event);
CC_DEPRECATED_ATTRIBUTE virtual void onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event);
/* Callback function should not be deprecated, it will generate lots of warnings.
Since 'setKeyboardEnabled' was deprecated, it will make warnings if developer overrides onKeyXXX and invokes setKeyboardEnabled(true) instead of using EventDispatcher::addEventListenerWithXXX.
*/
virtual void onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event);
virtual void onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event);
CC_DEPRECATED_ATTRIBUTE virtual bool isKeypadEnabled() const final { return _keyboardEnabled; }
CC_DEPRECATED_ATTRIBUTE virtual void setKeypadEnabled(bool value);
@ -160,9 +167,6 @@ public:
/** @deprecated Please override onKeyReleased and check the keycode of KeyboardEvent::KeyCode::Menu(KEY_BACKSPACE) instead. */
CC_DEPRECATED_ATTRIBUTE virtual void keyBackClicked() final {};
CC_DEPRECATED_ATTRIBUTE virtual void keyMenuClicked() final {};
//
// Overrides
//
protected:
bool _touchEnabled;

View File

@ -272,7 +272,7 @@ void UIPageView::updateChildrenSize()
}
cocos2d::Size selfSize = getSize();
for (unsigned int i=0; i<_pages->count(); i++)
for (long i=0; i<_pages->count(); i++)
{
UILayout* page = dynamic_cast<UILayout*>(_pages->getObjectAtIndex(i));
page->setSize(selfSize);

View File

@ -68,8 +68,6 @@ bool Control::init()
{
if (Layer::init())
{
//this->setTouchEnabled(true);
//_isTouchEnabled=true;
// Initialise instance variables
_state=Control::State::NORMAL;
setEnabled(true);

View File

@ -177,10 +177,16 @@ void ScrollView::resume(Object* sender)
_container->resume();
}
bool ScrollView::isTouchEnabled() const
{
return _touchListener != nullptr;
}
void ScrollView::setTouchEnabled(bool enabled)
{
_eventDispatcher->removeEventListener(_touchListener);
_touchListener = nullptr;
if (enabled)
{
_touchListener = EventListenerTouchOneByOne::create();

View File

@ -167,6 +167,7 @@ public:
void resume(Object* sender);
void setTouchEnabled(bool enabled);
bool isTouchEnabled() const;
bool isDragging() const {return _dragging;}
bool isTouchMoved() const { return _touchMoved; }
bool isBounceable() const { return _bounceable; }

View File

@ -15,7 +15,7 @@ public:
AccelerometerTest(void);
~AccelerometerTest(void);
virtual void onAcceleration(Acceleration* acc, Event* event);
void onAcceleration(Acceleration* acc, Event* event);
virtual std::string title();
virtual void onEnter();

View File

@ -10,8 +10,8 @@ public:
KeyboardTest();
~KeyboardTest();
virtual void onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event);
virtual void onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event);
void onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event);
void onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event);
private:
LabelTTF* _label;

View File

@ -10,7 +10,7 @@ public:
KeypadTest();
~KeypadTest();
virtual void onKeyReleased(EventKeyboard::KeyCode keycode, Event* event);
void onKeyReleased(EventKeyboard::KeyCode keycode, Event* event);
private:
LabelTTF* _label;

View File

@ -98,7 +98,7 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS
Scheduler::[pause resume unschedule schedule update isTargetPaused],
TextureCache::[addPVRTCImage],
Timer::[getSelector createWithScriptHandler],
*::[copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate],
*::[copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate onTouch.* onAcc.* onKey.* onRegisterTouchListener],
FileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$],
Application::[^application.* ^run$],
Camera::[getEyeXYZ getCenterXYZ getUpXYZ],