Merge pull request #11438 from andyque/removeUnusedFocusTest

remove listview focus test
This commit is contained in:
minggo 2015-04-14 18:26:32 +08:00
commit 440d70f44b
2 changed files with 94 additions and 197 deletions

View File

@ -18,7 +18,6 @@ UIFocusTests::UIFocusTests()
ADD_TEST_CASE(UIFocusTestNestedLayout1);
ADD_TEST_CASE(UIFocusTestNestedLayout2);
ADD_TEST_CASE(UIFocusTestNestedLayout3);
ADD_TEST_CASE(UIFocusTestListView);
}
UIFocusTestBase::UIFocusTestBase()
@ -588,89 +587,3 @@ void UIFocusTestNestedLayout3::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::Tou
}
}
}
//UIFocusTestListView
UIFocusTestListView::UIFocusTestListView()
{
}
UIFocusTestListView::~UIFocusTestListView()
{
}
bool UIFocusTestListView::init()
{
if (UIFocusTestBase::init()) {
Size winSize = Director::getInstance()->getVisibleSize();
_listView = ListView::create();
_listView->setDirection(ui::ScrollView::Direction::VERTICAL);
_listView->setBounceEnabled(true);
_listView->setBackGroundImage("cocosui/green_edit.png");
_listView->setBackGroundImageScale9Enabled(true);
_listView->setContentSize(Size(240, 130));
_listView->setPosition(Vec2(40, 70));
_uiLayer->addChild(_listView);
_listView->setScale(0.8f);
_listView->setFocused(true);
_listView->setLoopFocus(true);
_listView->setTag(-1000);
_firstFocusedWidget = _listView;
// create model
Button* default_button = Button::create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png");
default_button->setName("Title Button");
// set model
_listView->setItemModel(default_button);
// add default item
ssize_t count = 20;
for (int i = 0; i < count / 4; ++i)
{
_listView->pushBackDefaultItem();
}
// insert default item
for (int i = 0; i < count / 4; ++i)
{
_listView->insertDefaultItem(0);
}
_loopText = Text::create("loop enabled", "Arial", 20);
_loopText->setPosition(Vec2(winSize.width/2, winSize.height - 50));
_loopText->setColor(Color3B::GREEN);
this->addChild(_loopText);
auto btn = Button::create("cocosui/switch-mask.png");
btn->setTitleText("Toggle Loop");
btn->setPosition(Vec2(60, winSize.height - 50));
btn->setTitleColor(Color3B::RED);
btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestListView::toggleFocusLoop, this));
this->addChild(btn);
return true;
}
return false;
}
void UIFocusTestListView::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::TouchEventType type)
{
if (type == Widget::TouchEventType::ENDED) {
_listView->setLoopFocus(!_listView->isLoopFocus());
if (_listView->isLoopFocus()) {
_loopText->setString("loop enabled");
}else{
_loopText->setString("loop disabled");
}
}
}

View File

@ -116,22 +116,6 @@ protected:
cocos2d::ui::Text* _loopText;
};
class UIFocusTestListView : public UIFocusTestBase
{
public:
CREATE_FUNC(UIFocusTestListView);
UIFocusTestListView();
virtual ~UIFocusTestListView();
virtual bool init() override;
void toggleFocusLoop(cocos2d::Ref*,cocos2d::ui::Widget::TouchEventType);
protected:
cocos2d::ui::ListView* _listView;
cocos2d::ui::Text* _loopText;
};
#endif /* defined(__cocos2d_tests__UIFocusTest__) */