2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
#include "UIScrollViewTest_Editor.h"
|
2014-10-10 10:44:16 +08:00
|
|
|
#include "VisibleRect.h"
|
2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
// UIScrollViewTest_Vertical_Editor
|
|
|
|
|
|
|
|
UIScrollViewTest_Vertical_Editor::UIScrollViewTest_Vertical_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIScrollViewTest_Vertical_Editor::~UIScrollViewTest_Vertical_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-01 15:19:40 +08:00
|
|
|
void UIScrollViewTest_Vertical_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
2014-03-04 16:51:35 +08:00
|
|
|
{
|
2014-07-01 15:19:40 +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/UIScrollView/Vertical/windows_ui_scrollview_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/UIScrollView/Vertical/windows_ui_scrollview_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/UIScrollView/Vertical/crossplatform_UIScrollView_Vertical_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/UIScrollView/Vertical/crossplatform_UIScrollView_Vertical_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:19:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIScrollViewTest_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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UIScrollViewTest_Vertical_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIScrollView/Vertical/crossplatform_UIScrollView_Vertical_Editor_1.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:19:40 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
2014-10-10 10:44:16 +08:00
|
|
|
|
2014-07-01 15:19:40 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UIScrollViewTest_Horizontal_Editor
|
|
|
|
|
|
|
|
UIScrollViewTest_Horizontal_Editor::UIScrollViewTest_Horizontal_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIScrollViewTest_Horizontal_Editor::~UIScrollViewTest_Horizontal_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-01 15:19:40 +08:00
|
|
|
void UIScrollViewTest_Horizontal_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
2014-03-04 16:51:35 +08:00
|
|
|
{
|
2014-07-01 15:19:40 +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/UIScrollView/Horizontal/windows_ui_scrollview_horizontal_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/UIScrollView/Horizontal/windows_ui_scrollview_horizontal_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/UIScrollView/Horizontal/crossplatform_UIScrollView_Horizontal_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/UIScrollView/Horizontal/crossplatform_UIScrollView_Horizontal_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:19:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIScrollViewTest_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 UIScrollViewTest_Horizontal_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIScrollView/Horizontal/crossplatform_UIScrollView_Horizontal_Editor_1.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:19:40 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
2014-10-10 10:44:16 +08:00
|
|
|
|
2014-07-01 15:19:40 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UIScrollViewTest_Both_Editor
|
|
|
|
|
|
|
|
UIScrollViewTest_Both_Editor::UIScrollViewTest_Both_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIScrollViewTest_Both_Editor::~UIScrollViewTest_Both_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-01 15:19:40 +08:00
|
|
|
void UIScrollViewTest_Both_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
2014-03-04 16:51:35 +08:00
|
|
|
{
|
2014-07-01 15:19:40 +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/UIScrollView/Both/windows_ui_scrollview_both_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/UIScrollView/Both/windows_ui_scrollview_both_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/UIScrollView/Both/crossplatform_UIScrollView_Both_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/UIScrollView/Both/crossplatform_UIScrollView_Both_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:19:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIScrollViewTest_Both_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 UIScrollViewTest_Both_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2014-10-18 14:48:27 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIScrollView/Both/crossplatform_UIScrollView_Both_Editor_1.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:19:40 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
2014-10-10 10:44:16 +08:00
|
|
|
|
2014-07-01 15:19:40 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UIScrollViewTest_ScrollToPercentBothDirection_Editor
|
|
|
|
|
|
|
|
UIScrollViewTest_ScrollToPercentBothDirection_Editor::UIScrollViewTest_ScrollToPercentBothDirection_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIScrollViewTest_ScrollToPercentBothDirection_Editor::~UIScrollViewTest_ScrollToPercentBothDirection_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-01 15:19:40 +08:00
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
bool UIScrollViewTest_ScrollToPercentBothDirection_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2014-06-05 10:25:45 +08:00
|
|
|
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UITest/UITest.json"));
|
2014-06-18 14:56:26 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UITest/UITest.csb"));
|
2014-03-04 16:51:35 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
2014-06-20 11:18:53 +08:00
|
|
|
Size rootSize = _layout->getContentSize();
|
2014-05-15 01:07:09 +08:00
|
|
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
2014-03-04 16:51:35 +08:00
|
|
|
(screenSize.height - rootSize.height) / 2));
|
|
|
|
|
|
|
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
|
|
|
|
|
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
2014-05-09 14:30:39 +08:00
|
|
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
|
|
|
|
|
|
Button* left_button = static_cast<Button*>(Helper::seekWidgetByName(root, "left_Button"));
|
2014-05-09 14:30:39 +08:00
|
|
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
Button* middle_button = static_cast<Button*>(Helper::seekWidgetByName(root, "middle_Button"));
|
|
|
|
middle_button->setVisible(false);
|
|
|
|
|
|
|
|
Button* right_button = static_cast<Button*>(Helper::seekWidgetByName(root, "right_Button"));
|
2014-05-09 14:30:39 +08:00
|
|
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UIScrollViewTest_ScrollToPercentBothDirection_Bounce_Editor
|
|
|
|
|
|
|
|
UIScrollViewTest_ScrollToPercentBothDirection_Bounce_Editor::UIScrollViewTest_ScrollToPercentBothDirection_Bounce_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIScrollViewTest_ScrollToPercentBothDirection_Bounce_Editor::~UIScrollViewTest_ScrollToPercentBothDirection_Bounce_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2014-06-05 10:25:45 +08:00
|
|
|
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UITest/UITest.json"));
|
2014-06-18 14:56:26 +08:00
|
|
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UITest/UITest.csb"));
|
2014-03-04 16:51:35 +08:00
|
|
|
_touchGroup->addChild(_layout);
|
|
|
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
2014-06-20 11:18:53 +08:00
|
|
|
Size rootSize = _layout->getContentSize();
|
2014-05-15 01:07:09 +08:00
|
|
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
2014-03-04 16:51:35 +08:00
|
|
|
(screenSize.height - rootSize.height) / 2));
|
|
|
|
|
|
|
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
|
|
|
|
|
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
2014-05-09 14:30:39 +08:00
|
|
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
|
|
|
|
|
|
Button* left_button = static_cast<Button*>(Helper::seekWidgetByName(root, "left_Button"));
|
2014-05-09 14:30:39 +08:00
|
|
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
Button* middle_button = static_cast<Button*>(Helper::seekWidgetByName(root, "middle_Button"));
|
|
|
|
middle_button->setVisible(false);
|
|
|
|
|
|
|
|
Button* right_button = static_cast<Button*>(Helper::seekWidgetByName(root, "right_Button"));
|
2014-05-09 14:30:39 +08:00
|
|
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|