mirror of https://github.com/axmolengine/axmol.git
add switch method to all the GUI tests
This commit is contained in:
parent
21b11cc3c6
commit
3304bba017
|
@ -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<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,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
|
||||||
|
Slider* slider = static_cast<Slider*>(Helper::seekWidgetByName(root, "Slider_738"));
|
||||||
|
slider->addEventListener(CC_CALLBACK_2(UISliderTest_Editor::sliderEvent, this));
|
||||||
|
|
||||||
|
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()
|
bool UISliderTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.json"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.json"));
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.csb"));
|
|
||||||
_touchGroup->addChild(_layout);
|
_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*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
|
|
||||||
Slider* slider = static_cast<Slider*>(Helper::seekWidgetByName(root, "Slider_738"));
|
|
||||||
slider->addEventListener(CC_CALLBACK_2(UISliderTest_Editor::sliderEvent, this));
|
|
||||||
|
|
||||||
Slider* scale9_slider = static_cast<Slider*>(Helper::seekWidgetByName(root, "Slider_740"));
|
|
||||||
scale9_slider->addEventListener(CC_CALLBACK_2(UISliderTest_Editor::sliderEvent, this));
|
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create();
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
||||||
|
@ -49,7 +75,7 @@ bool UISliderTest_Editor::init()
|
||||||
_displayValueLabel->setString("No event");
|
_displayValueLabel->setString("No event");
|
||||||
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
||||||
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
||||||
_touchGroup->addChild(_displayValueLabel);
|
_touchGroup->addChild(_displayValueLabel, 20);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ public:
|
||||||
~UISliderTest_Editor();
|
~UISliderTest_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
void sliderEvent(Ref* pSender, Slider::EventType type);
|
void sliderEvent(Ref* pSender, Slider::EventType type);
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UISliderTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UISliderTest_Editor)
|
||||||
|
|
|
@ -3,26 +3,51 @@
|
||||||
#include "UITextAtlasTest_Editor.h"
|
#include "UITextAtlasTest_Editor.h"
|
||||||
|
|
||||||
// UITextAtlasTest_Editor
|
// 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);
|
||||||
|
|
||||||
|
_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,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
}
|
||||||
|
|
||||||
bool UITextAtlasTest_Editor::init()
|
bool UITextAtlasTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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()->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);
|
_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*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@ class UITextAtlasTest_Editor : public UIScene_Editor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UITextAtlasTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UITextAtlasTest_Editor)
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,26 +4,51 @@
|
||||||
|
|
||||||
|
|
||||||
// UITextBMFontTest_Editor
|
// 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);
|
||||||
|
|
||||||
|
_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,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
}
|
||||||
|
|
||||||
bool UITextBMFontTest_Editor::init()
|
bool UITextBMFontTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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()->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);
|
_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*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@ class UITextBMFontTest_Editor : public UIScene_Editor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UITextBMFontTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UITextBMFontTest_Editor)
|
||||||
};
|
};
|
||||||
|
|
|
@ -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<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,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
TextField* textField_normal = static_cast<TextField*>(Helper::seekWidgetByName(root, "TextField_1109"));
|
||||||
|
textField_normal->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this));
|
||||||
|
|
||||||
|
TextField* textField_max_character = static_cast<TextField*>(Helper::seekWidgetByName(root, "TextField_1110"));
|
||||||
|
textField_max_character->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this));
|
||||||
|
|
||||||
|
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()
|
bool UITextFieldTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.json"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.json"));
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.csb"));
|
|
||||||
_touchGroup->addChild(_layout);
|
_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*>(_layout->getChildByName("root_Panel"));
|
this->configureGUIScene();
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
TextField* textField_normal = static_cast<TextField*>(Helper::seekWidgetByName(root, "TextField_1109"));
|
|
||||||
textField_normal->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this));
|
|
||||||
|
|
||||||
TextField* textField_max_character = static_cast<TextField*>(Helper::seekWidgetByName(root, "TextField_1110"));
|
|
||||||
textField_max_character->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this));
|
|
||||||
|
|
||||||
TextField* textField_password = static_cast<TextField*>(Helper::seekWidgetByName(root, "TextField_1107"));
|
|
||||||
textField_password->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this));
|
|
||||||
|
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create();
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
||||||
|
@ -50,7 +77,7 @@ bool UITextFieldTest_Editor::init()
|
||||||
_displayValueLabel->setString("No event");
|
_displayValueLabel->setString("No event");
|
||||||
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
||||||
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
||||||
_touchGroup->addChild(_displayValueLabel);
|
_touchGroup->addChild(_displayValueLabel, 20);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ public:
|
||||||
~UITextFieldTest_Editor();
|
~UITextFieldTest_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
void textFieldEvent(Ref* pSender, TextField::EventType type);
|
void textFieldEvent(Ref* pSender, TextField::EventType type);
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UITextFieldTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UITextFieldTest_Editor)
|
||||||
Text* _displayValueLabel;
|
Text* _displayValueLabel;
|
||||||
|
|
|
@ -7,25 +7,51 @@
|
||||||
// UITextTest_Editor
|
// UITextTest_Editor
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
|
void UITextTest_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/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,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UITextTest_Editor::init()
|
bool UITextTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.json"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.json"));
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.csb"));
|
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
this->configureGUIScene();
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@ class UITextTest_Editor : public UIScene_Editor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UITextTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UITextTest_Editor)
|
||||||
};
|
};
|
||||||
|
|
|
@ -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<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,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(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()
|
bool UIWidgetAddNodeTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.json"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.json"));
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.csb"));
|
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
this->configureGUIScene();
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(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);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ public:
|
||||||
UIWidgetAddNodeTest_Editor();
|
UIWidgetAddNodeTest_Editor();
|
||||||
~UIWidgetAddNodeTest_Editor();
|
~UIWidgetAddNodeTest_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UIWidgetAddNodeTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UIWidgetAddNodeTest_Editor)
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue