PuzzleSDK
UIFocusTestNestedLayout2类 参考

#include <UIFocusTest.h>

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

Public 成员函数

 CREATE_FUNC (UIFocusTestNestedLayout2)
 
 UIFocusTestNestedLayout2 ()
 
virtual ~UIFocusTestNestedLayout2 ()
 
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 * _horizontalLayout
 
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.h112 行定义.

构造及析构函数说明

◆ UIFocusTestNestedLayout2()

UIFocusTestNestedLayout2::UIFocusTestNestedLayout2 ( )

在文件 UIFocusTest.cpp390 行定义.

391{
392
393}

◆ ~UIFocusTestNestedLayout2()

UIFocusTestNestedLayout2::~UIFocusTestNestedLayout2 ( )
virtual

在文件 UIFocusTest.cpp395 行定义.

396{
397
398}

成员函数说明

◆ CREATE_FUNC()

UIFocusTestNestedLayout2::CREATE_FUNC ( UIFocusTestNestedLayout2  )

◆ init()

bool UIFocusTestNestedLayout2::init ( )
overridevirtual

重载 UIFocusTestBase .

在文件 UIFocusTest.cpp400 行定义.

401{
402 if (UIFocusTestBase::init()) {
403
404 Size winSize = Director::getInstance()->getVisibleSize();
405
406 _horizontalLayout = HBox::create();
407 _horizontalLayout->setPosition(Vec2(winSize.width/2 - 200, winSize.height - 70));
408 _uiLayer->addChild(_horizontalLayout);
409 _horizontalLayout->setScale(0.6f);
410
411 _horizontalLayout->setFocused(true);
412 _horizontalLayout->setLoopFocus(true);
413 _horizontalLayout->setTag(100);
415
416 int count1 = 2;
417 for (int i=0; i<count1; ++i) {
418 ImageView *w = ImageView::create("cocosui/scrollviewbg.png");
419 w->setAnchorPoint(Vec2(0,1));
420 w->setTouchEnabled(true);
421 w->setTag(i+count1);
422 w->setScaleY(2.4f);
423 w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout2::onImageViewClicked, this));
424 _horizontalLayout->addChild(w);
425 }
426
427 //add HBox into VBox
428 VBox *vbox = VBox::create();
429 vbox->setScale(0.8f);
430 vbox->setTag(101);
431 _horizontalLayout->addChild(vbox);
432
433 int count2 = 2;
434 for (int i=0; i < count2; ++i) {
435 ImageView *w = ImageView::create("cocosui/scrollviewbg.png");
436 w->setAnchorPoint(Vec2(0,1));
437 w->setScaleX(2.0);
438 w->setTouchEnabled(true);
439 w->setTag(i+count1+count2);
440 w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout2::onImageViewClicked, this));
441 vbox->addChild(w);
442 }
443
444 HBox *innerHBox = HBox::create();
445 vbox->addChild(innerHBox);
446 innerHBox->setTag(102);
447 // innerVBox->setPassFocusToChild(false);
448 // innerVBox->setFocusEnabled(false);
449
450
451 int count3 = 2;
452 for (int i=0; i<count3; ++i) {
453 ImageView *w = ImageView::create("cocosui/scrollviewbg.png");
454 w->setTouchEnabled(true);
455 w->setTag(i+count1+count2+count3);
456 w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout2::onImageViewClicked, this));
457 innerHBox->addChild(w);
458 }
459
460 _loopText = Text::create("loop enabled", "Arial", 20);
461 _loopText->setPosition(Vec2(winSize.width/2, winSize.height - 50));
462 _loopText->setColor(Color3B::GREEN);
463 this->addChild(_loopText);
464
465 _toggleButton->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout2::toggleFocusLoop, this));
466
467 return true;
468 }
469 return false;
470}
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
void toggleFocusLoop(cocos2d::Ref *, cocos2d::ui::Widget::TouchEventType)
cocos2d::ui::Layout * _horizontalLayout
Definition: UIFocusTest.h:124
cocos2d::ui::Text * _loopText
Definition: UIFocusTest.h:125
cocos2d::Layer * _uiLayer
Definition: UIScene.h:44

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

+ 函数调用图:

◆ toggleFocusLoop()

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

在文件 UIFocusTest.cpp473 行定义.

474{
475 if (type == Widget::TouchEventType::ENDED) {
476 _horizontalLayout->setLoopFocus(!_horizontalLayout->isLoopFocus());
477 if (_horizontalLayout->isLoopFocus()) {
478 _loopText->setString("loop enabled");
479 }else{
480 _loopText->setString("loop disabled");
481 }
482 }
483}

引用了 _horizontalLayout , 以及 _loopText.

被这些函数引用 init().

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

类成员变量说明

◆ _horizontalLayout

cocos2d::ui::Layout* UIFocusTestNestedLayout2::_horizontalLayout
protected

在文件 UIFocusTest.h124 行定义.

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

◆ _loopText

cocos2d::ui::Text* UIFocusTestNestedLayout2::_loopText
protected

在文件 UIFocusTest.h125 行定义.

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


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