mirror of https://github.com/axmolengine/axmol.git
issue 2430:use enum class for Control enum values
This commit is contained in:
parent
0b8de88ddc
commit
f55d73194e
|
@ -1 +1 @@
|
|||
a30cd2dad1df734bd988309d3b344ff946601cb4
|
||||
b803d542a8eac86722010a38dd782612565198b7
|
|
@ -25,7 +25,7 @@ class CCBSelectorResolver {
|
|||
virtual ~CCBSelectorResolver() {};
|
||||
virtual SEL_MenuHandler onResolveCCBCCMenuItemSelector(Object * pTarget, const char* pSelectorName) = 0;
|
||||
virtual SEL_CallFuncN onResolveCCBCCCallFuncSelector(Object * pTarget, const char* pSelectorName) { return NULL; };
|
||||
virtual SEL_CCControlHandler onResolveCCBCCControlSelector(Object * pTarget, const char* pSelectorName) = 0;
|
||||
virtual Control::Handler onResolveCCBCCControlSelector(Object * pTarget, const char* pSelectorName) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -32,11 +32,11 @@ void ControlButtonLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, co
|
|||
|
||||
void ControlButtonLoader::onHandlePropTypeString(Node * pNode, Node * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_TITLE_NORMAL) == 0) {
|
||||
((ControlButton *)pNode)->setTitleForState(String::create(pString), ControlStateNormal);
|
||||
((ControlButton *)pNode)->setTitleForState(String::create(pString), Control::State::NORMAL);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLE_HIGHLIGHTED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleForState(String::create(pString), ControlStateHighlighted);
|
||||
((ControlButton *)pNode)->setTitleForState(String::create(pString), Control::State::HIGH_LIGHTED);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLE_DISABLED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleForState(String::create(pString), ControlStateDisabled);
|
||||
((ControlButton *)pNode)->setTitleForState(String::create(pString), Control::State::DISABLED);
|
||||
} else {
|
||||
ControlLoader::onHandlePropTypeString(pNode, pParent, pPropertyName, pString, pCCBReader);
|
||||
}
|
||||
|
@ -44,11 +44,11 @@ void ControlButtonLoader::onHandlePropTypeString(Node * pNode, Node * pParent, c
|
|||
|
||||
void ControlButtonLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_TITLETTF_NORMAL) == 0) {
|
||||
((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, ControlStateNormal);
|
||||
((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, Control::State::NORMAL);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLETTF_HIGHLIGHTED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, ControlStateHighlighted);
|
||||
((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, Control::State::HIGH_LIGHTED);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLETTF_DISABLED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, ControlStateDisabled);
|
||||
((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, Control::State::DISABLED);
|
||||
} else {
|
||||
ControlLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader);
|
||||
}
|
||||
|
@ -56,11 +56,11 @@ void ControlButtonLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent,
|
|||
|
||||
void ControlButtonLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_NORMAL) == 0) {
|
||||
((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, ControlStateNormal);
|
||||
((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, Control::State::NORMAL);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_HIGHLIGHTED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, ControlStateHighlighted);
|
||||
((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, Control::State::HIGH_LIGHTED);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_DISABLED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, ControlStateDisabled);
|
||||
((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, Control::State::DISABLED);
|
||||
} else {
|
||||
ControlLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader);
|
||||
}
|
||||
|
@ -85,15 +85,15 @@ void ControlButtonLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, con
|
|||
void ControlButtonLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * pCCBReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) {
|
||||
if(pSpriteFrame != NULL) {
|
||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, ControlStateNormal);
|
||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::NORMAL);
|
||||
}
|
||||
} else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) {
|
||||
if(pSpriteFrame != NULL) {
|
||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, ControlStateHighlighted);
|
||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::HIGH_LIGHTED);
|
||||
}
|
||||
} else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) {
|
||||
if(pSpriteFrame != NULL) {
|
||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, ControlStateDisabled);
|
||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::DISABLED);
|
||||
}
|
||||
} else {
|
||||
ControlLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pSpriteFrame, pCCBReader);
|
||||
|
@ -102,11 +102,11 @@ void ControlButtonLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pPare
|
|||
|
||||
void ControlButtonLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_NORMAL) == 0) {
|
||||
((ControlButton *)pNode)->setTitleColorForState(pColor3B, ControlStateNormal);
|
||||
((ControlButton *)pNode)->setTitleColorForState(pColor3B, Control::State::NORMAL);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_HIGHLIGHTED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleColorForState(pColor3B, ControlStateHighlighted);
|
||||
((ControlButton *)pNode)->setTitleColorForState(pColor3B, Control::State::HIGH_LIGHTED);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_DISABLED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleColorForState(pColor3B, ControlStateDisabled);
|
||||
((ControlButton *)pNode)->setTitleColorForState(pColor3B, Control::State::DISABLED);
|
||||
} else {
|
||||
ControlLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, pCCBReader);
|
||||
}
|
||||
|
|
|
@ -811,7 +811,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
|
|||
|
||||
if(target != NULL) {
|
||||
if(selectorName.length() > 0) {
|
||||
SEL_CCControlHandler selControlHandler = 0;
|
||||
Control::Handler selControlHandler = 0;
|
||||
|
||||
CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target);
|
||||
|
||||
|
@ -832,7 +832,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
|
|||
blockControlData->mSELControlHandler = selControlHandler;
|
||||
|
||||
blockControlData->mTarget = target;
|
||||
blockControlData->mControlEvents = controlEvents;
|
||||
blockControlData->mControlEvents = (Control::EventType)controlEvents;
|
||||
|
||||
return blockControlData;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "cocos2d.h"
|
||||
#include "CCBReader.h"
|
||||
#include "CCBValue.h"
|
||||
#include "../GUI/CCControlExtension/CCControl.h"
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
|
@ -35,9 +36,9 @@ struct BlockData {
|
|||
};
|
||||
|
||||
struct BlockControlData {
|
||||
SEL_CCControlHandler mSELControlHandler;
|
||||
Control::Handler mSELControlHandler;
|
||||
Object * mTarget;
|
||||
int mControlEvents;
|
||||
Control::EventType mControlEvents;
|
||||
};
|
||||
|
||||
/* Forward declaration. */
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/****************************************************************************
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
#include "cocos-ext.h"
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
const Control::EventType CCControlEventTouchDown = Control::EventType::TOUCH_DOWN;
|
||||
const Control::EventType CCControlEventTouchDragInside = Control::EventType::DRAG_INSIDE;
|
||||
const Control::EventType CCControlEventTouchDragOutside = Control::EventType::DRAG_OUTSIDE;
|
||||
const Control::EventType CCControlEventTouchDragEnter = Control::EventType::DRAG_ENTER;
|
||||
const Control::EventType CCControlEventTouchDragExit = Control::EventType::DRAG_EXIT;
|
||||
const Control::EventType CCControlEventTouchUpInside = Control::EventType::TOUCH_UP_INSIDE;
|
||||
const Control::EventType CCControlEventTouchUpOutside = Control::EventType::TOUCH_UP_OUTSIDE;
|
||||
const Control::EventType CCControlEventTouchCancel = Control::EventType::TOUCH_CANCEL;
|
||||
const Control::EventType CCControlEventValueChanged = Control::EventType::VALUE_CHANGED;
|
||||
|
||||
const Control::State CCControlStateNormal = Control::State::NORMAL;
|
||||
const Control::State CCControlStateHighlighted = Control::State::HIGH_LIGHTED;
|
||||
const Control::State CCControlStateDisabled = Control::State::DISABLED;
|
||||
const Control::State CCControlStateSelected = Control::State::SELECTED;
|
||||
|
||||
NS_CC_EXT_END
|
|
@ -120,8 +120,6 @@ CC_DEPRECATED_ATTRIBUTE typedef RegionAttachment CCRegionAttachment;
|
|||
CC_DEPRECATED_ATTRIBUTE typedef ScrollViewDirection CCScrollViewDirection;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef TableViewVerticalFillOrder CCTableViewVerticalFillOrder;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ControlStepperPart CCControlStepperPart;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ControlEvent CCControlEvent;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ControlState CCControlState;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef NodeLoaderMap CCNodeLoaderMap;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef NodeLoaderMapEntry CCNodeLoaderMapEntry;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef EventRegistry CCEventRegistry;
|
||||
|
@ -151,20 +149,26 @@ CC_DEPRECATED_ATTRIBUTE typedef AttachmentType CCAttachmentType;
|
|||
#define kCCControlStepperPartPlus kControlStepperPartPlus
|
||||
#define kCCControlStepperPartNone kControlStepperPartNone
|
||||
|
||||
#define CCControlEventTouchDown ControlEventTouchDown
|
||||
#define CCControlEventTouchDragInside ControlEventTouchDragInside
|
||||
#define CCControlEventTouchDragOutside ControlEventTouchDragOutside
|
||||
#define CCControlEventTouchDragEnter ControlEventTouchDragEnter
|
||||
#define CCControlEventTouchDragExit ControlEventTouchDragExit
|
||||
#define CCControlEventTouchUpInside ControlEventTouchUpInside
|
||||
#define CCControlEventTouchUpOutside ControlEventTouchUpOutside
|
||||
#define CCControlEventTouchCancel ControlEventTouchCancel
|
||||
#define CCControlEventValueChanged ControlEventValueChanged
|
||||
|
||||
#define CCControlStateNormal ControlStateNormal
|
||||
#define CCControlStateHighlighted ControlStateHighlighted
|
||||
#define CCControlStateDisabled ControlStateDisabled
|
||||
#define CCControlStateSelected ControlStateSelected
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDown;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDragInside;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDragOutside;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDragEnter;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDragExit;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchUpInside;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchUpOutside;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchCancel;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventValueChanged;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Control::EventType CCControlEvent;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Control::State CCControlStateNormal;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Control::State CCControlStateHighlighted;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Control::State CCControlStateDisabled;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Control::State CCControlStateSelected;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Control::State CCControlState;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Control::Handler SEL_CCControlHandler;
|
||||
|
||||
|
||||
#define kCCCreateFile kCreateFile
|
||||
#define kCCNetwork kNetwork
|
||||
|
|
|
@ -32,12 +32,13 @@
|
|||
#include "touch_dispatcher/CCTouchDispatcher.h"
|
||||
#include "menu_nodes/CCMenu.h"
|
||||
#include "touch_dispatcher/CCTouch.h"
|
||||
#include "CCInvocation.h"
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
Control::Control()
|
||||
: _isOpacityModifyRGB(false)
|
||||
, _state(ControlStateNormal)
|
||||
, _state(State::NORMAL)
|
||||
, _hasVisibleParents(false)
|
||||
, _enabled(false)
|
||||
, _selected(false)
|
||||
|
@ -69,7 +70,7 @@ bool Control::init()
|
|||
//this->setTouchEnabled(true);
|
||||
//_isTouchEnabled=true;
|
||||
// Initialise instance variables
|
||||
_state=ControlStateNormal;
|
||||
_state=Control::State::NORMAL;
|
||||
setEnabled(true);
|
||||
setSelected(false);
|
||||
setHighlighted(false);
|
||||
|
@ -108,17 +109,17 @@ void Control::onExit()
|
|||
Layer::onExit();
|
||||
}
|
||||
|
||||
void Control::sendActionsForControlEvents(ControlEvent controlEvents)
|
||||
void Control::sendActionsForControlEvents(EventType controlEvents)
|
||||
{
|
||||
// For each control events
|
||||
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||
{
|
||||
// If the given controlEvents bitmask contains the curent event
|
||||
if ((controlEvents & (1 << i)))
|
||||
if (((int)controlEvents & (1 << i)))
|
||||
{
|
||||
// Call invocations
|
||||
// <Invocation*>
|
||||
Array* invocationList = this->dispatchListforControlEvent(1<<i);
|
||||
Array* invocationList = this->dispatchListforControlEvent((Control::EventType)(1<<i));
|
||||
Object* pObj = NULL;
|
||||
CCARRAY_FOREACH(invocationList, pObj)
|
||||
{
|
||||
|
@ -135,15 +136,15 @@ void Control::sendActionsForControlEvents(ControlEvent controlEvents)
|
|||
}
|
||||
}
|
||||
}
|
||||
void Control::addTargetWithActionForControlEvents(Object* target, SEL_CCControlHandler action, ControlEvent controlEvents)
|
||||
void Control::addTargetWithActionForControlEvents(Object* target, Handler action, EventType controlEvents)
|
||||
{
|
||||
// For each control events
|
||||
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||
{
|
||||
// If the given controlEvents bitmask contains the curent event
|
||||
if ((controlEvents & (1 << i)))
|
||||
if (((int)controlEvents & (1 << i)))
|
||||
{
|
||||
this->addTargetWithActionForControlEvent(target, action, 1<<i);
|
||||
this->addTargetWithActionForControlEvent(target, action, (EventType)(1<<i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +164,7 @@ void Control::addTargetWithActionForControlEvents(Object* target, SEL_CCControlH
|
|||
* @param controlEvent A control event for which the action message is sent.
|
||||
* See "CCControlEvent" for constants.
|
||||
*/
|
||||
void Control::addTargetWithActionForControlEvent(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent)
|
||||
void Control::addTargetWithActionForControlEvent(Object* target, Handler action, EventType controlEvent)
|
||||
{
|
||||
// Create the invocation object
|
||||
Invocation *invocation = Invocation::create(target, action, controlEvent);
|
||||
|
@ -173,20 +174,20 @@ void Control::addTargetWithActionForControlEvent(Object* target, SEL_CCControlHa
|
|||
eventInvocationList->addObject(invocation);
|
||||
}
|
||||
|
||||
void Control::removeTargetWithActionForControlEvents(Object* target, SEL_CCControlHandler action, ControlEvent controlEvents)
|
||||
void Control::removeTargetWithActionForControlEvents(Object* target, Handler action, EventType controlEvents)
|
||||
{
|
||||
// For each control events
|
||||
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||
{
|
||||
// If the given controlEvents bitmask contains the curent event
|
||||
if ((controlEvents & (1 << i)))
|
||||
if (((int)controlEvents & (1 << i)))
|
||||
{
|
||||
this->removeTargetWithActionForControlEvent(target, action, 1 << i);
|
||||
this->removeTargetWithActionForControlEvent(target, action, (EventType)(1 << i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Control::removeTargetWithActionForControlEvent(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent)
|
||||
void Control::removeTargetWithActionForControlEvent(Object* target, Handler action, EventType controlEvent)
|
||||
{
|
||||
// Retrieve all invocations for the given control event
|
||||
//<Invocation*>
|
||||
|
@ -264,15 +265,15 @@ bool Control::isTouchInside(Touch* touch)
|
|||
return bBox.containsPoint(touchLocation);
|
||||
}
|
||||
|
||||
Array* Control::dispatchListforControlEvent(ControlEvent controlEvent)
|
||||
Array* Control::dispatchListforControlEvent(EventType controlEvent)
|
||||
{
|
||||
Array* invocationList = (Array*)_dispatchTable->objectForKey(controlEvent);
|
||||
Array* invocationList = (Array*)_dispatchTable->objectForKey((int)controlEvent);
|
||||
|
||||
// If the invocation list does not exist for the dispatch table, we create it
|
||||
if (invocationList == NULL)
|
||||
{
|
||||
invocationList = Array::createWithCapacity(1);
|
||||
_dispatchTable->setObject(invocationList, controlEvent);
|
||||
_dispatchTable->setObject(invocationList, (int)controlEvent);
|
||||
}
|
||||
return invocationList;
|
||||
}
|
||||
|
@ -285,9 +286,9 @@ void Control::setEnabled(bool bEnabled)
|
|||
{
|
||||
_enabled = bEnabled;
|
||||
if(_enabled) {
|
||||
_state = ControlStateNormal;
|
||||
_state = Control::State::NORMAL;
|
||||
} else {
|
||||
_state = ControlStateDisabled;
|
||||
_state = Control::State::DISABLED;
|
||||
}
|
||||
|
||||
this->needsLayout();
|
||||
|
|
|
@ -30,12 +30,13 @@
|
|||
#ifndef __CCCONTROL_H__
|
||||
#define __CCCONTROL_H__
|
||||
|
||||
#include "CCInvocation.h"
|
||||
#include "CCControlUtils.h"
|
||||
#include "cocos2d.h"
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
|
||||
|
||||
class Invocation;
|
||||
|
||||
/**
|
||||
|
@ -48,30 +49,6 @@ class Invocation;
|
|||
/** Number of kinds of control event. */
|
||||
#define kControlEventTotalNumber 9
|
||||
|
||||
/** Kinds of possible events for the control objects. */
|
||||
enum
|
||||
{
|
||||
ControlEventTouchDown = 1 << 0, // A touch-down event in the control.
|
||||
ControlEventTouchDragInside = 1 << 1, // An event where a finger is dragged inside the bounds of the control.
|
||||
ControlEventTouchDragOutside = 1 << 2, // An event where a finger is dragged just outside the bounds of the control.
|
||||
ControlEventTouchDragEnter = 1 << 3, // An event where a finger is dragged into the bounds of the control.
|
||||
ControlEventTouchDragExit = 1 << 4, // An event where a finger is dragged from within a control to outside its bounds.
|
||||
ControlEventTouchUpInside = 1 << 5, // A touch-up event in the control where the finger is inside the bounds of the control.
|
||||
ControlEventTouchUpOutside = 1 << 6, // A touch-up event in the control where the finger is outside the bounds of the control.
|
||||
ControlEventTouchCancel = 1 << 7, // A system event canceling the current touches for the control.
|
||||
ControlEventValueChanged = 1 << 8 // A touch dragging or otherwise manipulating a control, causing it to emit a series of different values.
|
||||
};
|
||||
typedef unsigned int ControlEvent;
|
||||
|
||||
/** The possible state for a control. */
|
||||
enum
|
||||
{
|
||||
ControlStateNormal = 1 << 0, // The normal, or default state of a control¡ªthat is, enabled but neither selected nor highlighted.
|
||||
ControlStateHighlighted = 1 << 1, // Highlighted state of a control. A control enters this state when a touch down, drag inside or drag enter is performed. You can retrieve and set this value through the highlighted property.
|
||||
ControlStateDisabled = 1 << 2, // Disabled state of a control. This state indicates that the control is currently disabled. You can retrieve and set this value through the enabled property.
|
||||
ControlStateSelected = 1 << 3 // Selected state of a control. This state indicates that the control is currently selected. You can retrieve and set this value through the selected property.
|
||||
};
|
||||
typedef unsigned int ControlState;
|
||||
|
||||
/*
|
||||
* @class
|
||||
|
@ -88,6 +65,31 @@ typedef unsigned int ControlState;
|
|||
class Control : public LayerRGBA
|
||||
{
|
||||
public:
|
||||
/** Kinds of possible events for the control objects. */
|
||||
enum class EventType
|
||||
{
|
||||
TOUCH_DOWN = 1 << 0, // A touch-down event in the control.
|
||||
DRAG_INSIDE = 1 << 1, // An event where a finger is dragged inside the bounds of the control.
|
||||
DRAG_OUTSIDE = 1 << 2, // An event where a finger is dragged just outside the bounds of the control.
|
||||
DRAG_ENTER = 1 << 3, // An event where a finger is dragged into the bounds of the control.
|
||||
DRAG_EXIT = 1 << 4, // An event where a finger is dragged from within a control to outside its bounds.
|
||||
TOUCH_UP_INSIDE = 1 << 5, // A touch-up event in the control where the finger is inside the bounds of the control.
|
||||
TOUCH_UP_OUTSIDE = 1 << 6, // A touch-up event in the control where the finger is outside the bounds of the control.
|
||||
TOUCH_CANCEL = 1 << 7, // A system event canceling the current touches for the control.
|
||||
VALUE_CHANGED = 1 << 8 // A touch dragging or otherwise manipulating a control, causing it to emit a series of different values.
|
||||
};
|
||||
|
||||
typedef void (Object::*Handler)(Object*, EventType);
|
||||
|
||||
/** The possible state for a control. */
|
||||
enum class State
|
||||
{
|
||||
NORMAL = 1 << 0, // The normal, or default state of a control¡ªthat is, enabled but neither selected nor highlighted.
|
||||
HIGH_LIGHTED = 1 << 1, // Highlighted state of a control. A control enters this state when a touch down, drag inside or drag enter is performed. You can retrieve and set this value through the highlighted property.
|
||||
DISABLED = 1 << 2, // Disabled state of a control. This state indicates that the control is currently disabled. You can retrieve and set this value through the enabled property.
|
||||
SELECTED = 1 << 3 // Selected state of a control. This state indicates that the control is currently selected. You can retrieve and set this value through the selected property.
|
||||
};
|
||||
|
||||
static Control* create();
|
||||
|
||||
Control();
|
||||
|
@ -118,7 +120,7 @@ public:
|
|||
* @param controlEvents A bitmask whose set flags specify the control events for
|
||||
* which action messages are sent. See "CCControlEvent" for bitmask constants.
|
||||
*/
|
||||
virtual void sendActionsForControlEvents(ControlEvent controlEvents);
|
||||
virtual void sendActionsForControlEvents(EventType controlEvents);
|
||||
|
||||
/**
|
||||
* Adds a target and action for a particular event (or events) to an internal
|
||||
|
@ -133,7 +135,7 @@ public:
|
|||
* @param controlEvents A bitmask specifying the control events for which the
|
||||
* action message is sent. See "CCControlEvent" for bitmask constants.
|
||||
*/
|
||||
virtual void addTargetWithActionForControlEvents(Object* target, SEL_CCControlHandler action, ControlEvent controlEvents);
|
||||
virtual void addTargetWithActionForControlEvents(Object* target, Handler action, EventType controlEvents);
|
||||
|
||||
/**
|
||||
* Removes a target and action for a particular event (or events) from an
|
||||
|
@ -147,7 +149,7 @@ public:
|
|||
* @param controlEvents A bitmask specifying the control events associated with
|
||||
* target and action. See "CCControlEvent" for bitmask constants.
|
||||
*/
|
||||
virtual void removeTargetWithActionForControlEvents(Object* target, SEL_CCControlHandler action, ControlEvent controlEvents);
|
||||
virtual void removeTargetWithActionForControlEvents(Object* target, Handler action, EventType controlEvents);
|
||||
|
||||
/**
|
||||
* Returns a point corresponding to the touh location converted into the
|
||||
|
@ -187,7 +189,7 @@ protected:
|
|||
* @return an Invocation object able to construct messages using a given
|
||||
* target-action pair.
|
||||
*/
|
||||
Invocation* invocationWithTargetAndActionForControlEvent(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent);
|
||||
Invocation* invocationWithTargetAndActionForControlEvent(Object* target, Handler action, EventType controlEvent);
|
||||
|
||||
/**
|
||||
* Returns the Invocation list for the given control event. If the list does
|
||||
|
@ -199,7 +201,7 @@ protected:
|
|||
* @return the Invocation list for the given control event.
|
||||
*/
|
||||
//<Invocation*>
|
||||
Array* dispatchListforControlEvent(ControlEvent controlEvent);
|
||||
Array* dispatchListforControlEvent(EventType controlEvent);
|
||||
|
||||
/**
|
||||
* Adds a target and action for a particular event to an internal dispatch
|
||||
|
@ -214,7 +216,7 @@ protected:
|
|||
* @param controlEvent A control event for which the action message is sent.
|
||||
* See "CCControlEvent" for constants.
|
||||
*/
|
||||
void addTargetWithActionForControlEvent(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent);
|
||||
void addTargetWithActionForControlEvent(Object* target, Handler action, EventType controlEvent);
|
||||
|
||||
/**
|
||||
* Removes a target and action for a particular event from an internal dispatch
|
||||
|
@ -228,7 +230,7 @@ protected:
|
|||
* @param controlEvent A control event for which the action message is sent.
|
||||
* See "CCControlEvent" for constants.
|
||||
*/
|
||||
void removeTargetWithActionForControlEvent(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent);
|
||||
void removeTargetWithActionForControlEvent(Object* target, Handler action, EventType controlEvent);
|
||||
|
||||
protected:
|
||||
bool _enabled;
|
||||
|
@ -249,7 +251,7 @@ protected:
|
|||
bool _isOpacityModifyRGB;
|
||||
|
||||
/** The current control state constant. */
|
||||
CC_SYNTHESIZE_READONLY(ControlState, _state, State);
|
||||
CC_SYNTHESIZE_READONLY(State, _state, State);
|
||||
};
|
||||
|
||||
// end of GUI group
|
||||
|
|
|
@ -125,10 +125,10 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b
|
|||
|
||||
String* tempString = String::create(label->getString());
|
||||
//tempString->autorelease();
|
||||
setTitleForState(tempString, ControlStateNormal);
|
||||
setTitleColorForState(rgbaLabel->getColor(), ControlStateNormal);
|
||||
setTitleLabelForState(node, ControlStateNormal);
|
||||
setBackgroundSpriteForState(backgroundSprite, ControlStateNormal);
|
||||
setTitleForState(tempString, Control::State::NORMAL);
|
||||
setTitleColorForState(rgbaLabel->getColor(), Control::State::NORMAL);
|
||||
setTitleLabelForState(node, Control::State::NORMAL);
|
||||
setBackgroundSpriteForState(backgroundSprite, Control::State::NORMAL);
|
||||
|
||||
setLabelAnchorPoint(Point(0.5f, 0.5f));
|
||||
|
||||
|
@ -204,11 +204,11 @@ void ControlButton::setHighlighted(bool enabled)
|
|||
{
|
||||
if (enabled == true)
|
||||
{
|
||||
_state = ControlStateHighlighted;
|
||||
_state = Control::State::HIGH_LIGHTED;
|
||||
}
|
||||
else
|
||||
{
|
||||
_state = ControlStateNormal;
|
||||
_state = Control::State::NORMAL;
|
||||
}
|
||||
|
||||
Control::setHighlighted(enabled);
|
||||
|
@ -289,27 +289,27 @@ void ControlButton::setLabelAnchorPoint(Point labelAnchorPoint)
|
|||
}
|
||||
}
|
||||
|
||||
String* ControlButton::getTitleForState(ControlState state)
|
||||
String* ControlButton::getTitleForState(State state)
|
||||
{
|
||||
if (_titleDispatchTable != NULL)
|
||||
{
|
||||
String* title=(String*)_titleDispatchTable->objectForKey(state);
|
||||
String* title=(String*)_titleDispatchTable->objectForKey((int)state);
|
||||
if (title)
|
||||
{
|
||||
return title;
|
||||
}
|
||||
return (String*)_titleDispatchTable->objectForKey(ControlStateNormal);
|
||||
return (String*)_titleDispatchTable->objectForKey((int)Control::State::NORMAL);
|
||||
}
|
||||
return String::create("");
|
||||
}
|
||||
|
||||
void ControlButton::setTitleForState(String* title, ControlState state)
|
||||
void ControlButton::setTitleForState(String* title, State state)
|
||||
{
|
||||
_titleDispatchTable->removeObjectForKey(state);
|
||||
_titleDispatchTable->removeObjectForKey((int)state);
|
||||
|
||||
if (title)
|
||||
{
|
||||
_titleDispatchTable->setObject(title, state);
|
||||
_titleDispatchTable->setObject(title, (int)state);
|
||||
}
|
||||
|
||||
// If the current state if equal to the given state we update the layout
|
||||
|
@ -320,20 +320,20 @@ void ControlButton::setTitleForState(String* title, ControlState state)
|
|||
}
|
||||
|
||||
|
||||
Color3B ControlButton::getTitleColorForState(ControlState state) const
|
||||
Color3B ControlButton::getTitleColorForState(State state) const
|
||||
{
|
||||
Color3B returnColor = Color3B::WHITE;
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(NULL == _titleColorDispatchTable);
|
||||
Color3bObject* colorObject=(Color3bObject*)_titleColorDispatchTable->objectForKey(state);
|
||||
Color3bObject* colorObject=(Color3bObject*)_titleColorDispatchTable->objectForKey((int)state);
|
||||
if (colorObject)
|
||||
{
|
||||
returnColor = colorObject->value;
|
||||
break;
|
||||
}
|
||||
|
||||
colorObject = (Color3bObject*)_titleColorDispatchTable->objectForKey(ControlStateNormal);
|
||||
colorObject = (Color3bObject*)_titleColorDispatchTable->objectForKey((int)Control::State::NORMAL);
|
||||
if (colorObject)
|
||||
{
|
||||
returnColor = colorObject->value;
|
||||
|
@ -343,13 +343,13 @@ Color3B ControlButton::getTitleColorForState(ControlState state) const
|
|||
return returnColor;
|
||||
}
|
||||
|
||||
void ControlButton::setTitleColorForState(Color3B color, ControlState state)
|
||||
void ControlButton::setTitleColorForState(Color3B color, State state)
|
||||
{
|
||||
//Color3B* colorValue=&color;
|
||||
_titleColorDispatchTable->removeObjectForKey(state);
|
||||
_titleColorDispatchTable->removeObjectForKey((int)state);
|
||||
Color3bObject* pColor3bObject = new Color3bObject(color);
|
||||
pColor3bObject->autorelease();
|
||||
_titleColorDispatchTable->setObject(pColor3bObject, state);
|
||||
_titleColorDispatchTable->setObject(pColor3bObject, (int)state);
|
||||
|
||||
// If the current state if equal to the given state we update the layout
|
||||
if (getState() == state)
|
||||
|
@ -358,26 +358,26 @@ void ControlButton::setTitleColorForState(Color3B color, ControlState state)
|
|||
}
|
||||
}
|
||||
|
||||
Node* ControlButton::getTitleLabelForState(ControlState state)
|
||||
Node* ControlButton::getTitleLabelForState(State state)
|
||||
{
|
||||
Node* titleLabel = (Node*)_titleLabelDispatchTable->objectForKey(state);
|
||||
Node* titleLabel = (Node*)_titleLabelDispatchTable->objectForKey((int)state);
|
||||
if (titleLabel)
|
||||
{
|
||||
return titleLabel;
|
||||
}
|
||||
return (Node*)_titleLabelDispatchTable->objectForKey(ControlStateNormal);
|
||||
return (Node*)_titleLabelDispatchTable->objectForKey((int)Control::State::NORMAL);
|
||||
}
|
||||
|
||||
void ControlButton::setTitleLabelForState(Node* titleLabel, ControlState state)
|
||||
void ControlButton::setTitleLabelForState(Node* titleLabel, State state)
|
||||
{
|
||||
Node* previousLabel = (Node*)_titleLabelDispatchTable->objectForKey(state);
|
||||
Node* previousLabel = (Node*)_titleLabelDispatchTable->objectForKey((int)state);
|
||||
if (previousLabel)
|
||||
{
|
||||
removeChild(previousLabel, true);
|
||||
_titleLabelDispatchTable->removeObjectForKey(state);
|
||||
_titleLabelDispatchTable->removeObjectForKey((int)state);
|
||||
}
|
||||
|
||||
_titleLabelDispatchTable->setObject(titleLabel, state);
|
||||
_titleLabelDispatchTable->setObject(titleLabel, (int)state);
|
||||
titleLabel->setVisible(false);
|
||||
titleLabel->setAnchorPoint(Point(0.5f, 0.5f));
|
||||
addChild(titleLabel, 1);
|
||||
|
@ -389,7 +389,7 @@ void ControlButton::setTitleLabelForState(Node* titleLabel, ControlState state)
|
|||
}
|
||||
}
|
||||
|
||||
void ControlButton::setTitleTTFForState(const char * fntFile, ControlState state)
|
||||
void ControlButton::setTitleTTFForState(const char * fntFile, State state)
|
||||
{
|
||||
String * title = this->getTitleForState(state);
|
||||
if (!title)
|
||||
|
@ -399,7 +399,7 @@ void ControlButton::setTitleTTFForState(const char * fntFile, ControlState state
|
|||
this->setTitleLabelForState(LabelTTF::create(title->getCString(), fntFile, 12), state);
|
||||
}
|
||||
|
||||
const char * ControlButton::getTitleTTFForState(ControlState state)
|
||||
const char * ControlButton::getTitleTTFForState(State state)
|
||||
{
|
||||
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
|
||||
LabelTTF* labelTTF = dynamic_cast<LabelTTF*>(label);
|
||||
|
@ -413,7 +413,7 @@ const char * ControlButton::getTitleTTFForState(ControlState state)
|
|||
}
|
||||
}
|
||||
|
||||
void ControlButton::setTitleTTFSizeForState(float size, ControlState state)
|
||||
void ControlButton::setTitleTTFSizeForState(float size, State state)
|
||||
{
|
||||
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
|
||||
if(label)
|
||||
|
@ -426,7 +426,7 @@ void ControlButton::setTitleTTFSizeForState(float size, ControlState state)
|
|||
}
|
||||
}
|
||||
|
||||
float ControlButton::getTitleTTFSizeForState(ControlState state)
|
||||
float ControlButton::getTitleTTFSizeForState(State state)
|
||||
{
|
||||
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
|
||||
LabelTTF* labelTTF = dynamic_cast<LabelTTF*>(label);
|
||||
|
@ -440,7 +440,7 @@ float ControlButton::getTitleTTFSizeForState(ControlState state)
|
|||
}
|
||||
}
|
||||
|
||||
void ControlButton::setTitleBMFontForState(const char * fntFile, ControlState state)
|
||||
void ControlButton::setTitleBMFontForState(const char * fntFile, State state)
|
||||
{
|
||||
String * title = this->getTitleForState(state);
|
||||
if (!title)
|
||||
|
@ -450,7 +450,7 @@ void ControlButton::setTitleBMFontForState(const char * fntFile, ControlState st
|
|||
this->setTitleLabelForState(LabelBMFont::create(title->getCString(), fntFile), state);
|
||||
}
|
||||
|
||||
const char * ControlButton::getTitleBMFontForState(ControlState state)
|
||||
const char * ControlButton::getTitleBMFontForState(State state)
|
||||
{
|
||||
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
|
||||
LabelBMFont* labelBMFont = dynamic_cast<LabelBMFont*>(label);
|
||||
|
@ -465,29 +465,29 @@ const char * ControlButton::getTitleBMFontForState(ControlState state)
|
|||
}
|
||||
|
||||
|
||||
Scale9Sprite* ControlButton::getBackgroundSpriteForState(ControlState state)
|
||||
Scale9Sprite* ControlButton::getBackgroundSpriteForState(State state)
|
||||
{
|
||||
Scale9Sprite* backgroundSprite = (Scale9Sprite*)_backgroundSpriteDispatchTable->objectForKey(state);
|
||||
Scale9Sprite* backgroundSprite = (Scale9Sprite*)_backgroundSpriteDispatchTable->objectForKey((int)state);
|
||||
if (backgroundSprite)
|
||||
{
|
||||
return backgroundSprite;
|
||||
}
|
||||
return (Scale9Sprite*)_backgroundSpriteDispatchTable->objectForKey(ControlStateNormal);
|
||||
return (Scale9Sprite*)_backgroundSpriteDispatchTable->objectForKey((int)Control::State::NORMAL);
|
||||
}
|
||||
|
||||
|
||||
void ControlButton::setBackgroundSpriteForState(Scale9Sprite* sprite, ControlState state)
|
||||
void ControlButton::setBackgroundSpriteForState(Scale9Sprite* sprite, State state)
|
||||
{
|
||||
Size oldPreferredSize = _preferredSize;
|
||||
|
||||
Scale9Sprite* previousBackgroundSprite = (Scale9Sprite*)_backgroundSpriteDispatchTable->objectForKey(state);
|
||||
Scale9Sprite* previousBackgroundSprite = (Scale9Sprite*)_backgroundSpriteDispatchTable->objectForKey((int)state);
|
||||
if (previousBackgroundSprite)
|
||||
{
|
||||
removeChild(previousBackgroundSprite, true);
|
||||
_backgroundSpriteDispatchTable->removeObjectForKey(state);
|
||||
_backgroundSpriteDispatchTable->removeObjectForKey((int)state);
|
||||
}
|
||||
|
||||
_backgroundSpriteDispatchTable->setObject(sprite, state);
|
||||
_backgroundSpriteDispatchTable->setObject(sprite, (int)state);
|
||||
sprite->setVisible(false);
|
||||
sprite->setAnchorPoint(Point(0.5f, 0.5f));
|
||||
addChild(sprite);
|
||||
|
@ -510,7 +510,7 @@ void ControlButton::setBackgroundSpriteForState(Scale9Sprite* sprite, ControlSta
|
|||
}
|
||||
}
|
||||
|
||||
void ControlButton::setBackgroundSpriteFrameForState(SpriteFrame * spriteFrame, ControlState state)
|
||||
void ControlButton::setBackgroundSpriteFrameForState(SpriteFrame * spriteFrame, State state)
|
||||
{
|
||||
Scale9Sprite * sprite = Scale9Sprite::createWithSpriteFrame(spriteFrame);
|
||||
this->setBackgroundSpriteForState(sprite, state);
|
||||
|
@ -647,7 +647,7 @@ bool ControlButton::ccTouchBegan(Touch *pTouch, Event *pEvent)
|
|||
|
||||
_isPushed = true;
|
||||
this->setHighlighted(true);
|
||||
sendActionsForControlEvents(ControlEventTouchDown);
|
||||
sendActionsForControlEvents(Control::EventType::TOUCH_DOWN);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -666,21 +666,21 @@ void ControlButton::ccTouchMoved(Touch *pTouch, Event *pEvent)
|
|||
if (isTouchMoveInside && !isHighlighted())
|
||||
{
|
||||
setHighlighted(true);
|
||||
sendActionsForControlEvents(ControlEventTouchDragEnter);
|
||||
sendActionsForControlEvents(Control::EventType::DRAG_ENTER);
|
||||
}
|
||||
else if (isTouchMoveInside && isHighlighted())
|
||||
{
|
||||
sendActionsForControlEvents(ControlEventTouchDragInside);
|
||||
sendActionsForControlEvents(Control::EventType::DRAG_INSIDE);
|
||||
}
|
||||
else if (!isTouchMoveInside && isHighlighted())
|
||||
{
|
||||
setHighlighted(false);
|
||||
|
||||
sendActionsForControlEvents(ControlEventTouchDragExit);
|
||||
sendActionsForControlEvents(Control::EventType::DRAG_EXIT);
|
||||
}
|
||||
else if (!isTouchMoveInside && !isHighlighted())
|
||||
{
|
||||
sendActionsForControlEvents(ControlEventTouchDragOutside);
|
||||
sendActionsForControlEvents(Control::EventType::DRAG_OUTSIDE);
|
||||
}
|
||||
}
|
||||
void ControlButton::ccTouchEnded(Touch *pTouch, Event *pEvent)
|
||||
|
@ -691,11 +691,11 @@ void ControlButton::ccTouchEnded(Touch *pTouch, Event *pEvent)
|
|||
|
||||
if (isTouchInside(pTouch))
|
||||
{
|
||||
sendActionsForControlEvents(ControlEventTouchUpInside);
|
||||
sendActionsForControlEvents(Control::EventType::TOUCH_UP_INSIDE);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendActionsForControlEvents(ControlEventTouchUpOutside);
|
||||
sendActionsForControlEvents(Control::EventType::TOUCH_UP_OUTSIDE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -749,7 +749,7 @@ void ControlButton::ccTouchCancelled(Touch *pTouch, Event *pEvent)
|
|||
{
|
||||
_isPushed = false;
|
||||
setHighlighted(false);
|
||||
sendActionsForControlEvents(ControlEventTouchCancel);
|
||||
sendActionsForControlEvents(Control::EventType::TOUCH_CANCEL);
|
||||
}
|
||||
|
||||
ControlButton* ControlButton::create()
|
||||
|
|
|
@ -82,7 +82,7 @@ public:
|
|||
*
|
||||
* @return The title for the specified state.
|
||||
*/
|
||||
virtual String* getTitleForState(ControlState state);
|
||||
virtual String* getTitleForState(State state);
|
||||
|
||||
/**
|
||||
* Sets the title string to use for the specified state.
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
* @param state The state that uses the specified title. The values are described
|
||||
* in "CCControlState".
|
||||
*/
|
||||
virtual void setTitleForState(String* title, ControlState state);
|
||||
virtual void setTitleForState(String* title, State state);
|
||||
|
||||
/**
|
||||
* Returns the title color used for a state.
|
||||
|
@ -104,7 +104,7 @@ public:
|
|||
* @return The color of the title for the specified state.
|
||||
*/
|
||||
|
||||
virtual Color3B getTitleColorForState(ControlState state) const;
|
||||
virtual Color3B getTitleColorForState(State state) const;
|
||||
|
||||
/**
|
||||
* Sets the color of the title to use for the specified state.
|
||||
|
@ -113,7 +113,7 @@ public:
|
|||
* @param state The state that uses the specified color. The values are described
|
||||
* in "CCControlState".
|
||||
*/
|
||||
virtual void setTitleColorForState(Color3B color, ControlState state);
|
||||
virtual void setTitleColorForState(Color3B color, State state);
|
||||
|
||||
/**
|
||||
* Returns the title label used for a state.
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
* @param state The state that uses the title label. Possible values are described
|
||||
* in "CCControlState".
|
||||
*/
|
||||
virtual Node* getTitleLabelForState(ControlState state);
|
||||
virtual Node* getTitleLabelForState(State state);
|
||||
|
||||
/**
|
||||
* Sets the title label to use for the specified state.
|
||||
|
@ -132,13 +132,13 @@ public:
|
|||
* @param state The state that uses the specified title. The values are described
|
||||
* in "CCControlState".
|
||||
*/
|
||||
virtual void setTitleLabelForState(Node* label, ControlState state);
|
||||
virtual void setTitleLabelForState(Node* label, State state);
|
||||
|
||||
virtual void setTitleTTFForState(const char * fntFile, ControlState state);
|
||||
virtual const char * getTitleTTFForState(ControlState state);
|
||||
virtual void setTitleTTFForState(const char * fntFile, State state);
|
||||
virtual const char * getTitleTTFForState(State state);
|
||||
|
||||
virtual void setTitleTTFSizeForState(float size, ControlState state);
|
||||
virtual float getTitleTTFSizeForState(ControlState state);
|
||||
virtual void setTitleTTFSizeForState(float size, State state);
|
||||
virtual float getTitleTTFSizeForState(State state);
|
||||
|
||||
/**
|
||||
* Sets the font of the label, changes the label to a LabelBMFont if neccessary.
|
||||
|
@ -146,8 +146,8 @@ public:
|
|||
* @param state The state that uses the specified fntFile. The values are described
|
||||
* in "CCControlState".
|
||||
*/
|
||||
virtual void setTitleBMFontForState(const char * fntFile, ControlState state);
|
||||
virtual const char * getTitleBMFontForState(ControlState state);
|
||||
virtual void setTitleBMFontForState(const char * fntFile, State state);
|
||||
virtual const char * getTitleBMFontForState(State state);
|
||||
|
||||
/**
|
||||
* Returns the background sprite used for a state.
|
||||
|
@ -155,7 +155,7 @@ public:
|
|||
* @param state The state that uses the background sprite. Possible values are
|
||||
* described in "CCControlState".
|
||||
*/
|
||||
virtual Scale9Sprite* getBackgroundSpriteForState(ControlState state);
|
||||
virtual Scale9Sprite* getBackgroundSpriteForState(State state);
|
||||
|
||||
/**
|
||||
* Sets the background sprite to use for the specified button state.
|
||||
|
@ -164,7 +164,7 @@ public:
|
|||
* @param state The state that uses the specified image. The values are described
|
||||
* in "CCControlState".
|
||||
*/
|
||||
virtual void setBackgroundSpriteForState(Scale9Sprite* sprite, ControlState state);
|
||||
virtual void setBackgroundSpriteForState(Scale9Sprite* sprite, State state);
|
||||
|
||||
/**
|
||||
* Sets the background spriteFrame to use for the specified button state.
|
||||
|
@ -173,16 +173,16 @@ public:
|
|||
* @param state The state that uses the specified image. The values are described
|
||||
* in "CCControlState".
|
||||
*/
|
||||
virtual void setBackgroundSpriteFrameForState(SpriteFrame * spriteFrame, ControlState state);
|
||||
virtual void setBackgroundSpriteFrameForState(SpriteFrame * spriteFrame, State state);
|
||||
|
||||
//set the margins at once (so we only have to do one call of needsLayout)
|
||||
virtual void setMargins(int marginH, int marginV);
|
||||
|
||||
// Overrides
|
||||
virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent) override;
|
||||
virtual void ccTouchMoved(Touch *pTouch, Event *pEvent) override;
|
||||
virtual void ccTouchEnded(Touch *pTouch, Event *pEvent) override;
|
||||
virtual void ccTouchCancelled(Touch *pTouch, Event *pEvent) override;
|
||||
virtual bool ccTouchBegan(Touch *pTouch, cocos2d::Event *pEvent) override;
|
||||
virtual void ccTouchMoved(Touch *pTouch, cocos2d::Event *pEvent) override;
|
||||
virtual void ccTouchEnded(Touch *pTouch, cocos2d::Event *pEvent) override;
|
||||
virtual void ccTouchCancelled(Touch *pTouch, cocos2d::Event *pEvent) override;
|
||||
virtual GLubyte getOpacity(void) const override;
|
||||
virtual void setOpacity(GLubyte var) override;
|
||||
virtual const Color3B& getColor(void) const override;
|
||||
|
|
|
@ -92,8 +92,8 @@ bool ControlColourPicker::init()
|
|||
_colourPicker->initWithTargetAndPos(spriteSheet, Point(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift));
|
||||
|
||||
// Setup events
|
||||
_huePicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::hueSliderValueChanged), ControlEventValueChanged);
|
||||
_colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::colourSliderValueChanged), ControlEventValueChanged);
|
||||
_huePicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::hueSliderValueChanged), Control::EventType::VALUE_CHANGED);
|
||||
_colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::colourSliderValueChanged), Control::EventType::VALUE_CHANGED);
|
||||
|
||||
// Set defaults
|
||||
updateHueAndControlPicker();
|
||||
|
@ -146,7 +146,7 @@ void ControlColourPicker::setEnabled(bool enabled)
|
|||
}
|
||||
|
||||
|
||||
//need two events to prevent an infinite loop! (can't update huePicker when the huePicker triggers the callback due to ControlEventValueChanged)
|
||||
//need two events to prevent an infinite loop! (can't update huePicker when the huePicker triggers the callback due to Control::EventType::VALUE_CHANGED)
|
||||
void ControlColourPicker::updateControlPicker()
|
||||
{
|
||||
_huePicker->setHue(_hsv.h);
|
||||
|
@ -161,7 +161,7 @@ void ControlColourPicker::updateHueAndControlPicker()
|
|||
}
|
||||
|
||||
|
||||
void ControlColourPicker::hueSliderValueChanged(Object * sender, ControlEvent controlEvent)
|
||||
void ControlColourPicker::hueSliderValueChanged(Object * sender, Control::EventType controlEvent)
|
||||
{
|
||||
_hsv.h = ((ControlHuePicker*)sender)->getHue();
|
||||
|
||||
|
@ -171,11 +171,11 @@ void ControlColourPicker::hueSliderValueChanged(Object * sender, ControlEvent co
|
|||
Control::setColor(Color3B((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f)));
|
||||
|
||||
// Send Control callback
|
||||
sendActionsForControlEvents(ControlEventValueChanged);
|
||||
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||
updateControlPicker();
|
||||
}
|
||||
|
||||
void ControlColourPicker::colourSliderValueChanged(Object * sender, ControlEvent controlEvent)
|
||||
void ControlColourPicker::colourSliderValueChanged(Object * sender, Control::EventType controlEvent)
|
||||
{
|
||||
_hsv.s=((ControlSaturationBrightnessPicker*)sender)->getSaturation();
|
||||
_hsv.v=((ControlSaturationBrightnessPicker*)sender)->getBrightness();
|
||||
|
@ -187,7 +187,7 @@ void ControlColourPicker::colourSliderValueChanged(Object * sender, ControlEvent
|
|||
Control::setColor(Color3B((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f)));
|
||||
|
||||
// Send Control callback
|
||||
sendActionsForControlEvents(ControlEventValueChanged);
|
||||
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||
}
|
||||
|
||||
//ignore all touches, handled by children
|
||||
|
|
|
@ -61,8 +61,8 @@ public:
|
|||
virtual void setEnabled(bool bEnabled);
|
||||
|
||||
//virtual ~ControlColourPicker();
|
||||
void hueSliderValueChanged(Object * sender, ControlEvent controlEvent);
|
||||
void colourSliderValueChanged(Object * sender, ControlEvent controlEvent);
|
||||
void hueSliderValueChanged(Object * sender, Control::EventType controlEvent);
|
||||
void colourSliderValueChanged(Object * sender, Control::EventType controlEvent);
|
||||
|
||||
protected:
|
||||
void updateControlPicker();
|
||||
|
|
|
@ -147,7 +147,7 @@ void ControlHuePicker::updateSliderPosition(Point location)
|
|||
setHue(angleDeg);
|
||||
|
||||
// send Control callback
|
||||
sendActionsForControlEvents(ControlEventValueChanged);
|
||||
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||
}
|
||||
|
||||
bool ControlHuePicker::checkSliderPosition(Point location)
|
||||
|
@ -186,7 +186,7 @@ void ControlHuePicker::ccTouchMoved(Touch* touch, Event* event)
|
|||
|
||||
//small modification: this allows changing of the colour, even if the touch leaves the bounding area
|
||||
// updateSliderPosition(touchLocation);
|
||||
// sendActionsForControlEvents(ControlEventValueChanged);
|
||||
// sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||
// Check the touch position on the slider
|
||||
checkSliderPosition(touchLocation);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ void ControlPotentiometer::setValue(float value)
|
|||
_progressTimer->setPercentage(percent * 100.0f);
|
||||
_thumbSprite->setRotation(percent * 360.0f);
|
||||
|
||||
sendActionsForControlEvents(ControlEventValueChanged);
|
||||
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||
}
|
||||
|
||||
float ControlPotentiometer::getValue()
|
||||
|
|
|
@ -174,7 +174,7 @@ bool ControlSaturationBrightnessPicker::checkSliderPosition(Point location)
|
|||
if (dist <= _background->getBoundingBox().size.width*0.5f)
|
||||
{
|
||||
updateSliderPosition(location);
|
||||
sendActionsForControlEvents(ControlEventValueChanged);
|
||||
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -203,7 +203,7 @@ void ControlSaturationBrightnessPicker::ccTouchMoved(Touch* touch, Event* event)
|
|||
|
||||
//small modification: this allows changing of the colour, even if the touch leaves the bounding area
|
||||
// updateSliderPosition(touchLocation);
|
||||
// sendActionsForControlEvents(ControlEventValueChanged);
|
||||
// sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||
// Check the touch position on the slider
|
||||
checkSliderPosition(touchLocation);
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ void ControlSlider::setEnabled(bool enabled)
|
|||
|
||||
this->needsLayout();
|
||||
|
||||
this->sendActionsForControlEvents(ControlEventValueChanged);
|
||||
this->sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||
}
|
||||
|
||||
void ControlSlider::setMinimumValue(float minimumValue)
|
||||
|
|
|
@ -213,7 +213,7 @@ void ControlStepper::setValueWithSendingEvent(double value, bool send)
|
|||
|
||||
if (send)
|
||||
{
|
||||
this->sendActionsForControlEvents(ControlEventValueChanged);
|
||||
this->sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
/** Update the layout of the stepper with the given touch location. */
|
||||
void updateLayoutUsingTouchLocation(Point location);
|
||||
|
||||
/** Set the numeric value of the stepper. If send is true, the ControlEventValueChanged is sent. */
|
||||
/** Set the numeric value of the stepper. If send is true, the Control::EventType::VALUE_CHANGED is sent. */
|
||||
void setValue(double value, bool send);
|
||||
|
||||
/** Start the autorepeat increment/decrement. */
|
||||
|
|
|
@ -366,7 +366,7 @@ void ControlSwitch::setOn(bool isOn, bool animated)
|
|||
_switchSprite->setSliderXPosition((_on) ? _switchSprite->getOnPosition() : _switchSprite->getOffPosition());
|
||||
}
|
||||
|
||||
sendActionsForControlEvents(ControlEventValueChanged);
|
||||
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||
}
|
||||
|
||||
void ControlSwitch::setEnabled(bool enabled)
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
Invocation* Invocation::create(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent)
|
||||
Invocation* Invocation::create(Object* target, Control::Handler action, Control::EventType controlEvent)
|
||||
{
|
||||
Invocation* pRet = new Invocation(target, action, controlEvent);
|
||||
if (pRet != NULL)
|
||||
|
@ -38,7 +38,7 @@ Invocation* Invocation::create(Object* target, SEL_CCControlHandler action, Cont
|
|||
return pRet;
|
||||
}
|
||||
|
||||
Invocation::Invocation(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent)
|
||||
Invocation::Invocation(Object* target, Control::Handler action, Control::EventType controlEvent)
|
||||
{
|
||||
_target=target;
|
||||
_action=action;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "cocoa/CCObject.h"
|
||||
#include "../../ExtensionMacros.h"
|
||||
#include "CCControl.h"
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
|
@ -42,24 +43,20 @@ NS_CC_EXT_BEGIN
|
|||
* @{
|
||||
*/
|
||||
|
||||
typedef unsigned int ControlEvent;
|
||||
|
||||
typedef void (Object::*SEL_CCControlHandler)(Object*, ControlEvent);
|
||||
|
||||
#define cccontrol_selector(_SELECTOR) (SEL_CCControlHandler)(&_SELECTOR)
|
||||
#define cccontrol_selector(_SELECTOR) (Control::Handler)(&_SELECTOR)
|
||||
|
||||
class Invocation : public Object
|
||||
{
|
||||
public:
|
||||
static Invocation* create(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent);
|
||||
Invocation(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent);
|
||||
static Invocation* create(Object* target, Control::Handler action, Control::EventType controlEvent);
|
||||
Invocation(Object* target, Control::Handler action, Control::EventType controlEvent);
|
||||
|
||||
void invoke(Object* sender);
|
||||
|
||||
protected:
|
||||
CC_SYNTHESIZE_READONLY(SEL_CCControlHandler, _action, Action);
|
||||
CC_SYNTHESIZE_READONLY(Control::Handler, _action, Action);
|
||||
CC_SYNTHESIZE_READONLY(Object*, _target, Target);
|
||||
CC_SYNTHESIZE_READONLY(ControlEvent, _controlEvent, ControlEvent);
|
||||
CC_SYNTHESIZE_READONLY(Control::EventType, _controlEvent, ControlEvent);
|
||||
};
|
||||
|
||||
// end of GUI group
|
||||
|
|
|
@ -51,7 +51,7 @@ EditBox::~EditBox(void)
|
|||
}
|
||||
|
||||
|
||||
void EditBox::touchDownAction(Object *sender, ControlEvent controlEvent)
|
||||
void EditBox::touchDownAction(Object *sender, Control::EventType controlEvent)
|
||||
{
|
||||
_editBoxImpl->openKeyboard();
|
||||
}
|
||||
|
@ -64,12 +64,12 @@ EditBox* EditBox::create(const Size& size, Scale9Sprite* pNormal9SpriteBg, Scale
|
|||
{
|
||||
if (pPressed9SpriteBg != NULL)
|
||||
{
|
||||
pRet->setBackgroundSpriteForState(pPressed9SpriteBg, ControlStateHighlighted);
|
||||
pRet->setBackgroundSpriteForState(pPressed9SpriteBg, Control::State::HIGH_LIGHTED);
|
||||
}
|
||||
|
||||
if (pDisabled9SpriteBg != NULL)
|
||||
{
|
||||
pRet->setBackgroundSpriteForState(pDisabled9SpriteBg, ControlStateDisabled);
|
||||
pRet->setBackgroundSpriteForState(pDisabled9SpriteBg, Control::State::DISABLED);
|
||||
}
|
||||
pRet->autorelease();
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ bool EditBox::initWithSizeAndBackgroundSprite(const Size& size, Scale9Sprite* pP
|
|||
this->setZoomOnTouchDown(false);
|
||||
this->setPreferredSize(size);
|
||||
this->setPosition(Point(0, 0));
|
||||
this->addTargetWithActionForControlEvent(this, cccontrol_selector(EditBox::touchDownAction), ControlEventTouchUpInside);
|
||||
this->addTargetWithActionForControlEvent(this, cccontrol_selector(EditBox::touchDownAction), Control::EventType::TOUCH_UP_INSIDE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -356,7 +356,7 @@ public:
|
|||
virtual void keyboardDidHide(IMEKeyboardNotificationInfo& info);
|
||||
|
||||
/* callback funtions */
|
||||
void touchDownAction(Object *sender, ControlEvent controlEvent);
|
||||
void touchDownAction(Object *sender, Control::EventType controlEvent);
|
||||
|
||||
protected:
|
||||
EditBoxImpl* _editBoxImpl;
|
||||
|
|
|
@ -39,18 +39,18 @@ void AnimationsTestLayer::setAnimationManager(cocos2d::extension::CCBAnimationMa
|
|||
CC_SAFE_RETAIN(mAnimationManager);
|
||||
}
|
||||
|
||||
void AnimationsTestLayer::onControlButtonIdleClicked(Object *pSender, ControlEvent pControlEvent) {
|
||||
void AnimationsTestLayer::onControlButtonIdleClicked(Object *pSender, Control::EventType pControlEvent) {
|
||||
mAnimationManager->runAnimationsForSequenceNamedTweenDuration("Idle", 0.3f);
|
||||
}
|
||||
|
||||
void AnimationsTestLayer::onControlButtonWaveClicked(Object *pSender, ControlEvent pControlEvent) {
|
||||
void AnimationsTestLayer::onControlButtonWaveClicked(Object *pSender, Control::EventType pControlEvent) {
|
||||
mAnimationManager->runAnimationsForSequenceNamedTweenDuration("Wave", 0.3f);
|
||||
}
|
||||
|
||||
void AnimationsTestLayer::onControlButtonJumpClicked(Object *pSender, ControlEvent pControlEvent) {
|
||||
void AnimationsTestLayer::onControlButtonJumpClicked(Object *pSender, Control::EventType pControlEvent) {
|
||||
mAnimationManager->runAnimationsForSequenceNamedTweenDuration("Jump", 0.3f);
|
||||
}
|
||||
|
||||
void AnimationsTestLayer::onControlButtonFunkyClicked(Object *pSender, ControlEvent pControlEvent) {
|
||||
void AnimationsTestLayer::onControlButtonFunkyClicked(Object *pSender, Control::EventType pControlEvent) {
|
||||
mAnimationManager->runAnimationsForSequenceNamedTweenDuration("Funky", 0.3f);
|
||||
}
|
|
@ -19,10 +19,10 @@ public:
|
|||
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node);
|
||||
|
||||
void onControlButtonIdleClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent);
|
||||
void onControlButtonWaveClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent);
|
||||
void onControlButtonJumpClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent);
|
||||
void onControlButtonFunkyClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent);
|
||||
void onControlButtonIdleClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent);
|
||||
void onControlButtonWaveClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent);
|
||||
void onControlButtonJumpClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent);
|
||||
void onControlButtonFunkyClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent);
|
||||
|
||||
void setAnimationManager(cocos2d::extension::CCBAnimationManager *pAnimationManager);
|
||||
|
||||
|
|
|
@ -28,33 +28,33 @@ bool ButtonTestLayer::onAssignCCBMemberVariable(Object * pTarget, const char * p
|
|||
return false;
|
||||
}
|
||||
|
||||
void ButtonTestLayer::onControlButtonClicked(cocos2d::Object *pSender, cocos2d::extension::ControlEvent pControlEvent) {
|
||||
void ButtonTestLayer::onControlButtonClicked(cocos2d::Object *pSender, cocos2d::extension::Control::EventType pControlEvent) {
|
||||
switch(pControlEvent) {
|
||||
case ControlEventTouchDown:
|
||||
case Control::EventType::TOUCH_DOWN:
|
||||
this->mControlEventLabel->setString("Touch Down.");
|
||||
break;
|
||||
case ControlEventTouchDragInside:
|
||||
case Control::EventType::DRAG_INSIDE:
|
||||
this->mControlEventLabel->setString("Touch Drag Inside.");
|
||||
break;
|
||||
case ControlEventTouchDragOutside:
|
||||
case Control::EventType::DRAG_OUTSIDE:
|
||||
this->mControlEventLabel->setString("Touch Drag Outside.");
|
||||
break;
|
||||
case ControlEventTouchDragEnter:
|
||||
case Control::EventType::DRAG_ENTER:
|
||||
this->mControlEventLabel->setString("Touch Drag Enter.");
|
||||
break;
|
||||
case ControlEventTouchDragExit:
|
||||
case Control::EventType::DRAG_EXIT:
|
||||
this->mControlEventLabel->setString("Touch Drag Exit.");
|
||||
break;
|
||||
case ControlEventTouchUpInside:
|
||||
case Control::EventType::TOUCH_UP_INSIDE:
|
||||
this->mControlEventLabel->setString("Touch Up Inside.");
|
||||
break;
|
||||
case ControlEventTouchUpOutside:
|
||||
case Control::EventType::TOUCH_UP_OUTSIDE:
|
||||
this->mControlEventLabel->setString("Touch Up Outside.");
|
||||
break;
|
||||
case ControlEventTouchCancel:
|
||||
case Control::EventType::TOUCH_CANCEL:
|
||||
this->mControlEventLabel->setString("Touch Cancel.");
|
||||
break;
|
||||
case ControlEventValueChanged:
|
||||
case Control::EventType::VALUE_CHANGED:
|
||||
this->mControlEventLabel->setString("Value Changed.");
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node);
|
||||
|
||||
void onControlButtonClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent);
|
||||
void onControlButtonClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent);
|
||||
|
||||
private:
|
||||
cocos2d::LabelBMFont * mControlEventLabel;
|
||||
|
|
|
@ -126,19 +126,19 @@ bool HelloCocosBuilderLayer::onAssignCCBCustomProperty(Object* pTarget, const ch
|
|||
return bRet;
|
||||
}
|
||||
|
||||
void HelloCocosBuilderLayer::onMenuTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) {
|
||||
void HelloCocosBuilderLayer::onMenuTestClicked(Object * pSender, cocos2d::extension::Control::EventType pControlEvent) {
|
||||
this->openTest("ccb/ccb/TestMenus.ccbi", "TestMenusLayer", MenuTestLayerLoader::loader());
|
||||
}
|
||||
|
||||
void HelloCocosBuilderLayer::onSpriteTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) {
|
||||
void HelloCocosBuilderLayer::onSpriteTestClicked(Object * pSender, cocos2d::extension::Control::EventType pControlEvent) {
|
||||
this->openTest("ccb/ccb/TestSprites.ccbi", "TestSpritesLayer", SpriteTestLayerLoader::loader());
|
||||
}
|
||||
|
||||
void HelloCocosBuilderLayer::onButtonTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) {
|
||||
void HelloCocosBuilderLayer::onButtonTestClicked(Object * pSender, cocos2d::extension::Control::EventType pControlEvent) {
|
||||
this->openTest("ccb/ccb/TestButtons.ccbi", "TestButtonsLayer", ButtonTestLayerLoader::loader());
|
||||
}
|
||||
|
||||
void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) {
|
||||
void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * pSender, cocos2d::extension::Control::EventType pControlEvent) {
|
||||
|
||||
/* Create an autorelease NodeLoaderLibrary. */
|
||||
NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::newDefaultNodeLoaderLibrary();
|
||||
|
@ -179,16 +179,16 @@ void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * pSender, cocos2d::
|
|||
//this->openTest("TestAnimations.ccbi", "TestAnimationsLayer", AnimationsTestLayerLoader::loader());
|
||||
}
|
||||
|
||||
void HelloCocosBuilderLayer::onParticleSystemTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) {
|
||||
void HelloCocosBuilderLayer::onParticleSystemTestClicked(Object * pSender, cocos2d::extension::Control::EventType pControlEvent) {
|
||||
this->openTest("ccb/ccb/TestParticleSystems.ccbi", "TestParticleSystemsLayer", ParticleSystemTestLayerLoader::loader());
|
||||
}
|
||||
|
||||
void HelloCocosBuilderLayer::onScrollViewTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent)
|
||||
void HelloCocosBuilderLayer::onScrollViewTestClicked(Object * pSender, cocos2d::extension::Control::EventType pControlEvent)
|
||||
{
|
||||
this->openTest("ccb/ccb/TestScrollViews.ccbi", "TestScrollViewsLayer", ScrollViewTestLayerLoader::loader());
|
||||
}
|
||||
|
||||
void HelloCocosBuilderLayer::onTimelineCallbackSoundClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent)
|
||||
void HelloCocosBuilderLayer::onTimelineCallbackSoundClicked(Object * pSender, cocos2d::extension::Control::EventType pControlEvent)
|
||||
{
|
||||
this->openTest("ccb/ccb/TestTimelineCallback.ccbi", "TimelineCallbackTestLayer", TimelineCallbackTestLayerLoader::loader());
|
||||
}
|
||||
|
|
|
@ -34,13 +34,13 @@ class HelloCocosBuilderLayer
|
|||
virtual bool onAssignCCBCustomProperty(Object* pTarget, const char* pMemberVariableName, cocos2d::extension::CCBValue* pCCBValue);
|
||||
virtual void onNodeLoaded(cocos2d::Node * node, cocos2d::extension::NodeLoader * nodeLoader);
|
||||
|
||||
void onMenuTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent);
|
||||
void onSpriteTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent);
|
||||
void onButtonTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent);
|
||||
void onAnimationsTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent);
|
||||
void onParticleSystemTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent);
|
||||
void onScrollViewTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent);
|
||||
void onTimelineCallbackSoundClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent);
|
||||
void onMenuTestClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent);
|
||||
void onSpriteTestClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent);
|
||||
void onButtonTestClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent);
|
||||
void onAnimationsTestClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent);
|
||||
void onParticleSystemTestClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent);
|
||||
void onScrollViewTestClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent);
|
||||
void onTimelineCallbackSoundClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent);
|
||||
|
||||
private:
|
||||
cocos2d::Sprite * mBurstSprite;
|
||||
|
|
|
@ -102,8 +102,8 @@ ControlButton *ControlButtonTest_HelloVariableSize::standardButtonWithTitle(cons
|
|||
titleButton->setColor(Color3B(159, 168, 176));
|
||||
|
||||
ControlButton *button = ControlButton::create(titleButton, backgroundButton);
|
||||
button->setBackgroundSpriteForState(backgroundHighlightedButton, ControlStateHighlighted);
|
||||
button->setTitleColorForState(Color3B::WHITE, ControlStateHighlighted);
|
||||
button->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED);
|
||||
button->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
@ -140,8 +140,8 @@ bool ControlButtonTest_Event::init()
|
|||
titleButton->setColor(Color3B(159, 168, 176));
|
||||
|
||||
ControlButton *controlButton = ControlButton::create(titleButton, backgroundButton);
|
||||
controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, ControlStateHighlighted);
|
||||
controlButton->setTitleColorForState(Color3B::WHITE, ControlStateHighlighted);
|
||||
controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED);
|
||||
controlButton->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED);
|
||||
|
||||
controlButton->setAnchorPoint(Point(0.5f, 1));
|
||||
controlButton->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f));
|
||||
|
@ -154,55 +154,55 @@ bool ControlButtonTest_Event::init()
|
|||
addChild(background);
|
||||
|
||||
// Sets up event handlers
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDownAction), ControlEventTouchDown);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragInsideAction), ControlEventTouchDragInside);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragOutsideAction), ControlEventTouchDragOutside);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragEnterAction), ControlEventTouchDragEnter);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragExitAction), ControlEventTouchDragExit);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpInsideAction), ControlEventTouchUpInside);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpOutsideAction), ControlEventTouchUpOutside);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchCancelAction), ControlEventTouchCancel);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDownAction), Control::EventType::TOUCH_DOWN);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragInsideAction), Control::EventType::DRAG_INSIDE);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragOutsideAction), Control::EventType::DRAG_OUTSIDE);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragEnterAction), Control::EventType::DRAG_ENTER);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragExitAction), Control::EventType::DRAG_EXIT);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpInsideAction), Control::EventType::TOUCH_UP_INSIDE);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpOutsideAction), Control::EventType::TOUCH_UP_OUTSIDE);
|
||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchCancelAction), Control::EventType::TOUCH_CANCEL);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ControlButtonTest_Event::touchDownAction(Object *senderz, ControlEvent controlEvent)
|
||||
void ControlButtonTest_Event::touchDownAction(Object *senderz, Control::EventType controlEvent)
|
||||
{
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Down")->getCString());
|
||||
}
|
||||
|
||||
void ControlButtonTest_Event::touchDragInsideAction(Object *sender, ControlEvent controlEvent)
|
||||
void ControlButtonTest_Event::touchDragInsideAction(Object *sender, Control::EventType controlEvent)
|
||||
{
|
||||
_displayValueLabel->setString(String::createWithFormat("Drag Inside")->getCString());
|
||||
}
|
||||
|
||||
void ControlButtonTest_Event::touchDragOutsideAction(Object *sender, ControlEvent controlEvent)
|
||||
void ControlButtonTest_Event::touchDragOutsideAction(Object *sender, Control::EventType controlEvent)
|
||||
{
|
||||
_displayValueLabel->setString(String::createWithFormat("Drag Outside")->getCString());
|
||||
}
|
||||
|
||||
void ControlButtonTest_Event::touchDragEnterAction(Object *sender, ControlEvent controlEvent)
|
||||
void ControlButtonTest_Event::touchDragEnterAction(Object *sender, Control::EventType controlEvent)
|
||||
{
|
||||
_displayValueLabel->setString(String::createWithFormat("Drag Enter")->getCString());
|
||||
}
|
||||
|
||||
void ControlButtonTest_Event::touchDragExitAction(Object *sender, ControlEvent controlEvent)
|
||||
void ControlButtonTest_Event::touchDragExitAction(Object *sender, Control::EventType controlEvent)
|
||||
{
|
||||
_displayValueLabel->setString(String::createWithFormat("Drag Exit")->getCString());
|
||||
}
|
||||
|
||||
void ControlButtonTest_Event::touchUpInsideAction(Object *sender, ControlEvent controlEvent)
|
||||
void ControlButtonTest_Event::touchUpInsideAction(Object *sender, Control::EventType controlEvent)
|
||||
{
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Up Inside.")->getCString());
|
||||
}
|
||||
|
||||
void ControlButtonTest_Event::touchUpOutsideAction(Object *sender, ControlEvent controlEvent)
|
||||
void ControlButtonTest_Event::touchUpOutsideAction(Object *sender, Control::EventType controlEvent)
|
||||
{
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Up Outside.")->getCString());
|
||||
}
|
||||
|
||||
void ControlButtonTest_Event::touchCancelAction(Object *sender, ControlEvent controlEvent)
|
||||
void ControlButtonTest_Event::touchCancelAction(Object *sender, Control::EventType controlEvent)
|
||||
{
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Cancel")->getCString());
|
||||
}
|
||||
|
@ -269,8 +269,8 @@ ControlButton *ControlButtonTest_Styling::standardButtonWithTitle(const char *ti
|
|||
titleButton->setColor(Color3B(159, 168, 176));
|
||||
|
||||
ControlButton *button = ControlButton::create(titleButton, backgroundButton);
|
||||
button->setBackgroundSpriteForState(backgroundHighlightedButton, ControlStateHighlighted);
|
||||
button->setTitleColorForState(Color3B::WHITE, ControlStateHighlighted);
|
||||
button->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED);
|
||||
button->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
|
|
@ -46,14 +46,14 @@ public:
|
|||
ControlButtonTest_Event();
|
||||
~ControlButtonTest_Event();
|
||||
bool init();
|
||||
void touchDownAction(Object *sender, ControlEvent controlEvent);
|
||||
void touchDragInsideAction(Object *sender, ControlEvent controlEvent);
|
||||
void touchDragOutsideAction(Object *sender, ControlEvent controlEvent);
|
||||
void touchDragEnterAction(Object *sender, ControlEvent controlEvent);
|
||||
void touchDragExitAction(Object *sender, ControlEvent controlEvent);
|
||||
void touchUpInsideAction(Object *sender, ControlEvent controlEvent);
|
||||
void touchUpOutsideAction(Object *sender, ControlEvent controlEvent);
|
||||
void touchCancelAction(Object *sender, ControlEvent controlEvent);
|
||||
void touchDownAction(Object *sender, Control::EventType controlEvent);
|
||||
void touchDragInsideAction(Object *sender, Control::EventType controlEvent);
|
||||
void touchDragOutsideAction(Object *sender, Control::EventType controlEvent);
|
||||
void touchDragEnterAction(Object *sender, Control::EventType controlEvent);
|
||||
void touchDragExitAction(Object *sender, Control::EventType controlEvent);
|
||||
void touchUpInsideAction(Object *sender, Control::EventType controlEvent);
|
||||
void touchUpOutsideAction(Object *sender, Control::EventType controlEvent);
|
||||
void touchCancelAction(Object *sender, Control::EventType controlEvent);
|
||||
protected:
|
||||
CC_SYNTHESIZE_RETAIN(LabelTTF *, _displayValueLabel, DisplayValueLabel)
|
||||
CONTROL_SCENE_CREATE_FUNC(ControlButtonTest_Event)
|
||||
|
|
|
@ -53,7 +53,7 @@ bool ControlColourPickerTest::init()
|
|||
layer->addChild(colourPicker);
|
||||
|
||||
// Add the target-action pair
|
||||
colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPickerTest::colourValueChanged), ControlEventValueChanged);
|
||||
colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPickerTest::colourValueChanged), Control::EventType::VALUE_CHANGED);
|
||||
|
||||
|
||||
layer_width += colourPicker->getContentSize().width;
|
||||
|
@ -77,7 +77,7 @@ bool ControlColourPickerTest::init()
|
|||
layer->setAnchorPoint(Point (0.5f, 0.5f));
|
||||
|
||||
// Update the color text
|
||||
colourValueChanged(colourPicker, ControlEventValueChanged);
|
||||
colourValueChanged(colourPicker, Control::EventType::VALUE_CHANGED);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -89,7 +89,7 @@ ControlColourPickerTest::~ControlColourPickerTest()
|
|||
CC_SAFE_RELEASE(_colorLabel);
|
||||
}
|
||||
|
||||
void ControlColourPickerTest::colourValueChanged(Object *sender, ControlEvent controlEvent)
|
||||
void ControlColourPickerTest::colourValueChanged(Object *sender, Control::EventType controlEvent)
|
||||
{
|
||||
ControlColourPicker* pPicker = (ControlColourPicker*)sender;
|
||||
_colorLabel->setString(String::createWithFormat("#%02X%02X%02X",pPicker->getColor().r, pPicker->getColor().g, pPicker->getColor().b)->getCString());
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
virtual ~ControlColourPickerTest();
|
||||
bool init();
|
||||
/** Callback for the change value. */
|
||||
void colourValueChanged(Object *sender, ControlEvent controlEvent);
|
||||
void colourValueChanged(Object *sender, Control::EventType controlEvent);
|
||||
|
||||
CC_SYNTHESIZE_RETAIN(LabelTTF*, _colorLabel, ColorLabel)
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ bool ControlPotentiometerTest::init()
|
|||
potentiometer->setPosition(Point(layer_width + 10 + potentiometer->getContentSize().width / 2, 0));
|
||||
|
||||
// When the value of the slider will change, the given selector will be call
|
||||
potentiometer->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlPotentiometerTest::valueChanged), ControlEventValueChanged);
|
||||
potentiometer->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlPotentiometerTest::valueChanged), Control::EventType::VALUE_CHANGED);
|
||||
|
||||
layer->addChild(potentiometer);
|
||||
|
||||
|
@ -78,13 +78,13 @@ bool ControlPotentiometerTest::init()
|
|||
layer->setAnchorPoint(Point(0.5f, 0.5f));
|
||||
|
||||
// Update the value label
|
||||
this->valueChanged(potentiometer, ControlEventValueChanged);
|
||||
this->valueChanged(potentiometer, Control::EventType::VALUE_CHANGED);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ControlPotentiometerTest::valueChanged(Object *sender, ControlEvent controlEvent)
|
||||
void ControlPotentiometerTest::valueChanged(Object *sender, Control::EventType controlEvent)
|
||||
{
|
||||
ControlPotentiometer* pControl = (ControlPotentiometer*)sender;
|
||||
// Change value of label.
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
bool init();
|
||||
CC_SYNTHESIZE_RETAIN(LabelTTF*, _displayValueLabel, DisplayValueLabel)
|
||||
|
||||
void valueChanged(Object *sender, ControlEvent controlEvent);
|
||||
void valueChanged(Object *sender, Control::EventType controlEvent);
|
||||
|
||||
CONTROL_SCENE_CREATE_FUNC(ControlPotentiometerTest)
|
||||
};
|
||||
|
|
|
@ -58,7 +58,7 @@ bool ControlSliderTest::init()
|
|||
slider->setTag(1);
|
||||
|
||||
// When the value of the slider will change, the given selector will be call
|
||||
slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSliderTest::valueChanged), ControlEventValueChanged);
|
||||
slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSliderTest::valueChanged), Control::EventType::VALUE_CHANGED);
|
||||
|
||||
ControlSlider *restrictSlider = ControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png");
|
||||
restrictSlider->setAnchorPoint(Point(0.5f, 1.0f));
|
||||
|
@ -71,7 +71,7 @@ bool ControlSliderTest::init()
|
|||
restrictSlider->setTag(2);
|
||||
|
||||
//same with restricted
|
||||
restrictSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSliderTest::valueChanged), ControlEventValueChanged);
|
||||
restrictSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSliderTest::valueChanged), Control::EventType::VALUE_CHANGED);
|
||||
|
||||
addChild(slider);
|
||||
addChild(restrictSlider);
|
||||
|
@ -80,7 +80,7 @@ bool ControlSliderTest::init()
|
|||
return false;
|
||||
}
|
||||
|
||||
void ControlSliderTest::valueChanged(Object *sender, ControlEvent controlEvent)
|
||||
void ControlSliderTest::valueChanged(Object *sender, Control::EventType controlEvent)
|
||||
{
|
||||
ControlSlider* pSlider = (ControlSlider*)sender;
|
||||
// Change value of label.
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
ControlSliderTest();
|
||||
virtual ~ControlSliderTest();
|
||||
bool init();
|
||||
void valueChanged(Object *sender, ControlEvent controlEvent);
|
||||
void valueChanged(Object *sender, Control::EventType controlEvent);
|
||||
protected:
|
||||
LabelTTF* _displayValueLabel;
|
||||
CONTROL_SCENE_CREATE_FUNC(ControlSliderTest)
|
||||
|
|
|
@ -63,7 +63,7 @@ bool ControlStepperTest::init()
|
|||
|
||||
ControlStepper *stepper = this->makeControlStepper();
|
||||
stepper->setPosition(Point(layer_width + 10 + stepper->getContentSize().width / 2, 0));
|
||||
stepper->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlStepperTest::valueChanged), ControlEventValueChanged);
|
||||
stepper->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlStepperTest::valueChanged), Control::EventType::VALUE_CHANGED);
|
||||
layer->addChild(stepper);
|
||||
|
||||
layer_width += stepper->getContentSize().width;
|
||||
|
@ -73,7 +73,7 @@ bool ControlStepperTest::init()
|
|||
layer->setAnchorPoint(Point(0.5f, 0.5f));
|
||||
|
||||
// Update the value label
|
||||
this->valueChanged(stepper, ControlEventValueChanged);
|
||||
this->valueChanged(stepper, Control::EventType::VALUE_CHANGED);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -87,7 +87,7 @@ ControlStepper *ControlStepperTest::makeControlStepper()
|
|||
return ControlStepper::create(minusSprite, plusSprite);
|
||||
}
|
||||
|
||||
void ControlStepperTest::valueChanged(Object *sender, ControlEvent controlEvent)
|
||||
void ControlStepperTest::valueChanged(Object *sender, Control::EventType controlEvent)
|
||||
{
|
||||
ControlStepper* pControl = (ControlStepper*)sender;
|
||||
// Change value of label.
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
ControlStepper* makeControlStepper();
|
||||
|
||||
/** Callback for the change value. */
|
||||
void valueChanged(Object *sender, ControlEvent controlEvent);
|
||||
void valueChanged(Object *sender, Control::EventType controlEvent);
|
||||
protected:
|
||||
CC_SYNTHESIZE_RETAIN(LabelTTF*, _displayValueLabel, DisplayValueLabel)
|
||||
CONTROL_SCENE_CREATE_FUNC(ControlStepperTest)
|
||||
|
|
|
@ -70,20 +70,20 @@ bool ControlSwitchTest::init()
|
|||
switchControl->setPosition(Point(layer_width + 10 + switchControl->getContentSize().width / 2, 0));
|
||||
layer->addChild(switchControl);
|
||||
|
||||
switchControl->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSwitchTest::valueChanged), ControlEventValueChanged);
|
||||
switchControl->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSwitchTest::valueChanged), Control::EventType::VALUE_CHANGED);
|
||||
|
||||
// Set the layer size
|
||||
layer->setContentSize(Size(layer_width, 0));
|
||||
layer->setAnchorPoint(Point(0.5f, 0.5f));
|
||||
|
||||
// Update the value label
|
||||
valueChanged(switchControl, ControlEventValueChanged);
|
||||
valueChanged(switchControl, Control::EventType::VALUE_CHANGED);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ControlSwitchTest::valueChanged(Object* sender, ControlEvent controlEvent)
|
||||
void ControlSwitchTest::valueChanged(Object* sender, Control::EventType controlEvent)
|
||||
{
|
||||
ControlSwitch* pSwitch = (ControlSwitch*)sender;
|
||||
if (pSwitch->isOn())
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
virtual ~ControlSwitchTest();
|
||||
bool init();
|
||||
/** Callback for the change value. */
|
||||
void valueChanged(Object* sender, ControlEvent controlEvent);
|
||||
void valueChanged(Object* sender, Control::EventType controlEvent);
|
||||
LabelTTF *_displayValueLabel;
|
||||
CONTROL_SCENE_CREATE_FUNC(ControlSwitchTest)
|
||||
};
|
||||
|
|
|
@ -865,7 +865,7 @@ ControlSlider* SchedulerTimeScale::sliderCtl()
|
|||
{
|
||||
ControlSlider * slider = ControlSlider::create("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png");
|
||||
|
||||
slider->addTargetWithActionForControlEvents(this, cccontrol_selector(SchedulerTimeScale::sliderAction), ControlEventValueChanged);
|
||||
slider->addTargetWithActionForControlEvents(this, cccontrol_selector(SchedulerTimeScale::sliderAction), Control::EventType::VALUE_CHANGED);
|
||||
|
||||
slider->setMinimumValue(-3.0f);
|
||||
slider->setMaximumValue(3.0f);
|
||||
|
@ -874,7 +874,7 @@ ControlSlider* SchedulerTimeScale::sliderCtl()
|
|||
return slider;
|
||||
}
|
||||
|
||||
void SchedulerTimeScale::sliderAction(Object* pSender, ControlEvent controlEvent)
|
||||
void SchedulerTimeScale::sliderAction(Object* pSender, Control::EventType controlEvent)
|
||||
{
|
||||
ControlSlider* pSliderCtl = static_cast<ControlSlider*>(pSender);
|
||||
float scale;
|
||||
|
@ -953,7 +953,7 @@ ControlSlider *TwoSchedulers::sliderCtl()
|
|||
// CGRect frame = CGRectMake(12.0f, 12.0f, 120.0f, 7.0f);
|
||||
ControlSlider *slider = ControlSlider::create("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png");
|
||||
//[[UISlider alloc] initWithFrame:frame];
|
||||
slider->addTargetWithActionForControlEvents(this, cccontrol_selector(TwoSchedulers::sliderAction), ControlEventValueChanged);
|
||||
slider->addTargetWithActionForControlEvents(this, cccontrol_selector(TwoSchedulers::sliderAction), Control::EventType::VALUE_CHANGED);
|
||||
|
||||
// in case the parent view draws with a custom color or gradient, use a transparent color
|
||||
//slider.backgroundColor = [UIColor clearColor];
|
||||
|
@ -966,7 +966,7 @@ ControlSlider *TwoSchedulers::sliderCtl()
|
|||
return slider;
|
||||
}
|
||||
|
||||
void TwoSchedulers::sliderAction(Object* sender, ControlEvent controlEvent)
|
||||
void TwoSchedulers::sliderAction(Object* sender, Control::EventType controlEvent)
|
||||
{
|
||||
float scale;
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ public:
|
|||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
ControlSlider* sliderCtl();
|
||||
void sliderAction(Object* pSender, ControlEvent controlEvent);
|
||||
void sliderAction(Object* pSender, Control::EventType controlEvent);
|
||||
ControlSlider* _sliderCtl;
|
||||
};
|
||||
|
||||
|
@ -241,7 +241,7 @@ public:
|
|||
virtual std::string subtitle();
|
||||
void onEnter();
|
||||
ControlSlider* sliderCtl();
|
||||
void sliderAction(Object* sender, ControlEvent controlEvent);
|
||||
void sliderAction(Object* sender, Control::EventType controlEvent);
|
||||
Scheduler *sched1;
|
||||
Scheduler *sched2;
|
||||
ActionManager *actionManager1;
|
||||
|
|
|
@ -593,7 +593,7 @@ ControlSlider* ShaderBlur::createSliderCtl()
|
|||
slider->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 3.0f));
|
||||
|
||||
// When the value of the slider will change, the given selector will be call
|
||||
slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ShaderBlur::sliderAction), ControlEventValueChanged);
|
||||
slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ShaderBlur::sliderAction), Control::EventType::VALUE_CHANGED);
|
||||
|
||||
return slider;
|
||||
|
||||
|
@ -623,7 +623,7 @@ bool ShaderBlur::init()
|
|||
return false;
|
||||
}
|
||||
|
||||
void ShaderBlur::sliderAction(Object* sender, ControlEvent controlEvent)
|
||||
void ShaderBlur::sliderAction(Object* sender, Control::EventType controlEvent)
|
||||
{
|
||||
ControlSlider* pSlider = (ControlSlider*)sender;
|
||||
_blurSprite->setBlurSize(pSlider->getValue());
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
virtual std::string subtitle();
|
||||
virtual bool init();
|
||||
ControlSlider* createSliderCtl();
|
||||
void sliderAction(Object* sender, ControlEvent controlEvent);
|
||||
void sliderAction(Object* sender, Control::EventType controlEvent);
|
||||
protected:
|
||||
SpriteBlur* _blurSprite;
|
||||
ControlSlider* _sliderCtl;
|
||||
|
|
|
@ -56,7 +56,7 @@ void CCBScriptCallbackProxy::menuItemCallback(Object *pSender) {
|
|||
ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() );
|
||||
}
|
||||
|
||||
void CCBScriptCallbackProxy::controlCallback(Object *pSender, ControlEvent event) {
|
||||
void CCBScriptCallbackProxy::controlCallback(Object *pSender, Control::EventType event) {
|
||||
ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() );
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
virtual CCBSelectorResolver * createNew();
|
||||
void menuItemCallback(Object *pSender);
|
||||
void controlCallback(Object *pSender, cocos2d::extension::ControlEvent event);
|
||||
void controlCallback(Object *pSender, cocos2d::extension::Control::EventType event);
|
||||
void setCallbackProperty(const char *prop);
|
||||
void setJSOwner(jsval ownr);
|
||||
jsval getJSOwner();
|
||||
|
|
|
@ -1 +1 @@
|
|||
bfb95e6faa9b59a5045353dffbae4d7cad7d6655
|
||||
ca873cec3679fc5428aabc3ff0c1eeb585d98f1a
|
|
@ -470,7 +470,7 @@ int tolua_Cocos2d_registerControlEventHandler00(lua_State* tolua_S)
|
|||
{
|
||||
Control* control = (Control*) tolua_tousertype(tolua_S,1,0);
|
||||
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
||||
ControlEvent controlevent = (ControlEvent)tolua_tonumber(tolua_S,3,0);
|
||||
Control::EventType controlevent = (Control::EventType)tolua_tonumber(tolua_S,3,0);
|
||||
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||
{
|
||||
if ((controlevent & (1 << i)))
|
||||
|
@ -502,7 +502,7 @@ int tolua_Cocos2d_unregisterControlEventHandler00(lua_State* tolua_S)
|
|||
#endif
|
||||
{
|
||||
Control* control = (Control*) tolua_tousertype(tolua_S,1,0);
|
||||
ControlEvent controlevent = (ControlEvent)tolua_tonumber(tolua_S,2,0);
|
||||
Control::EventType controlevent = (Control::EventType)tolua_tonumber(tolua_S,2,0);
|
||||
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||
{
|
||||
if ((controlevent & (1 << i)))
|
||||
|
|
Loading…
Reference in New Issue