2014-03-04 16:51:35 +08:00
|
|
|
#include "UIPageViewTest_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
|
|
|
UIPageViewEditorTests::UIPageViewEditorTests()
|
|
|
|
{
|
|
|
|
ADD_TEST_CASE(UIPageViewTest_Editor);
|
|
|
|
}
|
2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
// UIPageViewTest_Editor
|
|
|
|
|
|
|
|
UIPageViewTest_Editor::UIPageViewTest_Editor()
|
2014-04-09 22:53:59 +08:00
|
|
|
: _displayValueLabel(nullptr)
|
2014-03-04 16:51:35 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIPageViewTest_Editor::~UIPageViewTest_Editor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-01 15:19:40 +08:00
|
|
|
bool UIPageViewTest_Editor::init()
|
|
|
|
{
|
|
|
|
if (UIScene_Editor::init())
|
|
|
|
{
|
2015-05-14 18:08:37 +08:00
|
|
|
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIPageView/res.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
|
|
|
|
2015-07-16 16:50:47 +08:00
|
|
|
auto pageView = (PageView*)(ui::Helper::seekWidgetByName(_layout, "PageView_1269"));
|
|
|
|
pageView->scrollToPage(1); // 1->2
|
|
|
|
|
2014-07-01 15:19:40 +08:00
|
|
|
this->configureGUIScene();
|
2015-04-03 14:31:03 +08:00
|
|
|
|
2015-07-16 16:50:47 +08:00
|
|
|
auto button1 = Button::create();
|
|
|
|
button1->setTitleText("scrollToPage 3");
|
|
|
|
button1->setNormalizedPosition(Vec2(0.8,0.2));
|
|
|
|
button1->addClickEventListener([=](Ref*){
|
|
|
|
pageView->scrollToPage(2);
|
|
|
|
});
|
|
|
|
_touchGroup->addChild(button1);
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|