diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp index 54d2252ecb..b27625bb9b 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp @@ -16,32 +16,58 @@ UISliderTest_Editor::~UISliderTest_Editor() } +void UISliderTest_Editor::switchLoadMethod(cocos2d::Ref *pSender) +{ + MenuItemToggle *item = (MenuItemToggle*)pSender; + + if (item->getSelectedIndex() == 0){ + _layout->removeFromParentAndCleanup(true); + + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.json")); + + _touchGroup->addChild(_layout); + + this->configureGUIScene(); + }else{ + _layout->removeFromParentAndCleanup(true); + + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.csb")); + _touchGroup->addChild(_layout); + + this->configureGUIScene(); + } +} + +void UISliderTest_Editor::configureGUIScene() +{ + Size screenSize = CCDirector::getInstance()->getWinSize(); + Size rootSize = _layout->getContentSize(); + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, + (screenSize.height - rootSize.height) / 2)); + + Layout* root = static_cast(_layout->getChildByName("root_Panel")); + + Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); + + _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); + + + Slider* slider = static_cast(Helper::seekWidgetByName(root, "Slider_738")); + slider->addEventListener(CC_CALLBACK_2(UISliderTest_Editor::sliderEvent, this)); + + Slider* scale9_slider = static_cast(Helper::seekWidgetByName(root, "Slider_740")); + scale9_slider->addEventListener(CC_CALLBACK_2(UISliderTest_Editor::sliderEvent, this)); +} + bool UISliderTest_Editor::init() { if (UIScene_Editor::init()) { -// _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.json")); - _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.csb")); + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.json")); _touchGroup->addChild(_layout); - Size screenSize = CCDirector::getInstance()->getWinSize(); - Size rootSize = _layout->getContentSize(); - _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, - (screenSize.height - rootSize.height) / 2)); - - Layout* root = static_cast(_layout->getChildByName("root_Panel")); - - Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); - - _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); - - - Slider* slider = static_cast(Helper::seekWidgetByName(root, "Slider_738")); - slider->addEventListener(CC_CALLBACK_2(UISliderTest_Editor::sliderEvent, this)); - - Slider* scale9_slider = static_cast(Helper::seekWidgetByName(root, "Slider_740")); - scale9_slider->addEventListener(CC_CALLBACK_2(UISliderTest_Editor::sliderEvent, this)); - + + this->configureGUIScene(); _displayValueLabel = Text::create(); _displayValueLabel->setFontName("fonts/Marker Felt.ttf"); @@ -49,7 +75,7 @@ bool UISliderTest_Editor::init() _displayValueLabel->setString("No event"); _displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2, _layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f)); - _touchGroup->addChild(_displayValueLabel); + _touchGroup->addChild(_displayValueLabel, 20); return true; } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.h index 3637d2212e..ff7dc3ec40 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.h @@ -12,7 +12,9 @@ public: ~UISliderTest_Editor(); bool init(); void sliderEvent(Ref* pSender, Slider::EventType type); - + virtual void switchLoadMethod(Ref* pSender); + void configureGUIScene(); + protected: UI_SCENE_EDITOR_CREATE_FUNC(UISliderTest_Editor) Text* _displayValueLabel; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp index ed418ac7d7..bade2452e9 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp @@ -3,26 +3,51 @@ #include "UITextAtlasTest_Editor.h" // UITextAtlasTest_Editor +void UITextAtlasTest_Editor::switchLoadMethod(cocos2d::Ref *pSender) +{ + MenuItemToggle *item = (MenuItemToggle*)pSender; + + if (item->getSelectedIndex() == 0){ + _layout->removeFromParentAndCleanup(true); + + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.json")); + + _touchGroup->addChild(_layout); + + this->configureGUIScene(); + }else{ + _layout->removeFromParentAndCleanup(true); + + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.csb")); + _touchGroup->addChild(_layout); + + this->configureGUIScene(); + } +} + +void UITextAtlasTest_Editor::configureGUIScene() +{ + Size screenSize = CCDirector::getInstance()->getWinSize(); + Size rootSize = _layout->getContentSize(); + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, + (screenSize.height - rootSize.height) / 2)); + + Layout* root = static_cast(_layout->getChildByName("root_Panel")); + + Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); + + _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); +} bool UITextAtlasTest_Editor::init() { if (UIScene_Editor::init()) { -// _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.json")); - _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.csb")); + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.json")); _touchGroup->addChild(_layout); - Size screenSize = CCDirector::getInstance()->getWinSize(); - Size rootSize = _layout->getContentSize(); - _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, - (screenSize.height - rootSize.height) / 2)); - - Layout* root = static_cast(_layout->getChildByName("root_Panel")); - - Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); - - _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); - + + this->configureGUIScene(); return true; } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.h index a061b28d1c..e0a170acec 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.h @@ -31,7 +31,8 @@ class UITextAtlasTest_Editor : public UIScene_Editor { public: bool init(); - + virtual void switchLoadMethod(Ref* pSender); + void configureGUIScene(); protected: UI_SCENE_EDITOR_CREATE_FUNC(UITextAtlasTest_Editor) }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp index dc7eff0ed9..788f994a02 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp @@ -4,26 +4,51 @@ // UITextBMFontTest_Editor +void UITextBMFontTest_Editor::switchLoadMethod(cocos2d::Ref *pSender) +{ + MenuItemToggle *item = (MenuItemToggle*)pSender; + + if (item->getSelectedIndex() == 0){ + _layout->removeFromParentAndCleanup(true); + + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.json")); + + _touchGroup->addChild(_layout); + + this->configureGUIScene(); + }else{ + _layout->removeFromParentAndCleanup(true); + + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.csb")); + _touchGroup->addChild(_layout); + + this->configureGUIScene(); + } +} + +void UITextBMFontTest_Editor::configureGUIScene() +{ + Size screenSize = CCDirector::getInstance()->getWinSize(); + Size rootSize = _layout->getContentSize(); + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, + (screenSize.height - rootSize.height) / 2)); + + Layout* root = static_cast(_layout->getChildByName("root_Panel")); + + Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); + + _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); +} bool UITextBMFontTest_Editor::init() { if (UIScene_Editor::init()) { -// _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.json")); - _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.csb")); + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.json")); _touchGroup->addChild(_layout); - Size screenSize = CCDirector::getInstance()->getWinSize(); - Size rootSize = _layout->getContentSize(); - _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, - (screenSize.height - rootSize.height) / 2)); - - Layout* root = static_cast(_layout->getChildByName("root_Panel")); - - Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); - - _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); + this->configureGUIScene(); return true; } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.h index 765d0966a3..8ff7eccdab 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.h @@ -31,7 +31,8 @@ class UITextBMFontTest_Editor : public UIScene_Editor { public: bool init(); - + virtual void switchLoadMethod(Ref* pSender); + void configureGUIScene(); protected: UI_SCENE_EDITOR_CREATE_FUNC(UITextBMFontTest_Editor) }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp index b340b57a9a..8fb8f98623 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp @@ -16,33 +16,60 @@ UITextFieldTest_Editor::~UITextFieldTest_Editor() } +void UITextFieldTest_Editor::switchLoadMethod(cocos2d::Ref *pSender) +{ + MenuItemToggle *item = (MenuItemToggle*)pSender; + + if (item->getSelectedIndex() == 0){ + _layout->removeFromParentAndCleanup(true); + + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.json")); + + _touchGroup->addChild(_layout); + + this->configureGUIScene(); + }else{ + _layout->removeFromParentAndCleanup(true); + + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.csb")); + _touchGroup->addChild(_layout); + + this->configureGUIScene(); + } +} + +void UITextFieldTest_Editor::configureGUIScene() +{ + Size screenSize = CCDirector::getInstance()->getWinSize(); + Size rootSize = _layout->getContentSize(); + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, + (screenSize.height - rootSize.height) / 2)); + + Layout* root = static_cast(_layout->getChildByName("root_Panel")); + + Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); + + _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); + + TextField* textField_normal = static_cast(Helper::seekWidgetByName(root, "TextField_1109")); + textField_normal->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this)); + + TextField* textField_max_character = static_cast(Helper::seekWidgetByName(root, "TextField_1110")); + textField_max_character->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this)); + + TextField* textField_password = static_cast(Helper::seekWidgetByName(root, "TextField_1107")); + textField_password->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this)); +} + bool UITextFieldTest_Editor::init() { if (UIScene_Editor::init()) { -// _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.json")); - _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.csb")); + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.json")); _touchGroup->addChild(_layout); - Size screenSize = CCDirector::getInstance()->getWinSize(); - Size rootSize = _layout->getContentSize(); - _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, - (screenSize.height - rootSize.height) / 2)); - - Layout* root = static_cast(_layout->getChildByName("root_Panel")); - - Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); - - _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); - - TextField* textField_normal = static_cast(Helper::seekWidgetByName(root, "TextField_1109")); - textField_normal->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this)); - - TextField* textField_max_character = static_cast(Helper::seekWidgetByName(root, "TextField_1110")); - textField_max_character->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this)); - - TextField* textField_password = static_cast(Helper::seekWidgetByName(root, "TextField_1107")); - textField_password->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this)); + + this->configureGUIScene(); _displayValueLabel = Text::create(); _displayValueLabel->setFontName("fonts/Marker Felt.ttf"); @@ -50,7 +77,7 @@ bool UITextFieldTest_Editor::init() _displayValueLabel->setString("No event"); _displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2, _layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f)); - _touchGroup->addChild(_displayValueLabel); + _touchGroup->addChild(_displayValueLabel, 20); return true; } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.h index 38b1f8306f..1621d68d10 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.h @@ -34,7 +34,8 @@ public: ~UITextFieldTest_Editor(); bool init(); void textFieldEvent(Ref* pSender, TextField::EventType type); - + virtual void switchLoadMethod(Ref* pSender); + void configureGUIScene(); protected: UI_SCENE_EDITOR_CREATE_FUNC(UITextFieldTest_Editor) Text* _displayValueLabel; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp index 97b45c4936..f80c4c6f8b 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp @@ -7,25 +7,51 @@ // UITextTest_Editor using namespace ui; +void UITextTest_Editor::switchLoadMethod(cocos2d::Ref *pSender) +{ + MenuItemToggle *item = (MenuItemToggle*)pSender; + + if (item->getSelectedIndex() == 0){ + _layout->removeFromParentAndCleanup(true); + + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.json")); + + _touchGroup->addChild(_layout); + + this->configureGUIScene(); + }else{ + _layout->removeFromParentAndCleanup(true); + + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.csb")); + _touchGroup->addChild(_layout); + + this->configureGUIScene(); + } +} + +void UITextTest_Editor::configureGUIScene() +{ + Size screenSize = CCDirector::getInstance()->getWinSize(); + Size rootSize = _layout->getContentSize(); + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, + (screenSize.height - rootSize.height) / 2)); + + Layout* root = static_cast(_layout->getChildByName("root_Panel")); + + Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); + + _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); + +} + bool UITextTest_Editor::init() { if (UIScene_Editor::init()) { -// _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.json")); - _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.csb")); + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.json")); _touchGroup->addChild(_layout); - Size screenSize = CCDirector::getInstance()->getWinSize(); - Size rootSize = _layout->getContentSize(); - _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, - (screenSize.height - rootSize.height) / 2)); - - Layout* root = static_cast(_layout->getChildByName("root_Panel")); - - Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); - - _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); - + this->configureGUIScene(); return true; } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.h index 69bf1bdcbb..54c83d2315 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.h @@ -31,7 +31,8 @@ class UITextTest_Editor : public UIScene_Editor { public: bool init(); - + virtual void switchLoadMethod(Ref* pSender); + void configureGUIScene(); protected: UI_SCENE_EDITOR_CREATE_FUNC(UITextTest_Editor) }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp index 6f5276a3a1..313cedbc84 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp @@ -15,35 +15,63 @@ UIWidgetAddNodeTest_Editor::~UIWidgetAddNodeTest_Editor() } +void UIWidgetAddNodeTest_Editor::switchLoadMethod(cocos2d::Ref *pSender) +{ + MenuItemToggle *item = (MenuItemToggle*)pSender; + + if (item->getSelectedIndex() == 0){ + _layout->removeFromParentAndCleanup(true); + + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.json")); + + _touchGroup->addChild(_layout); + + this->configureGUIScene(); + }else{ + _layout->removeFromParentAndCleanup(true); + + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.csb")); + _touchGroup->addChild(_layout); + + this->configureGUIScene(); + } +} + +void UIWidgetAddNodeTest_Editor::configureGUIScene() +{ + Size screenSize = CCDirector::getInstance()->getWinSize(); + Size rootSize = _layout->getContentSize(); + _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, + (screenSize.height - rootSize.height) / 2)); + + Layout* root = static_cast(_layout->getChildByName("root_Panel")); + + Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); + + _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); + + + // Create the ui widget + Widget* widget = Widget::create(); + widget->setPosition(Vec2(rootSize.width / 2.0f, rootSize.height / 2.0f)); + widget->setLocalZOrder(_layout->getLocalZOrder() + 1); + _layout->addChild(widget); + + Sprite* sprite = Sprite::create("cocosui/ccicon.png"); + widget->addChild(sprite); + + +} + + bool UIWidgetAddNodeTest_Editor::init() { if (UIScene_Editor::init()) { -// _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.json")); - _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.csb")); + _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.json")); _touchGroup->addChild(_layout); - Size screenSize = CCDirector::getInstance()->getWinSize(); - Size rootSize = _layout->getContentSize(); - _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2, - (screenSize.height - rootSize.height) / 2)); - - Layout* root = static_cast(_layout->getChildByName("root_Panel")); - - Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); - - _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); - - - // Create the ui widget - Widget* widget = Widget::create(); - widget->setPosition(Vec2(rootSize.width / 2.0f, rootSize.height / 2.0f)); - widget->setLocalZOrder(_layout->getLocalZOrder() + 1); - _layout->addChild(widget); - - Sprite* sprite = Sprite::create("cocosui/ccicon.png"); - widget->addChild(sprite); - + this->configureGUIScene(); return true; } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.h index d50be1d6d8..11d4c36097 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.h @@ -33,7 +33,8 @@ public: UIWidgetAddNodeTest_Editor(); ~UIWidgetAddNodeTest_Editor(); bool init(); - + virtual void switchLoadMethod(Ref* pSender); + void configureGUIScene(); protected: UI_SCENE_EDITOR_CREATE_FUNC(UIWidgetAddNodeTest_Editor) };