add switch method to all the GUI tests

This commit is contained in:
andyque 2014-07-01 15:47:40 +08:00
parent 21b11cc3c6
commit 3304bba017
12 changed files with 280 additions and 116 deletions

View File

@ -16,13 +16,30 @@ UISliderTest_Editor::~UISliderTest_Editor()
}
bool UISliderTest_Editor::init()
void UISliderTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
{
if (UIScene_Editor::init())
{
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.json"));
MenuItemToggle *item = (MenuItemToggle*)pSender;
if (item->getSelectedIndex() == 0){
_layout->removeFromParentAndCleanup(true);
_layout = static_cast<Layout*>(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<Layout*>(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,
@ -41,7 +58,16 @@ bool UISliderTest_Editor::init()
Slider* scale9_slider = static_cast<Slider*>(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<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.json"));
_touchGroup->addChild(_layout);
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;
}

View File

@ -12,6 +12,8 @@ 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)

View File

@ -3,14 +3,30 @@
#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<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.json"));
_touchGroup->addChild(_layout);
this->configureGUIScene();
}else{
_layout->removeFromParentAndCleanup(true);
bool UITextAtlasTest_Editor::init()
{
if (UIScene_Editor::init())
{
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.json"));
_layout = static_cast<Layout*>(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,
@ -22,7 +38,16 @@ bool UITextAtlasTest_Editor::init()
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
}
bool UITextAtlasTest_Editor::init()
{
if (UIScene_Editor::init())
{
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.json"));
_touchGroup->addChild(_layout);
this->configureGUIScene();
return true;
}

View File

@ -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)
};

View File

@ -4,14 +4,30 @@
// UITextBMFontTest_Editor
void UITextBMFontTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
{
MenuItemToggle *item = (MenuItemToggle*)pSender;
if (item->getSelectedIndex() == 0){
_layout->removeFromParentAndCleanup(true);
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.json"));
_touchGroup->addChild(_layout);
this->configureGUIScene();
}else{
_layout->removeFromParentAndCleanup(true);
bool UITextBMFontTest_Editor::init()
{
if (UIScene_Editor::init())
{
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.json"));
_layout = static_cast<Layout*>(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,
@ -23,7 +39,16 @@ bool UITextBMFontTest_Editor::init()
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
}
bool UITextBMFontTest_Editor::init()
{
if (UIScene_Editor::init())
{
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.json"));
_touchGroup->addChild(_layout);
this->configureGUIScene();
return true;
}

View File

@ -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)
};

View File

@ -16,13 +16,30 @@ UITextFieldTest_Editor::~UITextFieldTest_Editor()
}
bool UITextFieldTest_Editor::init()
void UITextFieldTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
{
if (UIScene_Editor::init())
{
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.json"));
MenuItemToggle *item = (MenuItemToggle*)pSender;
if (item->getSelectedIndex() == 0){
_layout->removeFromParentAndCleanup(true);
_layout = static_cast<Layout*>(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<Layout*>(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,
@ -43,6 +60,16 @@ bool UITextFieldTest_Editor::init()
TextField* textField_password = static_cast<TextField*>(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<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.json"));
_touchGroup->addChild(_layout);
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;
}

View File

@ -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;

View File

@ -7,13 +7,30 @@
// UITextTest_Editor
using namespace ui;
bool UITextTest_Editor::init()
void UITextTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
{
if (UIScene_Editor::init())
{
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.json"));
MenuItemToggle *item = (MenuItemToggle*)pSender;
if (item->getSelectedIndex() == 0){
_layout->removeFromParentAndCleanup(true);
_layout = static_cast<Layout*>(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<Layout*>(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,
@ -26,6 +43,15 @@ bool UITextTest_Editor::init()
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
}
bool UITextTest_Editor::init()
{
if (UIScene_Editor::init())
{
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.json"));
_touchGroup->addChild(_layout);
this->configureGUIScene();
return true;
}

View File

@ -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)
};

View File

@ -15,13 +15,30 @@ UIWidgetAddNodeTest_Editor::~UIWidgetAddNodeTest_Editor()
}
bool UIWidgetAddNodeTest_Editor::init()
void UIWidgetAddNodeTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
{
if (UIScene_Editor::init())
{
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.json"));
MenuItemToggle *item = (MenuItemToggle*)pSender;
if (item->getSelectedIndex() == 0){
_layout->removeFromParentAndCleanup(true);
_layout = static_cast<Layout*>(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<Layout*>(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,
@ -44,6 +61,17 @@ bool UIWidgetAddNodeTest_Editor::init()
Sprite* sprite = Sprite::create("cocosui/ccicon.png");
widget->addChild(sprite);
}
bool UIWidgetAddNodeTest_Editor::init()
{
if (UIScene_Editor::init())
{
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.json"));
_touchGroup->addChild(_layout);
this->configureGUIScene();
return true;
}

View File

@ -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)
};