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);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Layout/windows_ui_layout_editor_1.json"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout/Layout/windows_ui_layout_editor_1.csb"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Layout/crossplatform_UILayout_Editor_1.ExportJson");
|
2014-10-10 10:44:16 +08:00
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Layout/crossplatform_UILayout_Editor_1.csb");
|
2014-10-10 10:44:16 +08:00
|
|
|
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-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Layout/crossplatform_UILayout_Editor_1.csb");
|
2014-10-10 10:44:16 +08:00
|
|
|
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);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Color/windows_ui_color.json"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout/Color/windows_ui_color.csb"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Color/crossplatform_Colo.ExportJson");
|
2014-10-10 10:44:16 +08:00
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2015-01-21 17:08:16 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Color/crossplatform_UILayout_Color_Editor_1.csb");
|
2014-10-10 10:44:16 +08:00
|
|
|
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())
|
|
|
|
{
|
2015-01-21 17:08:16 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Color/crossplatform_UILayout_Color_Editor_1.csb");
|
2014-10-10 10:44:16 +08:00
|
|
|
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);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Gradient_Color/windows_ui_gradient_color.json"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout/Gradient_Color/windows_ui_gradient_color.csb"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Gradient_Color/crossplatform_Gradient_Color.ExportJson");
|
2014-10-10 10:44:16 +08:00
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Gradient_Color/crossplatform_Gradient_Color.csb");
|
2014-10-10 10:44:16 +08:00
|
|
|
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-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Gradient_Color/crossplatform_Gradient_Color.csb");
|
2014-10-10 10:44:16 +08:00
|
|
|
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);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/BackgroundImage/windows_ui_backgroundimage.json"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout/BackgroundImage/windows_ui_backgroundimage.csb"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/BackgroundImage/crossplatform_BackgroundImage.ExportJson");
|
2014-10-10 10:44:16 +08:00
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/BackgroundImage/crossplatform_BackgroundImage.csb");
|
2014-10-10 10:44:16 +08:00
|
|
|
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-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/BackgroundImage/crossplatform_BackgroundImage.csb");
|
2014-10-10 10:44:16 +08:00
|
|
|
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);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Scale9_BackgroundImage/windows_ui_scale9_backgroundimage.json"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout/Scale9_BackgroundImage/windows_ui_scale9_backgroundimage.csb"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Scale9_BackgroundImage/crossplatform_Scale9_BackgroundImage.ExportJson");
|
2014-10-10 10:44:16 +08:00
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Scale9_BackgroundImage/crossplatform_Scale9_BackgroundImage.csb");
|
2014-10-10 10:44:16 +08:00
|
|
|
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-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Scale9_BackgroundImage/crossplatform_Scale9_BackgroundImage.csb");
|
2014-10-10 10:44:16 +08:00
|
|
|
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);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Linear_Vertical_Layout/windows_ui_linear_vertical_layout.json"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout/Linear_Vertical_Layout/windows_ui_linear_vertical_layout.csb"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Linear_Vertical_Layout/crossplatform_Linear_Vertical_Layout.ExportJson");
|
2014-10-10 10:44:16 +08:00
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Linear_Vertical_Layout/crossplatform_Linear_Vertical_Layout.csb");
|
2014-10-10 10:44:16 +08:00
|
|
|
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-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Linear_Vertical_Layout/windows_ui_linear_vertical_layout.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);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Linear_Horizontal_Layout/windows_ui_linear_horizontal_layout.json"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout/Linear_Horizontal_Layout/windows_ui_linear_horizontal_layout.csb"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Linear_Horizontal_Layout/crossplatform_Linear_Horizontal_Layout.ExportJson");
|
2014-10-10 10:44:16 +08:00
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Linear_Horizontal_Layout/crossplatform_Linear_Horizontal_Layout.csb");
|
2014-10-10 10:44:16 +08:00
|
|
|
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-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Linear_Horizontal_Layout/windows_ui_linear_horizontal_layout.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);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Relative_Align_Parent/windows_ui_relative_align_parent.json"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout/Relative_Align_Parent/windows_ui_relative_align_parent.csb"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Relative_Align_Parent/crossplatform_Relative_Align_Parent.ExportJson");
|
2014-10-10 10:44:16 +08:00
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Relative_Align_Parent/crossplatform_Relative_Align_Parent.csb");
|
2014-10-10 10:44:16 +08:00
|
|
|
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-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Relative_Align_Parent/windows_ui_relative_align_parent.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);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Relative_Align_Location/windows_ui_relative_align_location.json"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout/Relative_Align_Location/windows_ui_relative_align_location.csb"));
|
2014-10-10 10:44:16 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Relative_Align_Location/crossplatform_Relative_Align_Location.ExportJson");
|
2014-10-10 10:44:16 +08:00
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
_layout->removeFromParentAndCleanup(true);
|
|
|
|
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Relative_Align_Location/crossplatform_Relative_Align_Location.csb");
|
2014-10-10 10:44:16 +08:00
|
|
|
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-18 14:48:27 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Relative_Align_Location/windows_ui_relative_align_location.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;
|
|
|
|
}
|
2014-12-22 18:24:06 +08:00
|
|
|
|
|
|
|
UILayoutComponentTest_Editor::UILayoutComponentTest_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UILayoutComponentTest_Editor::~UILayoutComponentTest_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void UILayoutComponentTest_Editor::configureGUIScene()
|
|
|
|
{
|
2015-01-14 11:34:43 +08:00
|
|
|
Size screenSize = Director::getInstance()->getWinSize();
|
|
|
|
Size rootSize = _layout->getContentSize();
|
|
|
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
|
|
(screenSize.height - rootSize.height) / 2));
|
2014-12-22 18:24:06 +08:00
|
|
|
|
2015-01-14 11:34:43 +08:00
|
|
|
_root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
2014-12-22 18:24:06 +08:00
|
|
|
|
2015-01-14 11:34:43 +08:00
|
|
|
ui::Text* back_label = static_cast<ui::Text*>(Helper::seekWidgetByName(_root, "back"));
|
2014-12-22 18:24:06 +08:00
|
|
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
2015-01-14 11:34:43 +08:00
|
|
|
|
|
|
|
_sceneTitle = static_cast<ui::Text*>(Helper::seekWidgetByName(_root, "UItest"));
|
2014-12-22 18:24:06 +08:00
|
|
|
|
|
|
|
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,
|
2015-01-14 11:34:43 +08:00
|
|
|
left_button->getContentSize().height));
|
2014-12-22 18:24:06 +08:00
|
|
|
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,
|
2015-01-14 11:34:43 +08:00
|
|
|
right_button->getContentSize().height));
|
2014-12-22 18:24:06 +08:00
|
|
|
right_button->setTouchEnabled(true);
|
|
|
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
|
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
|
|
_layout->addChild(right_button);
|
|
|
|
|
2015-01-14 11:34:43 +08:00
|
|
|
_hUnchecked = static_cast<ui::Button*>(Helper::seekWidgetByName(_root, "Button_h_unchecked"));
|
|
|
|
_vUnchecked = static_cast<ui::Button*>(Helper::seekWidgetByName(_root, "Button_v_unchecked"));
|
|
|
|
_hChecked = static_cast<ui::Button*>(Helper::seekWidgetByName(_root, "Button_h_checked"));
|
|
|
|
_vChecked = static_cast<ui::Button*>(Helper::seekWidgetByName(_root, "Button_v_checked"));
|
|
|
|
_lPinUnchecked = static_cast<ui::Button*>(Helper::seekWidgetByName(_root, "Button_Pin_Left"));
|
|
|
|
_rPinUnchecked = static_cast<ui::Button*>(Helper::seekWidgetByName(_root, "Button_Pin_Right"));
|
|
|
|
_tPinUnchecked = static_cast<ui::Button*>(Helper::seekWidgetByName(_root, "Button_Pin_Top"));
|
|
|
|
_bPinUnchecked = static_cast<ui::Button*>(Helper::seekWidgetByName(_root, "Button_Pin_Bottom"));
|
|
|
|
_lPinChecked = static_cast<ui::Button*>(Helper::seekWidgetByName(_root, "Button_Pin_Left_Checked"));
|
|
|
|
_rPinChecked = static_cast<ui::Button*>(Helper::seekWidgetByName(_root, "Button_Pin_Right_Checked"));
|
|
|
|
_tPinChecked = static_cast<ui::Button*>(Helper::seekWidgetByName(_root, "Button_Pin_Top_Checked"));
|
|
|
|
_bPinChecked = static_cast<ui::Button*>(Helper::seekWidgetByName(_root, "Button_Pin_Bottom_Checked"));
|
|
|
|
|
|
|
|
_hUnchecked->addClickEventListener(CC_CALLBACK_1(UILayoutComponentTest_Editor::onChangeLayoutComponent, this));
|
|
|
|
_vUnchecked->addClickEventListener(CC_CALLBACK_1(UILayoutComponentTest_Editor::onChangeLayoutComponent, this));
|
|
|
|
_hChecked->addClickEventListener(CC_CALLBACK_1(UILayoutComponentTest_Editor::onChangeLayoutComponent, this));
|
|
|
|
_vChecked->addClickEventListener(CC_CALLBACK_1(UILayoutComponentTest_Editor::onChangeLayoutComponent, this));
|
|
|
|
_lPinUnchecked->addClickEventListener(CC_CALLBACK_1(UILayoutComponentTest_Editor::onChangeLayoutComponent, this));
|
|
|
|
_rPinUnchecked->addClickEventListener(CC_CALLBACK_1(UILayoutComponentTest_Editor::onChangeLayoutComponent, this));
|
|
|
|
_tPinUnchecked->addClickEventListener(CC_CALLBACK_1(UILayoutComponentTest_Editor::onChangeLayoutComponent, this));
|
|
|
|
_bPinUnchecked->addClickEventListener(CC_CALLBACK_1(UILayoutComponentTest_Editor::onChangeLayoutComponent, this));
|
|
|
|
_lPinChecked->addClickEventListener(CC_CALLBACK_1(UILayoutComponentTest_Editor::onChangeLayoutComponent, this));
|
|
|
|
_rPinChecked->addClickEventListener(CC_CALLBACK_1(UILayoutComponentTest_Editor::onChangeLayoutComponent, this));
|
|
|
|
_tPinChecked->addClickEventListener(CC_CALLBACK_1(UILayoutComponentTest_Editor::onChangeLayoutComponent, this));
|
|
|
|
_bPinChecked->addClickEventListener(CC_CALLBACK_1(UILayoutComponentTest_Editor::onChangeLayoutComponent, this));
|
|
|
|
|
|
|
|
_textPin = static_cast<ui::Text*>(Helper::seekWidgetByName(_root, "Text_Pin"));
|
|
|
|
_textStretch = static_cast<ui::Text*>(Helper::seekWidgetByName(_root, "Text_Stretch"));
|
|
|
|
_widget = Helper::seekWidgetByName(_root, "Image_Widget");
|
|
|
|
_container = Helper::seekWidgetByName(_root, "background_Panel");
|
|
|
|
|
|
|
|
auto btnSwitch = static_cast<ui::Button*>(Helper::seekWidgetByName(_root, "Button_Switch"));
|
|
|
|
btnSwitch->addClickEventListener(CC_CALLBACK_1(UILayoutComponentTest_Editor::onResizeContainer, this));
|
2014-12-22 18:24:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool UILayoutComponentTest_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2015-01-14 11:34:43 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/LayoutComponent/UILayoutComponent.csb");
|
|
|
|
Node* child = node->getChildByTag(5);
|
|
|
|
child->removeFromParent();
|
|
|
|
_layout = static_cast<Layout*>(child);
|
2014-12-22 18:24:06 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
this->configureGUIScene();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2015-01-14 11:34:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void UILayoutComponentTest_Editor::onChangeLayoutComponent(Ref* sender)
|
|
|
|
{
|
|
|
|
std::string statusStretch = _textStretch->getString();
|
|
|
|
std::string statusPin = _textPin->getString();
|
|
|
|
std::string hPinStatus = " Left";
|
|
|
|
std::string vPinStatus = " Bottom";
|
|
|
|
|
|
|
|
if (sender == _hUnchecked)
|
|
|
|
{
|
|
|
|
_hUnchecked->setVisible(false);
|
|
|
|
_hChecked->setVisible(true);
|
|
|
|
statusStretch += " Horizontal";
|
|
|
|
_textStretch->setString(statusStretch);
|
|
|
|
}
|
|
|
|
else if (sender == _hChecked)
|
|
|
|
{
|
|
|
|
_hChecked->setVisible(false);
|
|
|
|
_hUnchecked->setVisible(true);
|
|
|
|
statusStretch.erase(statusStretch.find(" Horizontal"), std::string(" Horizontal").length());
|
|
|
|
_textStretch->setString(statusStretch);
|
|
|
|
}
|
|
|
|
else if (sender == _vUnchecked)
|
|
|
|
{
|
|
|
|
_vUnchecked->setVisible(false);
|
|
|
|
_vChecked->setVisible(true);
|
|
|
|
statusStretch += " Vertical";
|
|
|
|
_textStretch->setString(statusStretch);
|
|
|
|
}
|
|
|
|
else if (sender == _vChecked)
|
|
|
|
{
|
|
|
|
_vChecked->setVisible(false);
|
|
|
|
_vUnchecked->setVisible(true);
|
|
|
|
statusStretch.erase(statusStretch.find(" Vertical"), std::string(" Vertical").length());
|
|
|
|
_textStretch->setString(statusStretch);
|
|
|
|
}
|
|
|
|
else if (sender == _lPinUnchecked)
|
|
|
|
{
|
|
|
|
_lPinUnchecked->setVisible(false);
|
|
|
|
_lPinChecked->setVisible(true);
|
|
|
|
}
|
|
|
|
else if (sender == _lPinChecked)
|
|
|
|
{
|
|
|
|
_lPinChecked->setVisible(false);
|
|
|
|
_lPinUnchecked->setVisible(true);
|
|
|
|
}
|
|
|
|
else if (sender == _rPinUnchecked)
|
|
|
|
{
|
|
|
|
_rPinUnchecked->setVisible(false);
|
|
|
|
_rPinChecked->setVisible(true);
|
|
|
|
}
|
|
|
|
else if (sender == _rPinChecked)
|
|
|
|
{
|
|
|
|
_rPinChecked->setVisible(false);
|
|
|
|
_rPinUnchecked->setVisible(true);
|
|
|
|
}
|
|
|
|
else if (sender == _tPinUnchecked)
|
|
|
|
{
|
|
|
|
_tPinUnchecked->setVisible(false);
|
|
|
|
_tPinChecked->setVisible(true);
|
|
|
|
}
|
|
|
|
else if (sender == _tPinChecked)
|
|
|
|
{
|
|
|
|
_tPinChecked->setVisible(false);
|
|
|
|
_tPinUnchecked->setVisible(true);
|
|
|
|
}
|
|
|
|
else if (sender == _bPinUnchecked)
|
|
|
|
{
|
|
|
|
_bPinUnchecked->setVisible(false);
|
|
|
|
_bPinChecked->setVisible(true);
|
|
|
|
}
|
|
|
|
else if (sender == _bPinChecked)
|
|
|
|
{
|
|
|
|
_bPinChecked->setVisible(false);
|
|
|
|
_bPinUnchecked->setVisible(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_rPinChecked->isVisible())
|
|
|
|
{
|
|
|
|
if (_lPinChecked->isVisible())
|
|
|
|
{
|
|
|
|
hPinStatus = " Left Right";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hPinStatus = " Right";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_tPinChecked->isVisible())
|
|
|
|
{
|
|
|
|
if (_bPinChecked->isVisible())
|
|
|
|
{
|
|
|
|
vPinStatus = " Top Bottom";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vPinStatus = " Top";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
statusPin = String::createWithFormat("Pin:%s%s", hPinStatus.c_str(), vPinStatus.c_str())->getCString();
|
|
|
|
_textPin->setString(statusPin);
|
|
|
|
|
|
|
|
auto layoutComponent = ui::LayoutComponent::bindLayoutComponent(_widget);
|
|
|
|
layoutComponent->setStretchWidthEnabled(statusStretch.find("Horizontal") != std::string::npos);
|
|
|
|
layoutComponent->setStretchHeightEnabled(statusStretch.find("Vertical") != std::string::npos);
|
|
|
|
|
|
|
|
ui::LayoutComponent::HorizontalEdge horizontalEdgeType = ui::LayoutComponent::HorizontalEdge::None;
|
|
|
|
if (statusPin.find("Left") != std::string::npos
|
|
|
|
&& statusPin.find("Right") == std::string::npos)
|
|
|
|
{
|
|
|
|
horizontalEdgeType = ui::LayoutComponent::HorizontalEdge::Left;
|
|
|
|
}
|
|
|
|
else if (statusPin.find("Left") == std::string::npos
|
|
|
|
&& statusPin.find("Right") != std::string::npos)
|
|
|
|
{
|
|
|
|
horizontalEdgeType = ui::LayoutComponent::HorizontalEdge::Right;
|
|
|
|
}
|
|
|
|
else if (statusPin.find("Left") != std::string::npos
|
|
|
|
&& statusPin.find("Right") != std::string::npos)
|
|
|
|
{
|
|
|
|
horizontalEdgeType = ui::LayoutComponent::HorizontalEdge::Center;
|
|
|
|
}
|
|
|
|
layoutComponent->setHorizontalEdge(horizontalEdgeType);
|
|
|
|
|
|
|
|
ui::LayoutComponent::VerticalEdge verticalEdgeType = ui::LayoutComponent::VerticalEdge::None;
|
|
|
|
if (statusPin.find("Top") != std::string::npos
|
|
|
|
&& statusPin.find("Bottom") == std::string::npos)
|
|
|
|
{
|
|
|
|
verticalEdgeType = ui::LayoutComponent::VerticalEdge::Top;
|
|
|
|
}
|
|
|
|
else if (statusPin.find("Top") == std::string::npos
|
|
|
|
&& statusPin.find("Bottom") != std::string::npos)
|
|
|
|
{
|
|
|
|
verticalEdgeType = ui::LayoutComponent::VerticalEdge::Bottom;
|
|
|
|
}
|
|
|
|
else if (statusPin.find("Top") != std::string::npos
|
|
|
|
&& statusPin.find("Bottom") != std::string::npos)
|
|
|
|
{
|
|
|
|
verticalEdgeType = ui::LayoutComponent::VerticalEdge::Center;
|
|
|
|
}
|
|
|
|
layoutComponent->setVerticalEdge(verticalEdgeType);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UILayoutComponentTest_Editor::onResizeContainer(Ref* sender)
|
|
|
|
{
|
|
|
|
auto layoutController = Helper::seekWidgetByName(_root, "Panel_Controller");
|
|
|
|
Size size = _container->getContentSize();
|
|
|
|
auto switchButton = Helper::seekWidgetByName(_root, "Button_Switch");
|
|
|
|
switchButton->setEnabled(false);
|
|
|
|
switchButton->setBright(false);
|
|
|
|
|
|
|
|
if (size.width < 200)
|
|
|
|
{
|
|
|
|
layoutController->setVisible(false);
|
|
|
|
this->schedule([=](float dt){
|
|
|
|
auto size = _container->getContentSize();
|
|
|
|
size.width += 303.f / 40.f;
|
|
|
|
size.height += 70.f / 40.f;
|
|
|
|
_container->setContentSize(size);
|
|
|
|
ui::Helper::doLayout(_container);
|
|
|
|
if (size.width > 390)
|
|
|
|
{
|
|
|
|
switchButton->setEnabled(true);
|
|
|
|
switchButton->setBright(true);
|
|
|
|
}
|
|
|
|
}, 0.025, 39, 0, "1");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
layoutController->setVisible(true);
|
|
|
|
this->schedule([=](float dt){
|
|
|
|
auto size = _container->getContentSize();
|
|
|
|
size.width -= 303.f / 40.f;
|
|
|
|
size.height -= 70.f / 40.f;
|
|
|
|
_container->setContentSize(size);
|
|
|
|
ui::Helper::doLayout(_container);
|
|
|
|
if (size.width < 110)
|
|
|
|
{
|
|
|
|
switchButton->setEnabled(true);
|
|
|
|
switchButton->setBright(true);
|
|
|
|
}
|
|
|
|
}, 0.025, 39, 0, "2");
|
|
|
|
}
|
2014-12-22 18:24:06 +08:00
|
|
|
}
|