PuzzleSDK
UIFocusTestNestedLayout1类 参考

#include <UIFocusTest.h>

+ 类 UIFocusTestNestedLayout1 继承关系图:
+ UIFocusTestNestedLayout1 的协作图:

Public 成员函数

 CREATE_FUNC (UIFocusTestNestedLayout1)
 
 UIFocusTestNestedLayout1 ()
 
virtual ~UIFocusTestNestedLayout1 ()
 
virtual bool init () override
 
void toggleFocusLoop (cocos2d::Ref *, cocos2d::ui::Widget::TouchEventType)
 
- Public 成员函数 继承自 UIFocusTestBase
 UIFocusTestBase ()
 
virtual ~UIFocusTestBase ()
 
virtual void onLeftKeyPressed ()
 
virtual void onRightKeyPressed ()
 
virtual void onUpKeyPressed ()
 
virtual void onDownKeyPressed ()
 
virtual void onFocusChanged (cocos2d::ui::Widget *widgetLostFocus, cocos2d::ui::Widget *widgetGetFocus)
 
void onImageViewClicked (cocos2d::Ref *ref, cocos2d::ui::Widget::TouchEventType touchType)
 
- Public 成员函数 继承自 UIScene
 UIScene ()
 
 ~UIScene ()
 
virtual void onEnter () override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string title () const
 
virtual std::string subtitle () const
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 

Protected 属性

cocos2d::ui::Layout * _verticalLayout
 
cocos2d::ui::Text * _loopText
 
- Protected 属性 继承自 UIFocusTestBase
cocos2d::Menu * _dpadMenu
 
cocos2d::ui::Widget * _firstFocusedWidget
 
cocos2d::EventListenerFocus * _eventListener
 
cocos2d::ui::Button * _toggleButton
 
- Protected 属性 继承自 UIScene
cocos2d::Layer * _uiLayer
 
cocos2d::ui::Layout * _widget
 
cocos2d::ui::Text * _sceneTitle
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 

详细描述

在文件 UIFocusTest.h96 行定义.

构造及析构函数说明

◆ UIFocusTestNestedLayout1()

UIFocusTestNestedLayout1::UIFocusTestNestedLayout1 ( )

在文件 UIFocusTest.cpp294 行定义.

295{
296
297}

◆ ~UIFocusTestNestedLayout1()

UIFocusTestNestedLayout1::~UIFocusTestNestedLayout1 ( )
virtual

在文件 UIFocusTest.cpp299 行定义.

300{
301
302}

成员函数说明

◆ CREATE_FUNC()

UIFocusTestNestedLayout1::CREATE_FUNC ( UIFocusTestNestedLayout1  )

◆ init()

bool UIFocusTestNestedLayout1::init ( )
overridevirtual

重载 UIFocusTestBase .

在文件 UIFocusTest.cpp304 行定义.

305{
306 if (UIFocusTestBase::init()) {
307
308 Size winSize = Director::getInstance()->getVisibleSize();
309
310 _verticalLayout = VBox::create();
311 _verticalLayout->setPosition(Vec2(winSize.width/2 - 80, winSize.height - 70));
312 _uiLayer->addChild(_verticalLayout);
313 _verticalLayout->setScale(0.5);
314
315 _verticalLayout->setFocused(true);
316 _verticalLayout->setLoopFocus(true);
317 _verticalLayout->setTag(100);
319
320 int count1 = 1;
321 for (int i=0; i<count1; ++i) {
322 ImageView *w = ImageView::create("cocosui/scrollviewbg.png");
323 w->setAnchorPoint(Vec2::ZERO);
324 w->setTouchEnabled(true);
325 w->setScaleX(2.5);
326 w->setTag(i+count1);
327 w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout1::onImageViewClicked, this));
328 _verticalLayout->addChild(w);
329 }
330
331 //add HBox into VBox
332 HBox *hbox = HBox::create();
333 hbox->setScale(0.8f);
334 hbox->setTag(101);
335 _verticalLayout->addChild(hbox);
336
337 int count2 = 2;
338 for (int i=0; i < count2; ++i) {
339 ImageView *w = ImageView::create("cocosui/scrollviewbg.png");
340 w->setAnchorPoint(Vec2(0,1));
341 w->setScaleY(2.0);
342 w->setTouchEnabled(true);
343 w->setTag(i+count1+count2);
344 w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout1::onImageViewClicked, this));
345 hbox->addChild(w);
346 }
347
348 VBox *innerVBox = VBox::create();
349 hbox->addChild(innerVBox);
350 innerVBox->setTag(102);
351// innerVBox->setPassFocusToChild(false);
352// innerVBox->setFocusEnabled(false);
353
354
355 int count3 = 2;
356 for (int i=0; i<count3; ++i) {
357 ImageView *w = ImageView::create("cocosui/scrollviewbg.png");
358 w->setTouchEnabled(true);
359 w->setTag(i+count1+count2+count3);
360 w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout1::onImageViewClicked, this));
361 innerVBox->addChild(w);
362 }
363
364 _loopText = Text::create("loop enabled", "Arial", 20);
365 _loopText->setPosition(Vec2(winSize.width/2, winSize.height - 50));
366 _loopText->setColor(Color3B::GREEN);
367 this->addChild(_loopText);
368
369 _toggleButton->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout1::toggleFocusLoop, this));
370
371 return true;
372 }
373 return false;
374}
cocos2d::ui::Widget * _firstFocusedWidget
Definition: UIFocusTest.h:58
virtual bool init() override
Definition: UIFocusTest.cpp:57
void onImageViewClicked(cocos2d::Ref *ref, cocos2d::ui::Widget::TouchEventType touchType)
cocos2d::ui::Button * _toggleButton
Definition: UIFocusTest.h:60
cocos2d::ui::Layout * _verticalLayout
Definition: UIFocusTest.h:108
void toggleFocusLoop(cocos2d::Ref *, cocos2d::ui::Widget::TouchEventType)
cocos2d::ui::Text * _loopText
Definition: UIFocusTest.h:109
cocos2d::Layer * _uiLayer
Definition: UIScene.h:44

引用了 UIFocusTestBase::_firstFocusedWidget, _loopText, UIFocusTestBase::_toggleButton, UIScene::_uiLayer, _verticalLayout, UIFocusTestBase::init(), UIFocusTestBase::onImageViewClicked() , 以及 toggleFocusLoop().

+ 函数调用图:

◆ toggleFocusLoop()

void UIFocusTestNestedLayout1::toggleFocusLoop ( cocos2d::Ref *  ,
cocos2d::ui::Widget::TouchEventType   
)

在文件 UIFocusTest.cpp377 行定义.

378{
379 if (type == Widget::TouchEventType::ENDED) {
380 _verticalLayout->setLoopFocus(!_verticalLayout->isLoopFocus());
381 if (_verticalLayout->isLoopFocus()) {
382 _loopText->setString("loop enabled");
383 }else{
384 _loopText->setString("loop disabled");
385 }
386 }
387}

引用了 _loopText , 以及 _verticalLayout.

被这些函数引用 init().

+ 这是这个函数的调用关系图:

类成员变量说明

◆ _loopText

cocos2d::ui::Text* UIFocusTestNestedLayout1::_loopText
protected

在文件 UIFocusTest.h109 行定义.

被这些函数引用 init() , 以及 toggleFocusLoop().

◆ _verticalLayout

cocos2d::ui::Layout* UIFocusTestNestedLayout1::_verticalLayout
protected

在文件 UIFocusTest.h108 行定义.

被这些函数引用 init() , 以及 toggleFocusLoop().


该类的文档由以下文件生成: