mirror of https://github.com/axmolengine/axmol.git
Removing unused files. Old XXXDispatcher.
This commit is contained in:
parent
480b2dd1d8
commit
664345a673
|
@ -1,83 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010 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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCKEYBOARD_DISPATCHER_H__
|
||||
#define __CCKEYBOARD_DISPATCHER_H__
|
||||
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include "cocoa/CCArray.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
/**
|
||||
* @addtogroup input
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef std::function<void(int)> KeyboardDelegate;
|
||||
|
||||
/**
|
||||
@class KeyboardDispatcher
|
||||
@brief Dispatch the keypad message from the phone
|
||||
*/
|
||||
class CC_DLL KeyboardDispatcher : public Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
KeyboardDispatcher();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~KeyboardDispatcher();
|
||||
|
||||
/**
|
||||
@brief set delagate to key press event
|
||||
*/
|
||||
void setKeyPressDelegate(KeyboardDelegate delegate);
|
||||
/**
|
||||
@brief set delagate to key release event
|
||||
*/
|
||||
void setKeyReleaseDelegate(KeyboardDelegate delegate);
|
||||
|
||||
/**
|
||||
@brief dispatch the key stroke event
|
||||
*/
|
||||
bool dispatchKeyboardEvent(int keyCode, bool pressed);
|
||||
|
||||
protected:
|
||||
|
||||
KeyboardDelegate _keyPressDelegate;
|
||||
KeyboardDelegate _keyReleaseDelegate;
|
||||
};
|
||||
|
||||
// end of input group
|
||||
/// @}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif //__CCKEYBOARD_DISPATCHER_H__
|
|
@ -1,102 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010 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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCKEYPAD_DELEGATE_H__
|
||||
#define __CCKEYPAD_DELEGATE_H__
|
||||
|
||||
|
||||
#include "cocoa/CCObject.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
/**
|
||||
* @addtogroup input
|
||||
* @{
|
||||
*/
|
||||
|
||||
class CC_DLL KeypadDelegate
|
||||
{
|
||||
public:
|
||||
/** The back key clicked
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
|
||||
virtual void keyBackClicked() {}
|
||||
|
||||
/** The menu key clicked. only available on wophone & android
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void keyMenuClicked() {};
|
||||
};
|
||||
|
||||
/**
|
||||
@brief
|
||||
KeypadHandler
|
||||
Object than contains the KeypadDelegate.
|
||||
*/
|
||||
class CC_DLL KeypadHandler : public Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~KeypadHandler(void);
|
||||
|
||||
/** delegate
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
KeypadDelegate* getDelegate();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setDelegate(KeypadDelegate *pDelegate);
|
||||
|
||||
/** initializes a KeypadHandler with a delegate
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual bool initWithDelegate(KeypadDelegate *pDelegate);
|
||||
|
||||
public:
|
||||
/** allocates a KeypadHandler with a delegate
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static KeypadHandler* handlerWithDelegate(KeypadDelegate *pDelegate);
|
||||
|
||||
protected:
|
||||
KeypadDelegate* _delegate;
|
||||
};
|
||||
|
||||
// end of input group
|
||||
/// @}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __CCKEYPAD_DELEGATE_H__
|
|
@ -1,103 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010 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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCKEYPAD_DISPATCHER_H__
|
||||
#define __CCKEYPAD_DISPATCHER_H__
|
||||
|
||||
#include "CCKeypadDelegate.h"
|
||||
#include "cocoa/CCArray.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
/**
|
||||
* @addtogroup input
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
// the back key clicked msg
|
||||
kTypeBackClicked = 1,
|
||||
kTypeMenuClicked,
|
||||
} ccKeypadMSGType;
|
||||
|
||||
struct _ccCArray;
|
||||
/**
|
||||
@class KeypadDispatcher
|
||||
@brief Dispatch the keypad message from the phone
|
||||
*/
|
||||
class CC_DLL KeypadDispatcher : public Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
KeypadDispatcher();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~KeypadDispatcher();
|
||||
|
||||
/**
|
||||
@brief add delegate to concern keypad msg
|
||||
*/
|
||||
void addDelegate(KeypadDelegate* pDelegate);
|
||||
|
||||
/**
|
||||
@brief remove the delegate from the delegates who concern keypad msg
|
||||
*/
|
||||
void removeDelegate(KeypadDelegate* pDelegate);
|
||||
|
||||
/**
|
||||
@brief force add the delegate
|
||||
*/
|
||||
void forceAddDelegate(KeypadDelegate* pDelegate);
|
||||
|
||||
/**
|
||||
@brief force remove the delegate
|
||||
*/
|
||||
void forceRemoveDelegate(KeypadDelegate* pDelegate);
|
||||
|
||||
/**
|
||||
@brief dispatch the key pad msg
|
||||
*/
|
||||
bool dispatchKeypadMSG(ccKeypadMSGType nMsgType);
|
||||
|
||||
protected:
|
||||
|
||||
Array* _delegates;
|
||||
bool _locked;
|
||||
bool _toAdd;
|
||||
bool _toRemove;
|
||||
|
||||
struct _ccCArray *_handlersToAdd;
|
||||
struct _ccCArray *_handlersToRemove;
|
||||
};
|
||||
|
||||
// end of input group
|
||||
/// @}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif //__CCKEYPAD_DISPATCHER_H__
|
|
@ -1,179 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2012 cocos2d-x.org
|
||||
Copyright (c) 2009 Valentin Milea
|
||||
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __TOUCH_DISPATHCHER_CCTOUCH_DELEGATE_PROTOCOL_H__
|
||||
#define __TOUCH_DISPATHCHER_CCTOUCH_DELEGATE_PROTOCOL_H__
|
||||
|
||||
#include "cocoa/CCObject.h"
|
||||
#include "ccConfig.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class Touch;
|
||||
class Event;
|
||||
class Set;
|
||||
class TouchDispatcher;
|
||||
|
||||
/**
|
||||
* @addtogroup input
|
||||
* @{
|
||||
*/
|
||||
|
||||
class CC_DLL TouchDelegate
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
TouchDelegate() {}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TouchDelegate()
|
||||
{
|
||||
}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent); return false;};
|
||||
// optional
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void ccTouchMoved(Touch *pTouch, Event *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void ccTouchEnded(Touch *pTouch, Event *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void ccTouchCancelled(Touch *pTouch, Event *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
|
||||
|
||||
// optional
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void ccTouchesBegan(Set *pTouches, Event *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void ccTouchesMoved(Set *pTouches, Event *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void ccTouchesEnded(Set *pTouches, Event *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void ccTouchesCancelled(Set *pTouches, Event *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
|
||||
|
||||
};
|
||||
/**
|
||||
@brief
|
||||
Using this type of delegate results in two benefits:
|
||||
- 1. You don't need to deal with Sets, the dispatcher does the job of splitting
|
||||
them. You get exactly one UITouch per call.
|
||||
- 2. You can *claim* a UITouch by returning true in ccTouchBegan. Updates of claimed
|
||||
touches are sent only to the delegate(s) that claimed them. So if you get a move/
|
||||
ended/canceled update you're sure it's your touch. This frees you from doing a
|
||||
lot of checks when doing multi-touch.
|
||||
|
||||
(The name TargetedTouchDelegate relates to updates "targeting" their specific
|
||||
handler, without bothering the other handlers.)
|
||||
@since v0.8
|
||||
*/
|
||||
class CC_DLL TargetedTouchDelegate : public TouchDelegate
|
||||
{
|
||||
public:
|
||||
/** Return true to claim the touch.
|
||||
@since v0
|
||||
*/
|
||||
virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent) { CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);return false;};
|
||||
|
||||
// optional
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void ccTouchMoved(Touch *pTouch, Event *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void ccTouchEnded(Touch *pTouch, Event *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void ccTouchCancelled(Touch *pTouch, Event *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
|
||||
};
|
||||
|
||||
/** @brief
|
||||
This type of delegate is the same one used by CocoaTouch. You will receive all the events (Began,Moved,Ended,Canceled).
|
||||
@since v0.8
|
||||
*/
|
||||
class CC_DLL StandardTouchDelegate : public TouchDelegate
|
||||
{
|
||||
public:
|
||||
// optional
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void ccTouchesBegan(Set *pTouches, Event *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void ccTouchesMoved(Set *pTouches, Event *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void ccTouchesEnded(Set *pTouches, Event *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void ccTouchesCancelled(Set *pTouches, Event *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
|
||||
};
|
||||
|
||||
// end of input group
|
||||
/// @}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __TOUCH_DISPATHCHER_CCTOUCH_DELEGATE_PROTOCOL_H__
|
|
@ -1,237 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2012 cocos2d-x.org
|
||||
Copyright (c) 2009 Valentin Milea
|
||||
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __TOUCH_DISPATCHER_CCTOUCH_DISPATCHER_H__
|
||||
#define __TOUCH_DISPATCHER_CCTOUCH_DISPATCHER_H__
|
||||
|
||||
#include "CCTouchDelegateProtocol.h"
|
||||
#include "cocoa/CCObject.h"
|
||||
#include "cocoa/CCArray.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
/**
|
||||
* @addtogroup input
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
enum {
|
||||
CCTOUCHBEGAN,
|
||||
CCTOUCHMOVED,
|
||||
CCTOUCHENDED,
|
||||
CCTOUCHCANCELLED,
|
||||
|
||||
ccTouchMax,
|
||||
};
|
||||
|
||||
class Set;
|
||||
class Event;
|
||||
|
||||
struct ccTouchHandlerHelperData {
|
||||
// we only use the type
|
||||
// void (StandardTouchDelegate::*touchesSel)(Set*, Event*);
|
||||
// void (TargetedTouchDelegate::*touchSel)(NSTouch*, Event*);
|
||||
int _type;
|
||||
};
|
||||
|
||||
|
||||
class CC_DLL EGLTouchDelegate
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void touchesBegan(Set* touches, Event* pEvent) = 0;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void touchesMoved(Set* touches, Event* pEvent) = 0;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void touchesEnded(Set* touches, Event* pEvent) = 0;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void touchesCancelled(Set* touches, Event* pEvent) = 0;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~EGLTouchDelegate() {}
|
||||
};
|
||||
|
||||
class TouchHandler;
|
||||
struct _ccCArray;
|
||||
/** @brief TouchDispatcher.
|
||||
Singleton that handles all the touch events.
|
||||
The dispatcher dispatches events to the registered TouchHandlers.
|
||||
There are 2 different type of touch handlers:
|
||||
- Standard Touch Handlers
|
||||
- Targeted Touch Handlers
|
||||
|
||||
The Standard Touch Handlers work like the CocoaTouch touch handler: a set of touches is passed to the delegate.
|
||||
On the other hand, the Targeted Touch Handlers only receive 1 touch at the time, and they can "swallow" touches (avoid the propagation of the event).
|
||||
|
||||
Firstly, the dispatcher sends the received touches to the targeted touches.
|
||||
These touches can be swallowed by the Targeted Touch Handlers. If there are still remaining touches, then the remaining touches will be sent
|
||||
to the Standard Touch Handlers.
|
||||
|
||||
@since v0.8.0
|
||||
*/
|
||||
class CC_DLL TouchDispatcher : public Object, public EGLTouchDelegate
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~TouchDispatcher();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool init(void);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
TouchDispatcher()
|
||||
: _targetedHandlers(NULL)
|
||||
, _standardHandlers(NULL)
|
||||
, _handlersToAdd(NULL)
|
||||
, _handlersToRemove(NULL)
|
||||
|
||||
{}
|
||||
|
||||
public:
|
||||
/** Whether or not the events are going to be dispatched. Default: true
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool isDispatchEvents(void);
|
||||
void setDispatchEvents(bool bDispatchEvents);
|
||||
|
||||
/** Adds a standard touch delegate to the dispatcher's list.
|
||||
See StandardTouchDelegate description.
|
||||
IMPORTANT: The delegate will be retained.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void addStandardDelegate(TouchDelegate *pDelegate, int nPriority);
|
||||
|
||||
/** Adds a targeted touch delegate to the dispatcher's list.
|
||||
See TargetedTouchDelegate description.
|
||||
IMPORTANT: The delegate will be retained.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void addTargetedDelegate(TouchDelegate *pDelegate, int nPriority, bool bSwallowsTouches);
|
||||
|
||||
/** Removes a touch delegate.
|
||||
The delegate will be released
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void removeDelegate(TouchDelegate *pDelegate);
|
||||
|
||||
/** Removes all touch delegates, releasing all the delegates
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void removeAllDelegates(void);
|
||||
|
||||
/** Changes the priority of a previously added delegate. The lower the number,
|
||||
the higher the priority
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setPriority(int nPriority, TouchDelegate *pDelegate);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void touches(Set *pTouches, Event *pEvent, unsigned int uIndex);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void touchesBegan(Set* touches, Event* pEvent);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void touchesMoved(Set* touches, Event* pEvent);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void touchesEnded(Set* touches, Event* pEvent);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void touchesCancelled(Set* touches, Event* pEvent);
|
||||
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
TouchHandler* findHandler(TouchDelegate *pDelegate);
|
||||
protected:
|
||||
void forceRemoveDelegate(TouchDelegate *pDelegate);
|
||||
void forceAddHandler(TouchHandler *pHandler, Array* pArray);
|
||||
void forceRemoveAllDelegates(void);
|
||||
void rearrangeHandlers(Array* pArray);
|
||||
TouchHandler* findHandler(Array* pArray, TouchDelegate *pDelegate);
|
||||
|
||||
protected:
|
||||
Array* _targetedHandlers;
|
||||
Array* _standardHandlers;
|
||||
|
||||
bool _locked;
|
||||
bool _toAdd;
|
||||
bool _toRemove;
|
||||
Array* _handlersToAdd;
|
||||
struct _ccCArray *_handlersToRemove;
|
||||
bool _toQuit;
|
||||
bool _dispatchEvents;
|
||||
|
||||
// 4, 1 for each type of event
|
||||
struct ccTouchHandlerHelperData _handlerHelperData[ccTouchMax];
|
||||
};
|
||||
|
||||
// end of input group
|
||||
/// @}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __TOUCH_DISPATCHER_CCTOUCH_DISPATCHER_H__
|
|
@ -1,138 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2012 cocos2d-x.org
|
||||
Copyright (c) 2009 Valentin Milea
|
||||
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __TOUCH_DISPATCHER_CCTOUCH_HANDLER_H__
|
||||
#define __TOUCH_DISPATCHER_CCTOUCH_HANDLER_H__
|
||||
|
||||
#include "CCTouchDelegateProtocol.h"
|
||||
#include "CCTouchDispatcher.h"
|
||||
#include "cocoa/CCObject.h"
|
||||
#include "cocoa/CCSet.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
/**
|
||||
* @addtogroup input
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
TouchHandler
|
||||
Object than contains the delegate and priority of the event handler.
|
||||
*/
|
||||
class CC_DLL TouchHandler : public Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TouchHandler(void);
|
||||
|
||||
/** delegate
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
TouchDelegate* getDelegate();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setDelegate(TouchDelegate *pDelegate);
|
||||
|
||||
/** priority */
|
||||
int getPriority(void);
|
||||
void setPriority(int nPriority);
|
||||
|
||||
/** enabled selectors */
|
||||
int getEnabledSelectors(void);
|
||||
void setEnalbedSelectors(int nValue);
|
||||
|
||||
/** initializes a TouchHandler with a delegate and a priority */
|
||||
bool initWithDelegate(TouchDelegate *pDelegate, int nPriority);
|
||||
|
||||
public:
|
||||
/** allocates a TouchHandler with a delegate and a priority */
|
||||
static TouchHandler* handlerWithDelegate(TouchDelegate *pDelegate, int nPriority);
|
||||
|
||||
protected:
|
||||
TouchDelegate *_delegate;
|
||||
int _priority;
|
||||
int _enabledSelectors;
|
||||
};
|
||||
|
||||
/** StandardTouchHandler
|
||||
It forwards each event to the delegate.
|
||||
*/
|
||||
class CC_DLL StandardTouchHandler : public TouchHandler
|
||||
{
|
||||
public:
|
||||
/** initializes a TouchHandler with a delegate and a priority */
|
||||
bool initWithDelegate(TouchDelegate *pDelegate, int nPriority);
|
||||
|
||||
public:
|
||||
/** allocates a TouchHandler with a delegate and a priority */
|
||||
static StandardTouchHandler* handlerWithDelegate(TouchDelegate *pDelegate, int nPriority);
|
||||
};
|
||||
|
||||
/**
|
||||
TargetedTouchHandler
|
||||
Object than contains the claimed touches and if it swallows touches.
|
||||
Used internally by TouchDispatcher
|
||||
*/
|
||||
class CC_DLL TargetedTouchHandler : public TouchHandler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~TargetedTouchHandler(void);
|
||||
|
||||
/** whether or not the touches are swallowed */
|
||||
bool isSwallowsTouches(void);
|
||||
void setSwallowsTouches(bool bSwallowsTouches);
|
||||
|
||||
/** MutableSet that contains the claimed touches */
|
||||
Set* getClaimedTouches(void);
|
||||
|
||||
/** initializes a TargetedTouchHandler with a delegate, a priority and whether or not it swallows touches or not */
|
||||
bool initWithDelegate(TouchDelegate *pDelegate, int nPriority, bool bSwallow);
|
||||
|
||||
public:
|
||||
/** allocates a TargetedTouchHandler with a delegate, a priority and whether or not it swallows touches or not */
|
||||
static TargetedTouchHandler* handlerWithDelegate(TouchDelegate *pDelegate, int nPriority, bool bSwallow);
|
||||
|
||||
protected:
|
||||
bool _swallowsTouches;
|
||||
Set *_claimedTouches;
|
||||
};
|
||||
|
||||
// end of input group
|
||||
/// @}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __TOUCH_DISPATCHER_CCTOUCH_HANDLER_H__
|
Loading…
Reference in New Issue