diff --git a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp index fe475ed136..b26507dbe5 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp @@ -48,22 +48,22 @@ namespace cocostudio const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, "normalData"); int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType"); - std::string normalTexturePath = this->getResourcePath(normalDic, "path", (TextureResType)normalType); - button->loadTextureNormal(normalTexturePath, (TextureResType)normalType); + std::string normalTexturePath = this->getResourcePath(normalDic, "path", (Widget::TextureResType)normalType); + button->loadTextureNormal(normalTexturePath, (Widget::TextureResType)normalType); const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, "pressedData"); int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType"); - std::string pressedTexturePath = this->getResourcePath(pressedDic, "path", (TextureResType)pressedType); - button->loadTexturePressed(pressedTexturePath, (TextureResType)pressedType); + std::string pressedTexturePath = this->getResourcePath(pressedDic, "path", (Widget::TextureResType)pressedType); + button->loadTexturePressed(pressedTexturePath, (Widget::TextureResType)pressedType); const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, "disabledData"); int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType"); - std::string disabledTexturePath = this->getResourcePath(disabledDic, "path", (TextureResType)disabledType); - button->loadTextureDisabled(disabledTexturePath, (TextureResType)disabledType); + std::string disabledTexturePath = this->getResourcePath(disabledDic, "path", (Widget::TextureResType)disabledType); + button->loadTextureDisabled(disabledTexturePath, (Widget::TextureResType)disabledType); if (scale9Enable) { diff --git a/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp index 72bc3193d8..0d24ac68b2 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp @@ -41,32 +41,32 @@ namespace cocostudio //load background image const rapidjson::Value& backGroundDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxData"); int backGroundType = DICTOOL->getIntValue_json(backGroundDic, "resourceType"); - std::string backGroundTexturePath = this->getResourcePath(backGroundDic, "path", (TextureResType)backGroundType); - checkBox->loadTextureBackGround(backGroundTexturePath, (TextureResType)backGroundType); + std::string backGroundTexturePath = this->getResourcePath(backGroundDic, "path", (Widget::TextureResType)backGroundType); + checkBox->loadTextureBackGround(backGroundTexturePath, (Widget::TextureResType)backGroundType); //load background selected image const rapidjson::Value& backGroundSelectedDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxSelectedData"); int backGroundSelectedType = DICTOOL->getIntValue_json(backGroundSelectedDic, "resourceType"); - std::string backGroundSelectedTexturePath = this->getResourcePath(backGroundSelectedDic, "path", (TextureResType)backGroundSelectedType); - checkBox->loadTextureBackGroundSelected(backGroundSelectedTexturePath, (TextureResType)backGroundSelectedType); + std::string backGroundSelectedTexturePath = this->getResourcePath(backGroundSelectedDic, "path", (Widget::TextureResType)backGroundSelectedType); + checkBox->loadTextureBackGroundSelected(backGroundSelectedTexturePath, (Widget::TextureResType)backGroundSelectedType); //load frontCross image const rapidjson::Value& frontCrossDic = DICTOOL->getSubDictionary_json(options, "frontCrossData"); int frontCrossType = DICTOOL->getIntValue_json(frontCrossDic, "resourceType"); - std::string frontCrossFileName = this->getResourcePath(frontCrossDic, "path", (TextureResType)frontCrossType); - checkBox->loadTextureFrontCross(frontCrossFileName, (TextureResType)frontCrossType); + std::string frontCrossFileName = this->getResourcePath(frontCrossDic, "path", (Widget::TextureResType)frontCrossType); + checkBox->loadTextureFrontCross(frontCrossFileName, (Widget::TextureResType)frontCrossType); //load backGroundBoxDisabledData const rapidjson::Value& backGroundDisabledDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxDisabledData"); int backGroundDisabledType = DICTOOL->getIntValue_json(backGroundDisabledDic, "resourceType"); - std::string backGroundDisabledFileName = this->getResourcePath(backGroundDisabledDic, "path", (TextureResType)backGroundDisabledType); - checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName, (TextureResType)backGroundDisabledType); + std::string backGroundDisabledFileName = this->getResourcePath(backGroundDisabledDic, "path", (Widget::TextureResType)backGroundDisabledType); + checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName, (Widget::TextureResType)backGroundDisabledType); ///load frontCrossDisabledData const rapidjson::Value& frontCrossDisabledDic = DICTOOL->getSubDictionary_json(options, "frontCrossDisabledData"); int frontCrossDisabledType = DICTOOL->getIntValue_json(frontCrossDisabledDic, "resourceType"); - std::string frontCrossDisabledFileName = this->getResourcePath(frontCrossDisabledDic, "path", (TextureResType)frontCrossDisabledType); - checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName, (TextureResType)frontCrossDisabledType); + std::string frontCrossDisabledFileName = this->getResourcePath(frontCrossDisabledDic, "path", (Widget::TextureResType)frontCrossDisabledType); + checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName, (Widget::TextureResType)frontCrossDisabledType); WidgetReader::setColorPropsFromJsonDictionary(widget, options); diff --git a/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp index 42b05593e0..7518098731 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp @@ -41,8 +41,8 @@ namespace cocostudio const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "fileNameData"); int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType); - imageView->loadTexture(imageFileName, (TextureResType)imageFileNameType); + std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (Widget::TextureResType)imageFileNameType); + imageView->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType); bool scale9EnableExist = DICTOOL->checkObjectExist_json(options, "scale9Enable"); diff --git a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp index edcf5aead1..fcc690e3b6 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp @@ -85,8 +85,8 @@ namespace cocostudio const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "backGroundImageData"); int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType); - panel->setBackGroundImage(imageFileName, (TextureResType)imageFileNameType); + std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (Widget::TextureResType)imageFileNameType); + panel->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType); if (backGroundScale9Enable) diff --git a/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp index caa6bc2714..6b5c77785d 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp @@ -40,8 +40,8 @@ namespace cocostudio const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "textureData"); int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType); - loadingBar->loadTexture(imageFileName, (TextureResType)imageFileNameType); + std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (Widget::TextureResType)imageFileNameType); + loadingBar->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType); /* gui mark add load bar scale9 parse */ diff --git a/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp index 564dd1866b..ca92886ef6 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp @@ -50,8 +50,8 @@ namespace cocostudio { const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "barFileNameData"); int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType); - slider->loadBarTexture(imageFileName, (TextureResType)imageFileNameType); + std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (Widget::TextureResType)imageFileNameType); + slider->loadBarTexture(imageFileName, (Widget::TextureResType)imageFileNameType); if (barTextureScale9Enable) { @@ -62,27 +62,27 @@ namespace cocostudio //loading normal slider ball texture const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, "ballNormalData"); int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType"); - std::string imageFileName = this->getResourcePath(normalDic, "path", (TextureResType)normalType); - slider->loadSlidBallTextureNormal(imageFileName, (TextureResType)normalType); + std::string imageFileName = this->getResourcePath(normalDic, "path", (Widget::TextureResType)normalType); + slider->loadSlidBallTextureNormal(imageFileName, (Widget::TextureResType)normalType); //loading slider ball press texture const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, "ballPressedData"); int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType"); - std::string pressedFileName = this->getResourcePath(pressedDic, "path", (TextureResType)pressedType); - slider->loadSlidBallTexturePressed(pressedFileName, (TextureResType)pressedType); + std::string pressedFileName = this->getResourcePath(pressedDic, "path", (Widget::TextureResType)pressedType); + slider->loadSlidBallTexturePressed(pressedFileName, (Widget::TextureResType)pressedType); //loading silder ball disable texture const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, "ballDisabledData"); int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType"); - std::string disabledFileName = this->getResourcePath(disabledDic, "path", (TextureResType)disabledType); - slider->loadSlidBallTextureDisabled(disabledFileName, (TextureResType)disabledType); + std::string disabledFileName = this->getResourcePath(disabledDic, "path", (Widget::TextureResType)disabledType); + slider->loadSlidBallTextureDisabled(disabledFileName, (Widget::TextureResType)disabledType); //load slider progress texture const rapidjson::Value& progressBarDic = DICTOOL->getSubDictionary_json(options, "progressBarData"); int progressBarType = DICTOOL->getIntValue_json(progressBarDic, "resourceType"); - std::string progressBarFileName = this->getResourcePath(progressBarDic, "path", (TextureResType)progressBarType); - slider->loadProgressBarTexture(progressBarFileName, (TextureResType)progressBarType); + std::string progressBarFileName = this->getResourcePath(progressBarDic, "path", (Widget::TextureResType)progressBarType); + slider->loadProgressBarTexture(progressBarFileName, (Widget::TextureResType)progressBarType); diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp index f511bf3605..cdcd9b841b 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp @@ -175,17 +175,17 @@ namespace cocostudio std::string WidgetReader::getResourcePath(const rapidjson::Value &dict, const std::string &key, - cocos2d::ui::TextureResType texType) + cocos2d::ui::Widget::TextureResType texType) { std::string jsonPath = GUIReader::getInstance()->getFilePath(); const char* imageFileName = DICTOOL->getStringValue_json(dict, key.c_str()); std::string imageFileName_tp; if (nullptr != imageFileName) { - if (texType == UI_TEX_TYPE_LOCAL) { + if (texType == ui::Widget::TextureResType::LOCAL) { imageFileName_tp = jsonPath + imageFileName; } - else if(texType == UI_TEX_TYPE_PLIST){ + else if(texType == ui::Widget::TextureResType::PLIST){ imageFileName_tp = imageFileName; } else{ diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h index fe0bb7c5c8..681f02224a 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h @@ -52,7 +52,7 @@ namespace cocostudio protected: std::string getResourcePath(const rapidjson::Value& dict, const std::string& key, - cocos2d::ui::TextureResType texType); + cocos2d::ui::Widget::TextureResType texType); }; } diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 3faf819508..f61d1e096c 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -49,9 +49,9 @@ _scale9Enabled(false), _capInsetsNormal(Rect::ZERO), _capInsetsPressed(Rect::ZERO), _capInsetsDisabled(Rect::ZERO), -_normalTexType(UI_TEX_TYPE_LOCAL), -_pressedTexType(UI_TEX_TYPE_LOCAL), -_disabledTexType(UI_TEX_TYPE_LOCAL), +_normalTexType(TextureResType::LOCAL), +_pressedTexType(TextureResType::LOCAL), +_disabledTexType(TextureResType::LOCAL), _normalTextureSize(_size), _pressedTextureSize(_size), _disabledTextureSize(_size), @@ -229,10 +229,10 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType) extension::Scale9Sprite* normalRendererScale9 = static_cast(_buttonNormalRenderer); switch (_normalTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: normalRendererScale9->initWithFile(normal); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: normalRendererScale9->initWithSpriteFrameName(normal); break; default: @@ -245,10 +245,10 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType) Sprite* normalRenderer = static_cast(_buttonNormalRenderer); switch (_normalTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: normalRenderer->setTexture(normal); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: normalRenderer->setSpriteFrame(normal); break; default: @@ -277,10 +277,10 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy extension::Scale9Sprite* clickedRendererScale9 = static_cast(_buttonClickedRenderer); switch (_pressedTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: clickedRendererScale9->initWithFile(selected); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: clickedRendererScale9->initWithSpriteFrameName(selected); break; default: @@ -293,10 +293,10 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy Sprite* clickedRenderer = static_cast(_buttonClickedRenderer); switch (_pressedTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: clickedRenderer->setTexture(selected); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: clickedRenderer->setSpriteFrame(selected); break; default: @@ -324,10 +324,10 @@ void Button::loadTextureDisabled(const std::string& disabled,TextureResType texT extension::Scale9Sprite* disabledScale9 = static_cast(_buttonDisableRenderer); switch (_disabledTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: disabledScale9->initWithFile(disabled); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: disabledScale9->initWithSpriteFrameName(disabled); break; default: @@ -340,10 +340,10 @@ void Button::loadTextureDisabled(const std::string& disabled,TextureResType texT Sprite* disabledRenderer = static_cast(_buttonDisableRenderer); switch (_disabledTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: disabledRenderer->setTexture(disabled); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: disabledRenderer->setSpriteFrame(disabled); break; default: diff --git a/cocos/ui/UIButton.h b/cocos/ui/UIButton.h index a67cfdd064..3f37b4554a 100644 --- a/cocos/ui/UIButton.h +++ b/cocos/ui/UIButton.h @@ -66,7 +66,7 @@ public: static Button* create(const std::string& normalImage, const std::string& selectedImage = "", const std::string& disableImage = "", - TextureResType texType = UI_TEX_TYPE_LOCAL); + TextureResType texType = TextureResType::LOCAL); /** @@ -83,7 +83,7 @@ public: void loadTextures(const std::string& normal, const std::string& selected, const std::string& disabled = "", - TextureResType texType = UI_TEX_TYPE_LOCAL); + TextureResType texType = TextureResType::LOCAL); /** * Load normal state texture for button. @@ -92,7 +92,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTextureNormal(const std::string& normal, TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTextureNormal(const std::string& normal, TextureResType texType = TextureResType::LOCAL); /** * Load selected state texture for button. @@ -101,7 +101,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTexturePressed(const std::string& selected, TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTexturePressed(const std::string& selected, TextureResType texType = TextureResType::LOCAL); /** * Load dark state texture for button. @@ -110,7 +110,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTextureDisabled(const std::string& disabled, TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTextureDisabled(const std::string& disabled, TextureResType texType = TextureResType::LOCAL); /** * Sets capinsets for button, if button is using scale9 renderer. @@ -190,7 +190,7 @@ CC_CONSTRUCTOR_ACCESS: virtual bool init(const std::string& normalImage, const std::string& selectedImage = "", const std::string& disableImage = "", - TextureResType texType = UI_TEX_TYPE_LOCAL); + TextureResType texType = TextureResType::LOCAL); protected: diff --git a/cocos/ui/UICheckBox.cpp b/cocos/ui/UICheckBox.cpp index b0552e72f2..cfb8933c6e 100644 --- a/cocos/ui/UICheckBox.cpp +++ b/cocos/ui/UICheckBox.cpp @@ -45,11 +45,11 @@ _frontCrossDisabledRenderer(nullptr), _isSelected(true), _checkBoxEventListener(nullptr), _checkBoxEventSelector(nullptr), -_backGroundTexType(UI_TEX_TYPE_LOCAL), -_backGroundSelectedTexType(UI_TEX_TYPE_LOCAL), -_frontCrossTexType(UI_TEX_TYPE_LOCAL), -_backGroundDisabledTexType(UI_TEX_TYPE_LOCAL), -_frontCrossDisabledTexType(UI_TEX_TYPE_LOCAL), +_backGroundTexType(TextureResType::LOCAL), +_backGroundSelectedTexType(TextureResType::LOCAL), +_frontCrossTexType(TextureResType::LOCAL), +_backGroundDisabledTexType(TextureResType::LOCAL), +_frontCrossDisabledTexType(TextureResType::LOCAL), _backGroundFileName(""), _backGroundSelectedFileName(""), _frontCrossFileName(""), @@ -174,10 +174,10 @@ void CheckBox::loadTextureBackGround(const std::string& backGround,TextureResTyp _backGroundTexType = texType; switch (_backGroundTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _backGroundBoxRenderer->setTexture(backGround); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _backGroundBoxRenderer->setSpriteFrame(backGround); break; default: @@ -200,10 +200,10 @@ void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelect _backGroundSelectedTexType = texType; switch (_backGroundSelectedTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _backGroundSelectedBoxRenderer->setTexture(backGroundSelected); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _backGroundSelectedBoxRenderer->setSpriteFrame(backGroundSelected); break; default: @@ -225,10 +225,10 @@ void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType tex _frontCrossTexType = texType; switch (_frontCrossTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _frontCrossRenderer->setTexture(cross); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _frontCrossRenderer->setSpriteFrame(cross); break; default: @@ -250,10 +250,10 @@ void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabl _backGroundDisabledTexType = texType; switch (_backGroundDisabledTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _backGroundBoxDisabledRenderer->setTexture(backGroundDisabled); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _backGroundBoxDisabledRenderer->setSpriteFrame(backGroundDisabled); break; default: @@ -275,10 +275,10 @@ void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabl _frontCrossDisabledTexType = texType; switch (_frontCrossDisabledTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _frontCrossDisabledRenderer->setTexture(frontCrossDisabled); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _frontCrossDisabledRenderer->setSpriteFrame(frontCrossDisabled); break; default: diff --git a/cocos/ui/UICheckBox.h b/cocos/ui/UICheckBox.h index cceb4596b1..5d10b824b5 100644 --- a/cocos/ui/UICheckBox.h +++ b/cocos/ui/UICheckBox.h @@ -83,7 +83,7 @@ public: const std::string& cross, const std::string& backGroundDisabled, const std::string& frontCrossDisabled, - TextureResType texType = UI_TEX_TYPE_LOCAL); + TextureResType texType = TextureResType::LOCAL); /** * Load textures for checkbox. @@ -103,7 +103,7 @@ public: const std::string& cross, const std::string& backGroundDisabled, const std::string& frontCrossDisabled, - TextureResType texType = UI_TEX_TYPE_LOCAL); + TextureResType texType = TextureResType::LOCAL); /** * Load backGround texture for checkbox. @@ -112,7 +112,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTextureBackGround(const std::string& backGround,TextureResType type = UI_TEX_TYPE_LOCAL); + void loadTextureBackGround(const std::string& backGround,TextureResType type = TextureResType::LOCAL); /** * Load backGroundSelected texture for checkbox. @@ -121,7 +121,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType = TextureResType::LOCAL); /** * Load cross texture for checkbox. @@ -130,7 +130,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTextureFrontCross(const std::string&,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTextureFrontCross(const std::string&,TextureResType texType = TextureResType::LOCAL); /** * Load backGroundDisabled texture for checkbox. @@ -139,7 +139,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType = TextureResType::LOCAL); /** * Load frontCrossDisabled texture for checkbox. @@ -148,7 +148,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType = TextureResType::LOCAL); /** * Sets selcted state for checkbox. @@ -188,7 +188,7 @@ CC_CONSTRUCTOR_ACCESS: const std::string& cross, const std::string& backGroundDisabled, const std::string& frontCrossDisabled, - TextureResType texType = UI_TEX_TYPE_LOCAL); + TextureResType texType = TextureResType::LOCAL); protected: virtual void initRenderer() override; diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index 997e930fd3..3b22249e8a 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -37,6 +37,12 @@ CC_DEPRECATED_ATTRIBUTE const Widget::PositionType POSITION_ABSOLUTE = Widget::P CC_DEPRECATED_ATTRIBUTE const Widget::PositionType POSITION_PERCENT = Widget::PositionType::PERCENT; CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_ABSOLUTE = Widget::SizeType::ABSOLUTE; CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_PERCENT = Widget::SizeType::PERCENT; +CC_DEPRECATED_ATTRIBUTE const Widget::TextureResType UI_TEX_TYPE_LOCAL = Widget::TextureResType::LOCAL; +CC_DEPRECATED_ATTRIBUTE const Widget::TextureResType UI_TEX_TYPE_PLIST = Widget::TextureResType::PLIST; + +CC_DEPRECATED_ATTRIBUTE typedef Widget::TextureResType TextureResType; +CC_DEPRECATED_ATTRIBUTE typedef Widget::PositionType PositionType; +CC_DEPRECATED_ATTRIBUTE typedef Widget::SizeType SizeType; diff --git a/cocos/ui/UIImageView.cpp b/cocos/ui/UIImageView.cpp index eb25b4b4fd..d67fe503e3 100644 --- a/cocos/ui/UIImageView.cpp +++ b/cocos/ui/UIImageView.cpp @@ -43,7 +43,7 @@ _prevIgnoreSize(true), _capInsets(Rect::ZERO), _imageRenderer(nullptr), _textureFile(""), -_imageTexType(UI_TEX_TYPE_LOCAL), +_imageTexType(TextureResType::LOCAL), _imageTextureSize(_size), _imageRendererAdaptDirty(true) { @@ -86,7 +86,7 @@ bool ImageView::init() ret = false; break; } - _imageTexType = UI_TEX_TYPE_LOCAL; + _imageTexType = TextureResType::LOCAL; } while (0); return ret; } @@ -121,7 +121,7 @@ void ImageView::loadTexture(const std::string& fileName, TextureResType texType) _imageTexType = texType; switch (_imageTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: if (_scale9Enabled) { extension::Scale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE; @@ -134,7 +134,7 @@ void ImageView::loadTexture(const std::string& fileName, TextureResType texType) imageRenderer->setTexture(fileName); } break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: if (_scale9Enabled) { extension::Scale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE; diff --git a/cocos/ui/UIImageView.h b/cocos/ui/UIImageView.h index 8b88b8e09b..2bf9bd43b3 100644 --- a/cocos/ui/UIImageView.h +++ b/cocos/ui/UIImageView.h @@ -63,7 +63,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - static ImageView* create(const std::string& imageFileName, TextureResType texType = UI_TEX_TYPE_LOCAL); + static ImageView* create(const std::string& imageFileName, TextureResType texType = TextureResType::LOCAL); /** @@ -73,7 +73,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTexture(const std::string& fileName,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTexture(const std::string& fileName,TextureResType texType = TextureResType::LOCAL); /** * Updates the texture rect of the ImageView in points. @@ -113,7 +113,7 @@ public: CC_CONSTRUCTOR_ACCESS: //initializes state of widget. virtual bool init() override; - virtual bool init(const std::string& imageFileName, TextureResType texType = UI_TEX_TYPE_LOCAL); + virtual bool init(const std::string& imageFileName, TextureResType texType = TextureResType::LOCAL); protected: virtual void initRenderer() override; diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 73682844c6..a36b04c626 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -573,7 +573,7 @@ _backGroundImage(nullptr), _backGroundImageFileName(""), _backGroundImageCapInsets(Rect::ZERO), _colorType(LAYOUT_COLOR_NONE), -_bgImageTexType(UI_TEX_TYPE_LOCAL), +_bgImageTexType(TextureResType::LOCAL), _colorRender(nullptr), _gradientRender(nullptr), _cColor(Color3B::WHITE), @@ -1123,10 +1123,10 @@ void Layout::setBackGroundImage(const std::string& fileName,TextureResType texTy extension::Scale9Sprite* bgiScale9 = static_cast(_backGroundImage); switch (_bgImageTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: bgiScale9->initWithFile(fileName); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: bgiScale9->initWithSpriteFrameName(fileName); break; default: @@ -1138,10 +1138,10 @@ void Layout::setBackGroundImage(const std::string& fileName,TextureResType texTy { switch (_bgImageTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: static_cast(_backGroundImage)->setTexture(fileName); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: static_cast(_backGroundImage)->setSpriteFrame(fileName); break; default: diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h index 316354961e..96b6fce71b 100644 --- a/cocos/ui/UILayout.h +++ b/cocos/ui/UILayout.h @@ -86,7 +86,7 @@ public: * * @param texType @see TextureResType. UI_TEX_TYPE_LOCAL means local file, UI_TEX_TYPE_PLIST means sprite frame. */ - void setBackGroundImage(const std::string& fileName,TextureResType texType = UI_TEX_TYPE_LOCAL); + void setBackGroundImage(const std::string& fileName,TextureResType texType = TextureResType::LOCAL); /** * Sets a background image capinsets for layout, if the background image is a scale9 render. diff --git a/cocos/ui/UILoadingBar.cpp b/cocos/ui/UILoadingBar.cpp index e54b24d04e..901d69a0de 100644 --- a/cocos/ui/UILoadingBar.cpp +++ b/cocos/ui/UILoadingBar.cpp @@ -38,7 +38,7 @@ _barType(LoadingBarTypeLeft), _percent(100), _totalLength(0), _barRenderer(nullptr), -_renderBarTexType(UI_TEX_TYPE_LOCAL), +_renderBarTexType(TextureResType::LOCAL), _barRendererTextureSize(Size::ZERO), _scale9Enabled(false), _prevIgnoreSize(true), @@ -129,7 +129,7 @@ int LoadingBar::getDirection() _textureFile = texture; switch (_renderBarTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: if (_scale9Enabled) { extension::Scale9Sprite* barRendererScale9 = static_cast(_barRenderer); @@ -141,7 +141,7 @@ int LoadingBar::getDirection() static_cast(_barRenderer)->setTexture(texture); } break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: if (_scale9Enabled) { extension::Scale9Sprite* barRendererScale9 = static_cast(_barRenderer); diff --git a/cocos/ui/UILoadingBar.h b/cocos/ui/UILoadingBar.h index f00de91acf..f23e2e4b89 100644 --- a/cocos/ui/UILoadingBar.h +++ b/cocos/ui/UILoadingBar.h @@ -91,7 +91,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTexture(const std::string& texture,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTexture(const std::string& texture,TextureResType texType = TextureResType::LOCAL); /** * Changes the progress direction of loadingbar. diff --git a/cocos/ui/UISlider.cpp b/cocos/ui/UISlider.cpp index b85a3da8e7..331988025e 100644 --- a/cocos/ui/UISlider.cpp +++ b/cocos/ui/UISlider.cpp @@ -56,11 +56,11 @@ _capInsetsBarRenderer(Rect::ZERO), _capInsetsProgressBarRenderer(Rect::ZERO), _sliderEventListener(nullptr), _sliderEventSelector(nullptr), -_barTexType(UI_TEX_TYPE_LOCAL), -_progressBarTexType(UI_TEX_TYPE_LOCAL), -_ballNTexType(UI_TEX_TYPE_LOCAL), -_ballPTexType(UI_TEX_TYPE_LOCAL), -_ballDTexType(UI_TEX_TYPE_LOCAL), +_barTexType(TextureResType::LOCAL), +_progressBarTexType(TextureResType::LOCAL), +_ballNTexType(TextureResType::LOCAL), +_ballPTexType(TextureResType::LOCAL), +_ballDTexType(TextureResType::LOCAL), _barRendererAdaptDirty(true), _progressBarRendererDirty(true) { @@ -123,7 +123,7 @@ void Slider::loadBarTexture(const std::string& fileName, TextureResType texType) _barTexType = texType; switch (_barTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: if (_scale9Enabled) { static_cast(_barRenderer)->initWithFile(fileName); @@ -133,7 +133,7 @@ void Slider::loadBarTexture(const std::string& fileName, TextureResType texType) static_cast(_barRenderer)->setTexture(fileName); } break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: if (_scale9Enabled) { static_cast(_barRenderer)->initWithSpriteFrameName(fileName); @@ -162,7 +162,7 @@ void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType _progressBarTexType = texType; switch (_progressBarTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: if (_scale9Enabled) { static_cast(_progressBarRenderer)->initWithFile(fileName); @@ -172,7 +172,7 @@ void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType static_cast(_progressBarRenderer)->setTexture(fileName); } break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: if (_scale9Enabled) { static_cast(_progressBarRenderer)->initWithSpriteFrameName(fileName); @@ -298,10 +298,10 @@ void Slider::loadSlidBallTextureNormal(const std::string& normal,TextureResType _ballNTexType = texType; switch (_ballNTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _slidBallNormalRenderer->setTexture(normal); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _slidBallNormalRenderer->setSpriteFrame(normal); break; default: @@ -320,10 +320,10 @@ void Slider::loadSlidBallTexturePressed(const std::string& pressed,TextureResTyp _ballPTexType = texType; switch (_ballPTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _slidBallPressedRenderer->setTexture(pressed); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _slidBallPressedRenderer->setSpriteFrame(pressed); break; default: @@ -342,10 +342,10 @@ void Slider::loadSlidBallTexturePressed(const std::string& pressed,TextureResTyp _ballDTexType = texType; switch (_ballDTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _slidBallDisabledRenderer->setTexture(disabled); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _slidBallDisabledRenderer->setSpriteFrame(disabled); break; default: diff --git a/cocos/ui/UISlider.h b/cocos/ui/UISlider.h index ba8a8928ae..52974d4560 100644 --- a/cocos/ui/UISlider.h +++ b/cocos/ui/UISlider.h @@ -71,7 +71,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadBarTexture(const std::string& fileName,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadBarTexture(const std::string& fileName,TextureResType texType = TextureResType::LOCAL); /** * Sets if slider is using scale9 renderer. @@ -121,7 +121,7 @@ public: void loadSlidBallTextures(const std::string& normal, const std::string& pressed, const std::string& disabled, - TextureResType texType = UI_TEX_TYPE_LOCAL); + TextureResType texType = TextureResType::LOCAL); /** * Load normal state texture for slider ball. @@ -130,7 +130,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadSlidBallTextureNormal(const std::string& normal,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadSlidBallTextureNormal(const std::string& normal,TextureResType texType = TextureResType::LOCAL); /** * Load selected state texture for slider ball. @@ -139,7 +139,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadSlidBallTexturePressed(const std::string& pressed,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadSlidBallTexturePressed(const std::string& pressed,TextureResType texType = TextureResType::LOCAL); /** * Load dark state texture for slider ball. @@ -148,7 +148,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadSlidBallTextureDisabled(const std::string& disabled,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadSlidBallTextureDisabled(const std::string& disabled,TextureResType texType = TextureResType::LOCAL); /** * Load dark state texture for slider progress bar. @@ -157,7 +157,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadProgressBarTexture(const std::string& fileName, TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadProgressBarTexture(const std::string& fileName, TextureResType texType = TextureResType::LOCAL); /** * Changes the progress direction of slider. diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index de6b8d86da..77bce664cd 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -46,12 +46,6 @@ typedef enum WidgetTypeWidget, //control WidgetTypeContainer //container }WidgetType; - -typedef enum -{ - UI_TEX_TYPE_LOCAL = 0, - UI_TEX_TYPE_PLIST = 1 -}TextureResType; @@ -101,6 +95,12 @@ public: ENDED, CANCELED }; + + enum class TextureResType + { + LOCAL = 0, + PLIST = 1 + }; typedef std::function ccWidgetTouchCallback;