diff --git a/cocos/gui/UIButton.cpp b/cocos/gui/UIButton.cpp index 656d10bb25..c0d21dc2b3 100644 --- a/cocos/gui/UIButton.cpp +++ b/cocos/gui/UIButton.cpp @@ -29,10 +29,10 @@ NS_CC_BEGIN namespace gui { -#define NORMALRENDERERZ (-2) -#define PRESSEDRENDERERZ (-2) -#define DISABLEDRENDERERZ (-2) -#define TITLERENDERERZ (-1) +static const int NORMAL_RENDERER_Z = (-2); +static const int PRESSED_RENDERER_Z = (-2); +static const int DISABLED_RENDERER_Z = (-2); +static const int TITLE_RENDERER_Z = (-1); Button::Button(): _buttonNormalRenderer(nullptr), @@ -98,10 +98,10 @@ void Button::initRenderer() _buttonDisableRenderer = Sprite::create(); _titleRenderer = LabelTTF::create(); - Node::addChild(_buttonNormalRenderer, NORMALRENDERERZ, -1); - Node::addChild(_buttonClickedRenderer, PRESSEDRENDERERZ, -1); - Node::addChild(_buttonDisableRenderer, DISABLEDRENDERERZ, -1); - Node::addChild(_titleRenderer, TITLERENDERERZ, -1); + Node::addChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1); + Node::addChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1); + Node::addChild(_buttonDisableRenderer, DISABLED_RENDERER_Z, -1); + Node::addChild(_titleRenderer, TITLE_RENDERER_Z, -1); } void Button::setScale9Enabled(bool able) @@ -134,9 +134,9 @@ void Button::setScale9Enabled(bool able) loadTextureNormal(_normalFileName.c_str(), _normalTexType); loadTexturePressed(_clickedFileName.c_str(), _pressedTexType); loadTextureDisabled(_disabledFileName.c_str(), _disabledTexType); - Node::addChild(_buttonNormalRenderer, NORMALRENDERERZ, -1); - Node::addChild(_buttonClickedRenderer, PRESSEDRENDERERZ, -1); - Node::addChild(_buttonDisableRenderer, DISABLEDRENDERERZ, -1); + Node::addChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1); + Node::addChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1); + Node::addChild(_buttonDisableRenderer, DISABLED_RENDERER_Z, -1); if (_scale9Enabled) { bool ignoreBefore = _ignoreSize; diff --git a/cocos/gui/UICheckBox.cpp b/cocos/gui/UICheckBox.cpp index 27d447bc74..b255cfe49c 100644 --- a/cocos/gui/UICheckBox.cpp +++ b/cocos/gui/UICheckBox.cpp @@ -28,11 +28,11 @@ NS_CC_BEGIN namespace gui { -#define BACKGROUNDBOXRENDERERZ (-1) -#define BACKGROUNDSELECTEDBOXRENDERERZ (-1) -#define FRONTCROSSRENDERERZ (-1) -#define BACKGROUNDBOXDISABLEDRENDERERZ (-1) -#define FRONTCROSSDISABLEDRENDERERZ (-1) +static const int BACKGROUNDBOX_RENDERER_Z = (-1); +static const int BACKGROUNDSELECTEDBOX_RENDERER_Z = (-1); +static const int FRONTCROSS_RENDERER_Z = (-1); +static const int BACKGROUNDBOXDISABLED_RENDERER_Z = (-1); +static const int FRONTCROSSDISABLED_RENDERER_Z = (-1); CheckBox::CheckBox(): _backGroundBoxRenderer(nullptr), @@ -92,11 +92,11 @@ void CheckBox::initRenderer() _backGroundBoxDisabledRenderer = Sprite::create(); _frontCrossDisabledRenderer = Sprite::create(); - Node::addChild(_backGroundBoxRenderer, BACKGROUNDBOXRENDERERZ, -1); - Node::addChild(_backGroundSelectedBoxRenderer, BACKGROUNDSELECTEDBOXRENDERERZ, -1); - Node::addChild(_frontCrossRenderer, FRONTCROSSRENDERERZ, -1); - Node::addChild(_backGroundBoxDisabledRenderer, BACKGROUNDBOXDISABLEDRENDERERZ, -1); - Node::addChild(_frontCrossDisabledRenderer, FRONTCROSSDISABLEDRENDERERZ, -1); + Node::addChild(_backGroundBoxRenderer, BACKGROUNDBOX_RENDERER_Z, -1); + Node::addChild(_backGroundSelectedBoxRenderer, BACKGROUNDSELECTEDBOX_RENDERER_Z, -1); + Node::addChild(_frontCrossRenderer, FRONTCROSS_RENDERER_Z, -1); + Node::addChild(_backGroundBoxDisabledRenderer, BACKGROUNDBOXDISABLED_RENDERER_Z, -1); + Node::addChild(_frontCrossDisabledRenderer, FRONTCROSSDISABLED_RENDERER_Z, -1); } void CheckBox::loadTextures(const char *backGround, const char *backGroundSelected, const char *cross,const char* backGroundDisabled,const char* frontCrossDisabled,TextureResType texType) diff --git a/cocos/gui/UIImageView.cpp b/cocos/gui/UIImageView.cpp index c228c5a513..fd2a0640c5 100644 --- a/cocos/gui/UIImageView.cpp +++ b/cocos/gui/UIImageView.cpp @@ -33,7 +33,7 @@ namespace gui { #define STATIC_CAST_CCSPRITE static_cast(_imageRenderer) #define STATIC_CAST_SCALE9SPRITE static_cast(_imageRenderer) -#define IMAGERENDERERZ (-1) +static const int IMAGE_RENDERER_Z = (-1); ImageView::ImageView(): _scale9Enabled(false), @@ -67,7 +67,7 @@ ImageView* ImageView::create() void ImageView::initRenderer() { _imageRenderer = Sprite::create(); - Node::addChild(_imageRenderer, IMAGERENDERERZ, -1); + Node::addChild(_imageRenderer, IMAGE_RENDERER_Z, -1); } void ImageView::loadTexture(const char *fileName, TextureResType texType) @@ -193,7 +193,7 @@ void ImageView::setScale9Enabled(bool able) _imageRenderer = Sprite::create(); } loadTexture(_textureFile.c_str(),_imageTexType); - Node::addChild(_imageRenderer, IMAGERENDERERZ, -1); + Node::addChild(_imageRenderer, IMAGE_RENDERER_Z, -1); if (_scale9Enabled) { bool ignoreBefore = _ignoreSize; diff --git a/cocos/gui/UILayout.cpp b/cocos/gui/UILayout.cpp index 9d511283a8..9c7085432c 100644 --- a/cocos/gui/UILayout.cpp +++ b/cocos/gui/UILayout.cpp @@ -30,8 +30,8 @@ NS_CC_BEGIN namespace gui { -#define BACKGROUNDIMAGEZ (-1) -#define BCAKGROUNDCOLORRENDERERZ (-2) +static const int BACKGROUNDIMAGE_Z = (-1); +static const int BCAKGROUNDCOLORRENDERER_Z = (-2); static GLint g_sStencilBits = -1; @@ -428,12 +428,12 @@ void Layout::setBackGroundImageScale9Enabled(bool able) if (_backGroundScale9Enabled) { _backGroundImage = extension::Scale9Sprite::create(); - Node::addChild(_backGroundImage, BACKGROUNDIMAGEZ, -1); + Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); } else { _backGroundImage = Sprite::create(); - Node::addChild(_backGroundImage, BACKGROUNDIMAGEZ, -1); + Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); } setBackGroundImage(_backGroundImageFileName.c_str(),_bgImageTexType); setBackGroundImageCapInsets(_backGroundImageCapInsets); @@ -546,14 +546,14 @@ void Layout::addBackGroundImage() { _backGroundImage = extension::Scale9Sprite::create(); _backGroundImage->setZOrder(-1); - Node::addChild(_backGroundImage, BACKGROUNDIMAGEZ, -1); + Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); static_cast(_backGroundImage)->setPreferredSize(_size); } else { _backGroundImage = Sprite::create(); _backGroundImage->setZOrder(-1); - Node::addChild(_backGroundImage, BACKGROUNDIMAGEZ, -1); + Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); } _backGroundImage->setPosition(Point(_size.width/2.0f, _size.height/2.0f)); } @@ -617,7 +617,7 @@ void Layout::setBackGroundColorType(LayoutBackGroundColorType type) _colorRender->setContentSize(_size); _colorRender->setOpacity(_cOpacity); _colorRender->setColor(_cColor); - Node::addChild(_colorRender, BACKGROUNDIMAGEZ, -1); + Node::addChild(_colorRender, BCAKGROUNDCOLORRENDERER_Z, -1); break; case LAYOUT_COLOR_GRADIENT: _gradientRender = LayerGradient::create(); @@ -626,7 +626,7 @@ void Layout::setBackGroundColorType(LayoutBackGroundColorType type) _gradientRender->setStartColor(_gStartColor); _gradientRender->setEndColor(_gEndColor); _gradientRender->setVector(_alongVector); - Node::addChild(_gradientRender, BACKGROUNDIMAGEZ, -1); + Node::addChild(_gradientRender, BCAKGROUNDCOLORRENDERER_Z, -1); break; default: break; diff --git a/cocos/gui/UILoadingBar.cpp b/cocos/gui/UILoadingBar.cpp index aec388a8c0..38ca9a3764 100644 --- a/cocos/gui/UILoadingBar.cpp +++ b/cocos/gui/UILoadingBar.cpp @@ -29,7 +29,7 @@ NS_CC_BEGIN namespace gui { -#define BARRENDERERZ (-1) +static const int BAR_RENDERER_Z = (-1); LoadingBar::LoadingBar(): _barType(LoadingBarTypeLeft), @@ -65,7 +65,7 @@ LoadingBar* LoadingBar::create() void LoadingBar::initRenderer() { _barRenderer = Sprite::create(); - Node::addChild(_barRenderer, BARRENDERERZ, -1); + Node::addChild(_barRenderer, BAR_RENDERER_Z, -1); _barRenderer->setAnchorPoint(Point(0.0,0.5)); } @@ -182,7 +182,7 @@ void LoadingBar::setScale9Enabled(bool enabled) _barRenderer = Sprite::create(); } loadTexture(_textureFile.c_str(),_renderBarTexType); - Node::addChild(_barRenderer, BARRENDERERZ, -1); + Node::addChild(_barRenderer, BAR_RENDERER_Z, -1); if (_scale9Enabled) { bool ignoreBefore = _ignoreSize; diff --git a/cocos/gui/UIScrollView.cpp b/cocos/gui/UIScrollView.cpp index 436cb52ea7..7a5614faff 100644 --- a/cocos/gui/UIScrollView.cpp +++ b/cocos/gui/UIScrollView.cpp @@ -28,7 +28,7 @@ NS_CC_BEGIN namespace gui { -#define AUTOSCROLLMAXSPEED 1000.0f +static const float AUTOSCROLLMAXSPEED = 1000.0f; const Point SCROLLDIR_UP = Point(0.0f, 1.0f); const Point SCROLLDIR_DOWN = Point(0.0f, -1.0f); diff --git a/cocos/gui/UISlider.cpp b/cocos/gui/UISlider.cpp index 30fc583524..cad6f3d763 100644 --- a/cocos/gui/UISlider.cpp +++ b/cocos/gui/UISlider.cpp @@ -29,9 +29,9 @@ NS_CC_BEGIN namespace gui { -#define BASEBARRENDERERZ (-2) -#define PROGRESSBARRENDERERZ (-2) -#define SLIDBALLRENDERERZ (-1) +static const int BASEBAR_RENDERER_Z = (-2); +static const int PROGRESSBAR_RENDERER_Z = (-2); +static const int SLIDBALL_RENDERER_Z = (-1); Slider::Slider(): _barRenderer(nullptr), @@ -85,8 +85,8 @@ void Slider::initRenderer() _barRenderer = Sprite::create(); _progressBarRenderer = Sprite::create(); _progressBarRenderer->setAnchorPoint(Point(0.0f, 0.5f)); - Node::addChild(_barRenderer, BASEBARRENDERERZ, -1); - Node::addChild(_progressBarRenderer, PROGRESSBARRENDERERZ, -1); + Node::addChild(_barRenderer, BASEBAR_RENDERER_Z, -1); + Node::addChild(_progressBarRenderer, PROGRESSBAR_RENDERER_Z, -1); _slidBallNormalRenderer = Sprite::create(); _slidBallPressedRenderer = Sprite::create(); _slidBallPressedRenderer->setVisible(false); @@ -96,7 +96,7 @@ void Slider::initRenderer() _slidBallRenderer->addChild(_slidBallNormalRenderer); _slidBallRenderer->addChild(_slidBallPressedRenderer); _slidBallRenderer->addChild(_slidBallDisabledRenderer); - Node::addChild(_slidBallRenderer, SLIDBALLRENDERERZ, -1); + Node::addChild(_slidBallRenderer, SLIDBALL_RENDERER_Z, -1); } void Slider::loadBarTexture(const char* fileName, TextureResType texType) @@ -201,8 +201,8 @@ void Slider::setScale9Enabled(bool able) } loadBarTexture(_textureFile.c_str(), _barTexType); loadProgressBarTexture(_progressBarTextureFile.c_str(), _progressBarTexType); - Node::addChild(_barRenderer, BASEBARRENDERERZ, -1); - Node::addChild(_progressBarRenderer, PROGRESSBARRENDERERZ, -1); + Node::addChild(_barRenderer, BASEBAR_RENDERER_Z, -1); + Node::addChild(_progressBarRenderer, PROGRESSBAR_RENDERER_Z, -1); if (_scale9Enabled) { bool ignoreBefore = _ignoreSize; diff --git a/cocos/gui/UIText.cpp b/cocos/gui/UIText.cpp index a57c2c5b3b..91815575b1 100644 --- a/cocos/gui/UIText.cpp +++ b/cocos/gui/UIText.cpp @@ -28,7 +28,7 @@ NS_CC_BEGIN namespace gui { -#define LABELRENDERERZ (-1) +static const int LABEL_RENDERER_Z = (-1); Text::Text(): _touchScaleChangeEnabled(false), @@ -70,7 +70,7 @@ bool Text::init() void Text::initRenderer() { _labelRenderer = LabelTTF::create(); - Node::addChild(_labelRenderer, LABELRENDERERZ, -1); + Node::addChild(_labelRenderer, LABEL_RENDERER_Z, -1); } void Text::setText(const std::string& text) diff --git a/cocos/gui/UITextAtlas.cpp b/cocos/gui/UITextAtlas.cpp index cd1d2c0609..9e5444ab60 100644 --- a/cocos/gui/UITextAtlas.cpp +++ b/cocos/gui/UITextAtlas.cpp @@ -28,7 +28,7 @@ NS_CC_BEGIN namespace gui { -#define LABELATLASRENDERERZ (-1) +static const int LABELATLAS_RENDERER_Z = (-1); UICCLabelAtlas::UICCLabelAtlas() @@ -107,7 +107,7 @@ TextAtlas* TextAtlas::create() void TextAtlas::initRenderer() { _labelAtlasRenderer = UICCLabelAtlas::create(); - Node::addChild(_labelAtlasRenderer, LABELATLASRENDERERZ, -1); + Node::addChild(_labelAtlasRenderer, LABELATLAS_RENDERER_Z, -1); } void TextAtlas::setProperty(const std::string& stringValue, const std::string& charMapFile, int itemWidth, int itemHeight, const std::string& startCharMap) diff --git a/cocos/gui/UITextBMFont.cpp b/cocos/gui/UITextBMFont.cpp index f062a884b8..846ed82876 100644 --- a/cocos/gui/UITextBMFont.cpp +++ b/cocos/gui/UITextBMFont.cpp @@ -28,7 +28,7 @@ NS_CC_BEGIN namespace gui { -#define LABELBMFONTRENDERERZ (-1) +static const int LABELBMFONT_RENDERER_Z = (-1); TextBMFont::TextBMFont(): _labelBMFontRenderer(nullptr), @@ -58,7 +58,7 @@ TextBMFont* TextBMFont::create() void TextBMFont::initRenderer() { _labelBMFontRenderer = cocos2d::LabelBMFont::create(); - Node::addChild(_labelBMFontRenderer, LABELBMFONTRENDERERZ, -1); + Node::addChild(_labelBMFontRenderer, LABELBMFONT_RENDERER_Z, -1); } void TextBMFont::setFntFile(const char *fileName) diff --git a/cocos/gui/UITextField.cpp b/cocos/gui/UITextField.cpp index 217f1ed481..58cf592df7 100644 --- a/cocos/gui/UITextField.cpp +++ b/cocos/gui/UITextField.cpp @@ -269,7 +269,7 @@ bool UICCTextField::getDeleteBackward() return _deleteBackward; } -#define TEXTFIELDRENDERERZ (-1) +static const int TEXTFIELD_RENDERER_Z = (-1); TextField::TextField(): @@ -314,7 +314,7 @@ bool TextField::init() void TextField::initRenderer() { _textFieldRenderer = UICCTextField::create("input words here", "Thonburi", 20); - Node::addChild(_textFieldRenderer, TEXTFIELDRENDERERZ, -1); + Node::addChild(_textFieldRenderer, TEXTFIELD_RENDERER_Z, -1); } void TextField::setTouchSize(const Size &size)