mirror of https://github.com/axmolengine/axmol.git
issue #2430:move Menu enum into class
This commit is contained in:
parent
77afae124b
commit
beb192ecaa
|
@ -45,7 +45,7 @@ const Color3B ccBLACK = Color3B::BLACK;
|
|||
const Color3B ccORANGE = Color3B::ORANGE;
|
||||
const Color3B ccGRAY = Color3B::GRAY;
|
||||
|
||||
const BlendFunc kBlendFuncDisable = BlendFunc::BLEND_FUNC_DISABLE;
|
||||
const BlendFunc kCCBlendFuncDisable = BlendFunc::BLEND_FUNC_DISABLE;
|
||||
|
||||
const int kCCVertexAttrib_Position = GLProgram::VERTEX_ATTRIB_POSITION;
|
||||
const int kCCVertexAttrib_Color = GLProgram::VERTEX_ATTRIB_COLOR;
|
||||
|
@ -138,4 +138,8 @@ const int kCCTexture2DPixelFormat_PVRTC4 = Texture2D::PIXEL_FORMAT_PRVTC4;
|
|||
const int kCCTexture2DPixelFormat_PVRTC2 = Texture2D::PIXEL_FORMAT_PRVTC2;
|
||||
const int kCCTexture2DPixelFormat_Default = Texture2D::PIXEL_FORMAT_DEFAULT;
|
||||
|
||||
const int kCCMenuHandlerPriority = Menu::HANDLER_PRIORITY;
|
||||
const int kCCMenuStateWaiting = Menu::STATE_WAITING;
|
||||
const int kCCMenuStateTrackingTouch = Menu::STATE_TRACKING_TOUCH;
|
||||
|
||||
NS_CC_END
|
|
@ -409,7 +409,7 @@ CC_DEPRECATED_ATTRIBUTE extern const Color3B ccBLACK;
|
|||
CC_DEPRECATED_ATTRIBUTE extern const Color3B ccORANGE;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Color3B ccGRAY;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const BlendFunc kBlendFuncDisable;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const BlendFunc kCCBlendFuncDisable;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE static inline Color3B ccc3(GLubyte r, GLubyte g, GLubyte b)
|
||||
{
|
||||
|
@ -893,11 +893,10 @@ CC_DEPRECATED_ATTRIBUTE extern const int kCCPositionTypeRelative;
|
|||
CC_DEPRECATED_ATTRIBUTE extern const int kCCPositionTypeGrouped;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef enum ParticleSystem::PositionType tPositionType;
|
||||
|
||||
#define kCCBlendFuncDisable kBlendFuncDisable
|
||||
|
||||
#define kCCMenuHandlerPriority kMenuHandlerPriority
|
||||
#define kCCMenuStateWaiting kMenuStateWaiting
|
||||
#define kCCMenuStateTrackingTouch kMenuStateTrackingTouch
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCMenuHandlerPriority;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCMenuStateWaiting;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCMenuStateTrackingTouch;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef enum Menu::State tMenuState;
|
||||
|
||||
#define kCCTouchesOneByOne kTouchesOneByOne
|
||||
#define kCCTouchesAllAtOnce kTouchesAllAtOnce
|
||||
|
|
|
@ -121,7 +121,7 @@ bool Menu::initWithArray(Array* pArrayOfItems)
|
|||
{
|
||||
if (Layer::init())
|
||||
{
|
||||
setTouchPriority(kMenuHandlerPriority);
|
||||
setTouchPriority(Menu::HANDLER_PRIORITY);
|
||||
setTouchMode(kTouchesOneByOne);
|
||||
setTouchEnabled(true);
|
||||
|
||||
|
@ -149,7 +149,7 @@ bool Menu::initWithArray(Array* pArrayOfItems)
|
|||
|
||||
// [self alignItemsVertically];
|
||||
_selectedItem = NULL;
|
||||
_state = kMenuStateWaiting;
|
||||
_state = Menu::STATE_WAITING;
|
||||
|
||||
// enable cascade color and opacity on menus
|
||||
setCascadeColorEnabled(true);
|
||||
|
@ -181,7 +181,7 @@ void Menu::addChild(Node * child, int zOrder, int tag)
|
|||
|
||||
void Menu::onExit()
|
||||
{
|
||||
if (_state == kMenuStateTrackingTouch)
|
||||
if (_state == Menu::STATE_TRACKING_TOUCH)
|
||||
{
|
||||
if (_selectedItem)
|
||||
{
|
||||
|
@ -189,7 +189,7 @@ void Menu::onExit()
|
|||
_selectedItem = NULL;
|
||||
}
|
||||
|
||||
_state = kMenuStateWaiting;
|
||||
_state = Menu::STATE_WAITING;
|
||||
}
|
||||
|
||||
Layer::onExit();
|
||||
|
@ -225,7 +225,7 @@ void Menu::registerWithTouchDispatcher()
|
|||
bool Menu::ccTouchBegan(Touch* touch, Event* event)
|
||||
{
|
||||
CC_UNUSED_PARAM(event);
|
||||
if (_state != kMenuStateWaiting || ! _visible || !_enabled)
|
||||
if (_state != Menu::STATE_WAITING || ! _visible || !_enabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ bool Menu::ccTouchBegan(Touch* touch, Event* event)
|
|||
_selectedItem = this->itemForTouch(touch);
|
||||
if (_selectedItem)
|
||||
{
|
||||
_state = kMenuStateTrackingTouch;
|
||||
_state = Menu::STATE_TRACKING_TOUCH;
|
||||
_selectedItem->selected();
|
||||
return true;
|
||||
}
|
||||
|
@ -252,31 +252,31 @@ void Menu::ccTouchEnded(Touch *touch, Event* event)
|
|||
{
|
||||
CC_UNUSED_PARAM(touch);
|
||||
CC_UNUSED_PARAM(event);
|
||||
CCASSERT(_state == kMenuStateTrackingTouch, "[Menu ccTouchEnded] -- invalid state");
|
||||
CCASSERT(_state == Menu::STATE_TRACKING_TOUCH, "[Menu ccTouchEnded] -- invalid state");
|
||||
if (_selectedItem)
|
||||
{
|
||||
_selectedItem->unselected();
|
||||
_selectedItem->activate();
|
||||
}
|
||||
_state = kMenuStateWaiting;
|
||||
_state = Menu::STATE_WAITING;
|
||||
}
|
||||
|
||||
void Menu::ccTouchCancelled(Touch *touch, Event* event)
|
||||
{
|
||||
CC_UNUSED_PARAM(touch);
|
||||
CC_UNUSED_PARAM(event);
|
||||
CCASSERT(_state == kMenuStateTrackingTouch, "[Menu ccTouchCancelled] -- invalid state");
|
||||
CCASSERT(_state == Menu::STATE_TRACKING_TOUCH, "[Menu ccTouchCancelled] -- invalid state");
|
||||
if (_selectedItem)
|
||||
{
|
||||
_selectedItem->unselected();
|
||||
}
|
||||
_state = kMenuStateWaiting;
|
||||
_state = Menu::STATE_WAITING;
|
||||
}
|
||||
|
||||
void Menu::ccTouchMoved(Touch* touch, Event* event)
|
||||
{
|
||||
CC_UNUSED_PARAM(event);
|
||||
CCASSERT(_state == kMenuStateTrackingTouch, "[Menu ccTouchMoved] -- invalid state");
|
||||
CCASSERT(_state == Menu::STATE_TRACKING_TOUCH, "[Menu ccTouchMoved] -- invalid state");
|
||||
MenuItem *currentItem = this->itemForTouch(touch);
|
||||
if (currentItem != _selectedItem)
|
||||
{
|
||||
|
|
|
@ -36,16 +36,8 @@ NS_CC_BEGIN
|
|||
* @addtogroup menu
|
||||
* @{
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
kMenuStateWaiting,
|
||||
kMenuStateTrackingTouch
|
||||
} tMenuState;
|
||||
|
||||
enum {
|
||||
//* priority used by the menu for the event handler
|
||||
kMenuHandlerPriority = -128,
|
||||
};
|
||||
|
||||
|
||||
/** @brief A Menu
|
||||
*
|
||||
|
@ -56,6 +48,17 @@ enum {
|
|||
class CC_DLL Menu : public LayerRGBA
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
HANDLER_PRIORITY = -128,
|
||||
};
|
||||
|
||||
enum State
|
||||
{
|
||||
STATE_WAITING,
|
||||
STATE_TRACKING_TOUCH,
|
||||
};
|
||||
|
||||
/** creates an empty Menu */
|
||||
static Menu* create();
|
||||
|
||||
|
@ -133,7 +136,7 @@ protected:
|
|||
bool _enabled;
|
||||
|
||||
MenuItem* itemForTouch(Touch * touch);
|
||||
tMenuState _state;
|
||||
State _state;
|
||||
MenuItem *_selectedItem;
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ enum {
|
|||
MenuLayerMainMenu::MenuLayerMainMenu()
|
||||
{
|
||||
setTouchEnabled(true);
|
||||
setTouchPriority(kMenuHandlerPriority + 1);
|
||||
setTouchPriority(Menu::HANDLER_PRIORITY + 1);
|
||||
setTouchMode(kTouchesOneByOne);
|
||||
|
||||
// Font Item
|
||||
|
@ -149,7 +149,7 @@ void MenuLayerMainMenu::menuCallbackConfig(Object* sender)
|
|||
void MenuLayerMainMenu::allowTouches(float dt)
|
||||
{
|
||||
Director* director = Director::getInstance();
|
||||
director->getTouchDispatcher()->setPriority(kMenuHandlerPriority+1, this);
|
||||
director->getTouchDispatcher()->setPriority(Menu::HANDLER_PRIORITY+1, this);
|
||||
unscheduleAllSelectors();
|
||||
log("TOUCHES ALLOWED AGAIN");
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ void MenuLayerMainMenu::menuCallbackDisabled(Object* sender)
|
|||
{
|
||||
// hijack all touch events for 5 seconds
|
||||
Director* director = Director::getInstance();
|
||||
director->getTouchDispatcher()->setPriority(kMenuHandlerPriority-1, this);
|
||||
director->getTouchDispatcher()->setPriority(Menu::HANDLER_PRIORITY-1, this);
|
||||
schedule(schedule_selector(MenuLayerMainMenu::allowTouches), 5.0f);
|
||||
log("TOUCHES DISABLED FOR 5 SECONDS");
|
||||
}
|
||||
|
@ -491,10 +491,10 @@ MenuLayerPriorityTest::MenuLayerPriorityTest()
|
|||
MenuItemFont::setFontSize(48);
|
||||
item1 = MenuItemFont::create("Toggle priority", [&](Object *sender) {
|
||||
if( _priority) {
|
||||
_menu2->setHandlerPriority(kMenuHandlerPriority + 20);
|
||||
_menu2->setHandlerPriority(Menu::HANDLER_PRIORITY + 20);
|
||||
_priority = false;
|
||||
} else {
|
||||
_menu2->setHandlerPriority(kMenuHandlerPriority - 20);
|
||||
_menu2->setHandlerPriority(Menu::HANDLER_PRIORITY - 20);
|
||||
_priority = true;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
2aa796ad26412cb737af83183fdf70095a9c3567
|
||||
de01748799b69d22f96ac8a3a4b9126f4238b38b
|
Loading…
Reference in New Issue