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
|
|
|
|
2015-04-09 12:23:47 +08:00
|
|
|
USING_NS_CC;
|
|
|
|
using namespace cocos2d::ui;
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
UIScrollViewEditorTests::UIScrollViewEditorTests()
|
|
|
|
{
|
|
|
|
ADD_TEST_CASE(UIScrollViewTest_Vertical_Editor);
|
|
|
|
ADD_TEST_CASE(UIScrollViewTest_Horizontal_Editor);
|
|
|
|
ADD_TEST_CASE(UIScrollViewTest_Both_Editor);
|
|
|
|
ADD_TEST_CASE(UIScrollViewTest_ScrollToPercentBothDirection_Editor);
|
|
|
|
ADD_TEST_CASE(UIScrollViewTest_ScrollToPercentBothDirection_Bounce_Editor);
|
|
|
|
}
|
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
|
|
|
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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2015-04-03 14:31:03 +08:00
|
|
|
|
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
|
|
|
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();
|
2015-04-03 14:31:03 +08:00
|
|
|
|
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-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));
|
|
|
|
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-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));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|