2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
2012-09-24 21:22:20 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2012-04-19 14:35:52 +08:00
|
|
|
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"
|
2012-06-19 13:50:11 +08:00
|
|
|
#include "cocoa/CCObject.h"
|
|
|
|
#include "cocoa/CCSet.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup input
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
TouchHandler
|
2012-04-19 14:35:52 +08:00
|
|
|
Object than contains the delegate and priority of the event handler.
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL TouchHandler : public Object
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual ~TouchHandler(void);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** delegate */
|
2013-06-20 14:13:12 +08:00
|
|
|
TouchDelegate* getDelegate();
|
|
|
|
void setDelegate(TouchDelegate *pDelegate);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** 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 */
|
2013-07-17 16:25:13 +08:00
|
|
|
bool initWithDelegate(TouchDelegate *pDelegate, int nPriority);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** allocates a TouchHandler with a delegate and a priority */
|
2013-06-20 14:13:12 +08:00
|
|
|
static TouchHandler* handlerWithDelegate(TouchDelegate *pDelegate, int nPriority);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2013-06-20 14:13:12 +08:00
|
|
|
TouchDelegate *_delegate;
|
2013-06-15 14:03:30 +08:00
|
|
|
int _priority;
|
|
|
|
int _enabledSelectors;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** StandardTouchHandler
|
2012-09-17 15:02:24 +08:00
|
|
|
It forwards each event to the delegate.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL StandardTouchHandler : public TouchHandler
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes a TouchHandler with a delegate and a priority */
|
2013-07-17 16:25:13 +08:00
|
|
|
bool initWithDelegate(TouchDelegate *pDelegate, int nPriority);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** allocates a TouchHandler with a delegate and a priority */
|
2013-06-20 14:13:12 +08:00
|
|
|
static StandardTouchHandler* handlerWithDelegate(TouchDelegate *pDelegate, int nPriority);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
TargetedTouchHandler
|
2012-09-17 15:02:24 +08:00
|
|
|
Object than contains the claimed touches and if it swallows touches.
|
2012-04-19 14:35:52 +08:00
|
|
|
Used internally by TouchDispatcher
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL TargetedTouchHandler : public TouchHandler
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:13:12 +08:00
|
|
|
~TargetedTouchHandler(void);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** whether or not the touches are swallowed */
|
|
|
|
bool isSwallowsTouches(void);
|
|
|
|
void setSwallowsTouches(bool bSwallowsTouches);
|
|
|
|
|
|
|
|
/** MutableSet that contains the claimed touches */
|
2013-06-20 14:13:12 +08:00
|
|
|
Set* getClaimedTouches(void);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** initializes a TargetedTouchHandler with a delegate, a priority and whether or not it swallows touches or not */
|
2013-06-20 14:13:12 +08:00
|
|
|
bool initWithDelegate(TouchDelegate *pDelegate, int nPriority, bool bSwallow);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** allocates a TargetedTouchHandler with a delegate, a priority and whether or not it swallows touches or not */
|
2013-06-20 14:13:12 +08:00
|
|
|
static TargetedTouchHandler* handlerWithDelegate(TouchDelegate *pDelegate, int nPriority, bool bSwallow);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _swallowsTouches;
|
2013-06-20 14:13:12 +08:00
|
|
|
Set *_claimedTouches;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
// end of input group
|
|
|
|
/// @}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif // __TOUCH_DISPATCHER_CCTOUCH_HANDLER_H__
|