PuzzleSDK
UIFocusTestNestedLayout3类 参考

#include <UIFocusTest.h>

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

Public 成员函数

 CREATE_FUNC (UIFocusTestNestedLayout3)
 
 UIFocusTestNestedLayout3 ()
 
virtual ~UIFocusTestNestedLayout3 ()
 
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.h128 行定义.

构造及析构函数说明

◆ UIFocusTestNestedLayout3()

UIFocusTestNestedLayout3::UIFocusTestNestedLayout3 ( )

在文件 UIFocusTest.cpp486 行定义.

487{
488
489}

◆ ~UIFocusTestNestedLayout3()

UIFocusTestNestedLayout3::~UIFocusTestNestedLayout3 ( )
virtual

在文件 UIFocusTest.cpp491 行定义.

492{
493
494}

成员函数说明

◆ CREATE_FUNC()

UIFocusTestNestedLayout3::CREATE_FUNC ( UIFocusTestNestedLayout3  )

◆ init()

bool UIFocusTestNestedLayout3::init ( )
overridevirtual

重载 UIFocusTestBase .

在文件 UIFocusTest.cpp496 行定义.

497{
498 if (UIFocusTestBase::init()) {
499
500 Size winSize = Director::getInstance()->getVisibleSize();
501
502 _verticalLayout = VBox::create();
503 _verticalLayout->setPosition(Vec2(40.0f, winSize.height - 70));
504 _uiLayer->addChild(_verticalLayout);
505 _verticalLayout->setScale(0.8f);
506
507 _verticalLayout->setFocused(true);
508 _verticalLayout->setLoopFocus(true);
509 _verticalLayout->setTag(-1000);
511
512
513 HBox *upperHBox = HBox::create();
514 upperHBox->setTag(-200);
515 _verticalLayout->addChild(upperHBox);
516
517 LinearLayoutParameter *params = LinearLayoutParameter::create();
518 params->setMargin(Margin(0.0f,0.0f,50.0f,0.0f));
519
520 LinearLayoutParameter *vparams = LinearLayoutParameter::create();
521 vparams->setMargin(Margin(10.0f, 0.0f, 0.0f, 140.0f));
522 upperHBox->setLayoutParameter(vparams);
523
524 int count = 3;
525 for (int i=0; i<count; ++i) {
526 VBox *firstVbox = VBox::create();
527 firstVbox->setScale(0.5);
528 firstVbox->setLayoutParameter(params);
529 firstVbox->setTag((i+1) * 100);
530
531 int count1 = 3;
532 for (int j=0; j<count1; ++j) {
533 ImageView *w = ImageView::create("cocosui/scrollviewbg.png");
534 w->setTouchEnabled(true);
535 w->setTag(j+firstVbox->getTag()+1);
536 w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestBase::onImageViewClicked, this));
537 firstVbox->addChild(w);
538 }
539
540 upperHBox->addChild(firstVbox);
541
542 }
543
544 HBox *bottomHBox = HBox::create();
545 bottomHBox->setScale(0.5);
546 bottomHBox->setTag(600);
547
548 bottomHBox->setLayoutParameter(vparams);
549 count = 3;
550 LinearLayoutParameter *bottomParams = LinearLayoutParameter::create();
551 bottomParams->setMargin(Margin(0.0f, 0.0f, 8.0f, 0.0f));
552 for (int i=0; i < count; ++i) {
553 ImageView *w = ImageView::create("cocosui/scrollviewbg.png");
554 w->setLayoutParameter(bottomParams);
555 w->setTouchEnabled(true);
556 w->setTag(i+601);
557 w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestBase::onImageViewClicked, this));
558 bottomHBox->addChild(w);
559 }
560 _verticalLayout->addChild(bottomHBox);
561
562
563
564 _loopText = Text::create("loop enabled", "Arial", 20);
565 _loopText->setPosition(Vec2(winSize.width/2, winSize.height - 50));
566 _loopText->setColor(Color3B::GREEN);
567 this->addChild(_loopText);
568
569 _toggleButton->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout3::toggleFocusLoop, this));
570
571 return true;
572 }
573 return false;
574}
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 * _verticalLayout
Definition: UIFocusTest.h:140
cocos2d::ui::Text * _loopText
Definition: UIFocusTest.h:141
cocos2d::Layer * _uiLayer
Definition: UIScene.h:44

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

+ 函数调用图:

◆ toggleFocusLoop()

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

在文件 UIFocusTest.cpp577 行定义.

578{
579 if (type == Widget::TouchEventType::ENDED) {
580 _verticalLayout->setLoopFocus(!_verticalLayout->isLoopFocus());
581 if (_verticalLayout->isLoopFocus()) {
582 _loopText->setString("loop enabled");
583 }else{
584 _loopText->setString("loop disabled");
585 }
586 }
587}

引用了 _loopText , 以及 _verticalLayout.

被这些函数引用 init().

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

类成员变量说明

◆ _loopText

cocos2d::ui::Text* UIFocusTestNestedLayout3::_loopText
protected

在文件 UIFocusTest.h141 行定义.

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

◆ _verticalLayout

cocos2d::ui::Layout* UIFocusTestNestedLayout3::_verticalLayout
protected

在文件 UIFocusTest.h140 行定义.

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


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