2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
#include "UILayoutTest_Editor.h"
|
2014-10-10 10:44:16 +08:00
|
|
|
#include "VisibleRect.h"
|
2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
// UILayoutTest_Editor
|
|
|
|
|
|
|
|
UILayoutTest_Editor::UILayoutTest_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UILayoutTest_Editor::~UILayoutTest_Editor()
|
|
|
|
{
|
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UILayoutTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
|
|
|
{
|
|
|
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
|
|
|
|
2014-10-10 10:44:16 +08:00
|
|
|
switch (item->getSelectedIndex())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/windows_ui_layout_editor_1.json"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/windows_ui_layout_editor_1.csb"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/crossplatform_UILayout_Editor_1.ExportJson");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/crossplatform_UILayout_Editor_1.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2014-07-01 15:01:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UILayoutTest_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"));
|
|
|
|
|
|
|
|
Button* left_button = Button::create();
|
|
|
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
|
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
|
|
left_button->getContentSize().height));
|
|
|
|
left_button->setTouchEnabled(true);
|
|
|
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
|
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
_layout->addChild(left_button);
|
|
|
|
|
|
|
|
Button* right_button = Button::create();
|
|
|
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
|
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
|
|
right_button->getContentSize().height));
|
|
|
|
right_button->setTouchEnabled(true);
|
|
|
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
|
|
_layout->addChild(right_button);
|
|
|
|
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool UILayoutTest_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2014-10-10 10:44:16 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/crossplatform_UILayout_Editor_1.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
2014-03-04 16:51:35 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
2014-10-10 10:44:16 +08:00
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
this->configureGUIScene();
|
2014-03-04 16:51:35 +08:00
|
|
|
|
2014-10-10 10:44:16 +08:00
|
|
|
/*
|
|
|
|
Menu* menu = static_cast<Menu*>(getChildByTag(1));
|
|
|
|
MenuItemToggle* menuItemToggle = static_cast<MenuItemToggle*>(menu->getChildByTag(1));
|
|
|
|
MenuItem* selectedItem = menuItemToggle->getSelectedItem();
|
|
|
|
menuItemToggle->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y + selectedItem->getContentSize().height * 3.75f));
|
|
|
|
*/
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UILayoutTest_Color_Editor
|
|
|
|
|
|
|
|
UILayoutTest_Color_Editor::UILayoutTest_Color_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UILayoutTest_Color_Editor::~UILayoutTest_Color_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
void UILayoutTest_Color_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
|
|
|
{
|
|
|
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
|
|
|
|
2014-10-10 10:44:16 +08:00
|
|
|
switch (item->getSelectedIndex())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/windows_ui_layout_color_editor_1.json"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/windows_ui_layout_color_editor_1.csb"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/crossplatform_UILayout_Color_Editor_1.ExportJson");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/crossplatform_UILayout_Color_Editor_1.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2014-07-01 15:01:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UILayoutTest_Color_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"));
|
|
|
|
|
|
|
|
Button* left_button = Button::create();
|
|
|
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
|
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
|
|
left_button->getContentSize().height));
|
|
|
|
left_button->setTouchEnabled(true);
|
|
|
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
|
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
_layout->addChild(left_button);
|
|
|
|
|
|
|
|
Button* right_button = Button::create();
|
|
|
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
|
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
|
|
right_button->getContentSize().height));
|
|
|
|
right_button->setTouchEnabled(true);
|
|
|
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
|
|
_layout->addChild(right_button);
|
|
|
|
}
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
bool UILayoutTest_Color_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2014-10-10 10:44:16 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/crossplatform_UILayout_Color_Editor_1.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
2014-03-04 16:51:35 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
2014-10-10 10:44:16 +08:00
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
this->configureGUIScene();
|
2014-10-10 10:44:16 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
Menu* menu = static_cast<Menu*>(getChildByTag(1));
|
|
|
|
MenuItemToggle* menuItemToggle = static_cast<MenuItemToggle*>(menu->getChildByTag(1));
|
|
|
|
MenuItem* selectedItem = menuItemToggle->getSelectedItem();
|
|
|
|
menuItemToggle->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y + selectedItem->getContentSize().height * 3.75f));
|
|
|
|
*/
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UILayoutTest_Gradient_Editor
|
|
|
|
|
|
|
|
UILayoutTest_Gradient_Editor::UILayoutTest_Gradient_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UILayoutTest_Gradient_Editor::~UILayoutTest_Gradient_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
void UILayoutTest_Gradient_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
|
|
|
{
|
|
|
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
|
|
|
|
2014-10-10 10:44:16 +08:00
|
|
|
switch (item->getSelectedIndex())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/windows_ui_layout_gradient_color_editor_1_0.json"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/windows_ui_layout_gradient_color_editor_1_0.csb"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/crossplatform_UILayout_Gradient_Color_Editor_1.ExportJson");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/crossplatform_UILayout_Gradient_Color_Editor_1.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2014-07-01 15:01:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UILayoutTest_Gradient_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"));
|
|
|
|
|
|
|
|
Button* left_button = Button::create();
|
|
|
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
|
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
|
|
left_button->getContentSize().height));
|
|
|
|
left_button->setTouchEnabled(true);
|
|
|
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
|
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
_layout->addChild(left_button);
|
|
|
|
|
|
|
|
Button* right_button = Button::create();
|
|
|
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
|
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
|
|
right_button->getContentSize().height));
|
|
|
|
right_button->setTouchEnabled(true);
|
|
|
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
|
|
_layout->addChild(right_button);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
bool UILayoutTest_Gradient_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2014-10-10 10:44:16 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/crossplatform_UILayout_Gradient_Color_Editor_1.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
2014-07-01 15:01:38 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
2014-10-10 10:44:16 +08:00
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
this->configureGUIScene();
|
2014-10-10 10:44:16 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
Menu* menu = static_cast<Menu*>(getChildByTag(1));
|
|
|
|
MenuItemToggle* menuItemToggle = static_cast<MenuItemToggle*>(menu->getChildByTag(1));
|
|
|
|
MenuItem* selectedItem = menuItemToggle->getSelectedItem();
|
|
|
|
menuItemToggle->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y + selectedItem->getContentSize().height * 3.75f));
|
|
|
|
*/
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UILayoutTest_BackGroundImage_Editor
|
|
|
|
|
|
|
|
UILayoutTest_BackGroundImage_Editor::UILayoutTest_BackGroundImage_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UILayoutTest_BackGroundImage_Editor::~UILayoutTest_BackGroundImage_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
void UILayoutTest_BackGroundImage_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
|
|
|
{
|
|
|
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
|
|
|
|
2014-10-10 10:44:16 +08:00
|
|
|
switch (item->getSelectedIndex())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/windows_ui_layout_backgroundimage_editor_1_0_0.json"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/windows_ui_layout_backgroundimage_editor_1_0_0.csb"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/crossplatform_UILayout_BackgroundImage_Editor_1.ExportJson");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/crossplatform_UILayout_BackgroundImage_Editor_1.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2014-07-01 15:01:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UILayoutTest_BackGroundImage_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"));
|
|
|
|
|
|
|
|
Button* left_button = Button::create();
|
|
|
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
|
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
|
|
left_button->getContentSize().height * 0.625));
|
|
|
|
left_button->setTouchEnabled(true);
|
|
|
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
|
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
_layout->addChild(left_button);
|
|
|
|
|
|
|
|
Button* right_button = Button::create();
|
|
|
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
|
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
|
|
right_button->getContentSize().height * 0.625));
|
|
|
|
right_button->setTouchEnabled(true);
|
|
|
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
|
|
_layout->addChild(right_button);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
bool UILayoutTest_BackGroundImage_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2014-10-10 10:44:16 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/crossplatform_UILayout_BackgroundImage_Editor_1.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
2014-03-04 16:51:35 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
2014-10-10 10:44:16 +08:00
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
this->configureGUIScene();
|
2014-10-10 10:44:16 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
Menu* menu = static_cast<Menu*>(getChildByTag(1));
|
|
|
|
MenuItemToggle* menuItemToggle = static_cast<MenuItemToggle*>(menu->getChildByTag(1));
|
|
|
|
MenuItem* selectedItem = menuItemToggle->getSelectedItem();
|
|
|
|
menuItemToggle->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y + selectedItem->getContentSize().height * 3.75f));
|
|
|
|
*/
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UILayoutTest_BackGroundImage_Scale9_Editor
|
|
|
|
|
|
|
|
UILayoutTest_BackGroundImage_Scale9_Editor::UILayoutTest_BackGroundImage_Scale9_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UILayoutTest_BackGroundImage_Scale9_Editor::~UILayoutTest_BackGroundImage_Scale9_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
void UILayoutTest_BackGroundImage_Scale9_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
|
|
|
{
|
|
|
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
|
|
|
|
2014-10-10 10:44:16 +08:00
|
|
|
switch (item->getSelectedIndex())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/windows_ui_layout_scale9_backgroundimage_editor.json"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/windows_ui_layout_scale9_backgroundimage_editor.csb"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/crossplatform_UILayout_Scale9_BackgroundImage_Editor_1.ExportJson");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/crossplatform_UILayout_Scale9_BackgroundImage_Editor_1.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2014-07-01 15:01:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UILayoutTest_BackGroundImage_Scale9_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"));
|
|
|
|
|
|
|
|
Button* left_button = Button::create();
|
|
|
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
|
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
|
|
left_button->getContentSize().height));
|
|
|
|
left_button->setTouchEnabled(true);
|
|
|
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
|
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
_layout->addChild(left_button);
|
|
|
|
|
|
|
|
Button* right_button = Button::create();
|
|
|
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
|
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
|
|
right_button->getContentSize().height));
|
|
|
|
right_button->setTouchEnabled(true);
|
|
|
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
|
|
_layout->addChild(right_button);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2014-10-10 10:44:16 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/crossplatform_UILayout_Scale9_BackgroundImage_Editor_1.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
2014-03-04 16:51:35 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
2014-10-10 10:44:16 +08:00
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
this->configureGUIScene();
|
2014-10-10 10:44:16 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
Menu* menu = static_cast<Menu*>(getChildByTag(1));
|
|
|
|
MenuItemToggle* menuItemToggle = static_cast<MenuItemToggle*>(menu->getChildByTag(1));
|
|
|
|
MenuItem* selectedItem = menuItemToggle->getSelectedItem();
|
|
|
|
menuItemToggle->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y + selectedItem->getContentSize().height * 4.25f));
|
|
|
|
*/
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UILayoutTest_Layout_Linear_Vertical_Editor
|
|
|
|
|
|
|
|
UILayoutTest_Layout_Linear_Vertical_Editor::UILayoutTest_Layout_Linear_Vertical_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UILayoutTest_Layout_Linear_Vertical_Editor::~UILayoutTest_Layout_Linear_Vertical_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
void UILayoutTest_Layout_Linear_Vertical_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
|
|
|
{
|
|
|
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
|
|
|
|
2014-10-10 10:44:16 +08:00
|
|
|
switch (item->getSelectedIndex())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/windows_ui_layout_linear_vertical_layout_editor.json"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/windows_ui_layout_linear_vertical_layout_editor.csb"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/crossplatform_UILayout_Linear_Vertical_Layout_Editor_1.ExportJson");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/crossplatform_UILayout_Linear_Vertical_Layout_Editor_1.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2014-07-01 15:01:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UILayoutTest_Layout_Linear_Vertical_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"));
|
|
|
|
|
|
|
|
Button* left_button = Button::create();
|
|
|
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
|
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
|
|
left_button->getContentSize().height * 0.625));
|
|
|
|
left_button->setTouchEnabled(true);
|
|
|
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
|
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
_layout->addChild(left_button);
|
|
|
|
|
|
|
|
Button* right_button = Button::create();
|
|
|
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
|
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
|
|
right_button->getContentSize().height * 0.625));
|
|
|
|
right_button->setTouchEnabled(true);
|
|
|
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
|
|
_layout->addChild(right_button);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2014-10-10 10:44:16 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/windows_ui_layout_linear_vertical_layout_editor.json"));
|
2014-07-01 15:01:38 +08:00
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
this->configureGUIScene();
|
2014-10-10 10:44:16 +08:00
|
|
|
|
|
|
|
Menu* menu = static_cast<Menu*>(getChildByTag(1));
|
|
|
|
MenuItemToggle* menuItemToggle = static_cast<MenuItemToggle*>(menu->getChildByTag(1));
|
|
|
|
MenuItem* selectedItem = menuItemToggle->getSelectedItem();
|
|
|
|
menuItemToggle->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y + selectedItem->getContentSize().height * 4.25f));
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UILayoutTest_Layout_Linear_Horizontal_Editor
|
|
|
|
|
|
|
|
UILayoutTest_Layout_Linear_Horizontal_Editor::UILayoutTest_Layout_Linear_Horizontal_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UILayoutTest_Layout_Linear_Horizontal_Editor::~UILayoutTest_Layout_Linear_Horizontal_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
void UILayoutTest_Layout_Linear_Horizontal_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
2014-03-04 16:51:35 +08:00
|
|
|
{
|
2014-07-01 15:01:38 +08:00
|
|
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
|
|
|
|
2014-10-10 10:44:16 +08:00
|
|
|
switch (item->getSelectedIndex())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/windows_ui_layout_linear_horizontal_layout_editor.json"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/windows_ui_layout_linear_horizontal_layout_editor.csb"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/crossplatform_UILayout_Linear_Horizontal_Layout_Editor_1.ExportJson");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/crossplatform_UILayout_Linear_Horizontal_Layout_Editor_1.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2014-07-01 15:01:38 +08:00
|
|
|
}
|
|
|
|
}
|
2014-03-04 16:51:35 +08:00
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
void UILayoutTest_Layout_Linear_Horizontal_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"));
|
|
|
|
|
|
|
|
Button* left_button = Button::create();
|
|
|
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
|
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
|
|
left_button->getContentSize().height * 0.625));
|
|
|
|
left_button->setTouchEnabled(true);
|
|
|
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
|
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
_layout->addChild(left_button);
|
|
|
|
|
|
|
|
Button* right_button = Button::create();
|
|
|
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
|
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
|
|
right_button->getContentSize().height * 0.625));
|
|
|
|
right_button->setTouchEnabled(true);
|
|
|
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
|
|
_layout->addChild(right_button);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2014-10-10 10:44:16 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/windows_ui_layout_linear_horizontal_layout_editor.json"));
|
2014-07-01 15:01:38 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
2014-03-04 16:51:35 +08:00
|
|
|
|
2014-10-10 10:44:16 +08:00
|
|
|
Menu* menu = static_cast<Menu*>(getChildByTag(1));
|
|
|
|
MenuItemToggle* menuItemToggle = static_cast<MenuItemToggle*>(menu->getChildByTag(1));
|
|
|
|
MenuItem* selectedItem = menuItemToggle->getSelectedItem();
|
|
|
|
menuItemToggle->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y + selectedItem->getContentSize().height * 4.25f));
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UILayoutTest_Layout_Relative_Align_Parent_Editor
|
|
|
|
|
|
|
|
UILayoutTest_Layout_Relative_Align_Parent_Editor::UILayoutTest_Layout_Relative_Align_Parent_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UILayoutTest_Layout_Relative_Align_Parent_Editor::~UILayoutTest_Layout_Relative_Align_Parent_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
void UILayoutTest_Layout_Relative_Align_Parent_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
|
|
|
{
|
|
|
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
|
|
|
|
2014-10-10 10:44:16 +08:00
|
|
|
switch (item->getSelectedIndex())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/windows_ui_layout_relative_align_parent_editor.json"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/windows_ui_layout_relative_align_parent_editor.csb"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/crossplatform_UILayout_Relative_Align_Parent_Editor_1.ExportJson");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/crossplatform_UILayout_Relative_Align_Parent_Editor_1.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2014-07-01 15:01:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UILayoutTest_Layout_Relative_Align_Parent_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"));
|
|
|
|
|
|
|
|
Button* left_button = Button::create();
|
|
|
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
|
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
|
|
left_button->getContentSize().height * 0.625));
|
|
|
|
left_button->setTouchEnabled(true);
|
|
|
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
|
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
_layout->addChild(left_button);
|
|
|
|
|
|
|
|
Button* right_button = Button::create();
|
|
|
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
|
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
|
|
right_button->getContentSize().height * 0.625));
|
|
|
|
right_button->setTouchEnabled(true);
|
|
|
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
|
|
_layout->addChild(right_button);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2014-10-10 10:44:16 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/windows_ui_layout_relative_align_parent_editor.json"));
|
2014-03-04 16:51:35 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
2014-07-01 15:01:38 +08:00
|
|
|
this->configureGUIScene();
|
2014-03-04 16:51:35 +08:00
|
|
|
|
2014-10-10 10:44:16 +08:00
|
|
|
Menu* menu = static_cast<Menu*>(getChildByTag(1));
|
|
|
|
MenuItemToggle* menuItemToggle = static_cast<MenuItemToggle*>(menu->getChildByTag(1));
|
|
|
|
MenuItem* selectedItem = menuItemToggle->getSelectedItem();
|
|
|
|
menuItemToggle->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y + selectedItem->getContentSize().height * 4.25f));
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UILayoutTest_Layout_Relative_Location_Editor
|
|
|
|
|
|
|
|
UILayoutTest_Layout_Relative_Location_Editor::UILayoutTest_Layout_Relative_Location_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UILayoutTest_Layout_Relative_Location_Editor::~UILayoutTest_Layout_Relative_Location_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-01 15:01:38 +08:00
|
|
|
void UILayoutTest_Layout_Relative_Location_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
|
|
|
{
|
|
|
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
|
|
|
|
2014-10-10 10:44:16 +08:00
|
|
|
switch (item->getSelectedIndex())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/windows_ui_layout_relative_align_location_editor.json"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/windows_ui_layout_relative_align_location_editor.csb"));
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/crossplatform_UILayout_Relative_Align_Location_Editor_1.ExportJson");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/crossplatform_UILayout_Relative_Align_Location_Editor_1.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2014-07-01 15:01:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UILayoutTest_Layout_Relative_Location_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"));
|
|
|
|
|
|
|
|
Button* left_button = Button::create();
|
|
|
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
|
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
|
|
left_button->getContentSize().height * 0.625));
|
|
|
|
left_button->setTouchEnabled(true);
|
|
|
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
|
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
_layout->addChild(left_button);
|
|
|
|
|
|
|
|
Button* right_button = Button::create();
|
|
|
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
|
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
|
|
right_button->getContentSize().height * 0.625));
|
|
|
|
right_button->setTouchEnabled(true);
|
|
|
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
|
|
_layout->addChild(right_button);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
bool UILayoutTest_Layout_Relative_Location_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2014-10-10 10:44:16 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/windows_ui_layout_relative_align_location_editor.json"));
|
2014-03-04 16:51:35 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
2014-07-01 15:01:38 +08:00
|
|
|
this->configureGUIScene();
|
2014-10-10 10:44:16 +08:00
|
|
|
|
|
|
|
Menu* menu = static_cast<Menu*>(getChildByTag(1));
|
|
|
|
MenuItemToggle* menuItemToggle = static_cast<MenuItemToggle*>(menu->getChildByTag(1));
|
|
|
|
MenuItem* selectedItem = menuItemToggle->getSelectedItem();
|
|
|
|
menuItemToggle->setPosition(Vec2(VisibleRect::center().x, VisibleRect::center().y + selectedItem->getContentSize().height * 4.25f));
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|