PuzzleSDK
UILayoutTest_Layout_Linear_Horizontal类 参考

#include <UILayoutTest.h>

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

Public 成员函数

 UILayoutTest_Layout_Linear_Horizontal ()
 
 ~UILayoutTest_Layout_Linear_Horizontal ()
 
virtual bool init () override
 
 CREATE_FUNC (UILayoutTest_Layout_Linear_Horizontal)
 
- 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
 

额外继承的成员函数

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

详细描述

在文件 UILayoutTest.h97 行定义.

构造及析构函数说明

◆ UILayoutTest_Layout_Linear_Horizontal()

UILayoutTest_Layout_Linear_Horizontal::UILayoutTest_Layout_Linear_Horizontal ( )

在文件 UILayoutTest.cpp453 行定义.

454{
455}

◆ ~UILayoutTest_Layout_Linear_Horizontal()

UILayoutTest_Layout_Linear_Horizontal::~UILayoutTest_Layout_Linear_Horizontal ( )

在文件 UILayoutTest.cpp457 行定义.

458{
459}

成员函数说明

◆ CREATE_FUNC()

UILayoutTest_Layout_Linear_Horizontal::CREATE_FUNC ( UILayoutTest_Layout_Linear_Horizontal  )

◆ init()

bool UILayoutTest_Layout_Linear_Horizontal::init ( )
overridevirtual

重载 UIScene .

在文件 UILayoutTest.cpp461 行定义.

462{
463 if (UIScene::init())
464 {
465 Size widgetSize = _widget->getContentSize();
466
467 // Add the alert
468 Text* alert = Text::create("Layout Linear Horizontal", "fonts/Marker Felt.ttf", 20);
469 alert->setColor(Color3B(159, 168, 176));
470 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 4.5f));
471 _uiLayer->addChild(alert);
472
473 Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
474
475 Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
476
477 // Create the layout
478 Layout* layout = Layout::create();
479 layout->setLayoutType(Layout::Type::HORIZONTAL);
480 layout->setClippingEnabled(true);
481 layout->setContentSize(Size(280, 150));
482 Size backgroundSize = background->getContentSize();
483 layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
484 (backgroundSize.width - layout->getContentSize().width) / 2.0f,
485 (widgetSize.height - backgroundSize.height) / 2.0f +
486 (backgroundSize.height - layout->getContentSize().height) / 2.0f));
487 _uiLayer->addChild(layout);
488
489 Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
490 layout->addChild(button);
491
492 LinearLayoutParameter* lp1 = LinearLayoutParameter::create();
493 button->setLayoutParameter(lp1);
494 lp1->setGravity(LinearLayoutParameter::LinearGravity::CENTER_VERTICAL);
495 lp1->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f));
496
497
498 Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
499 titleButton->setTitleText("Title Button");
500 layout->addChild(titleButton);
501
502 LinearLayoutParameter* lp2 = LinearLayoutParameter::create();
503 titleButton->setLayoutParameter(lp2);
504 lp2->setGravity(LinearLayoutParameter::LinearGravity::CENTER_VERTICAL);
505 lp2->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f));
506
507
508 Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
509 button_scale9->setScale9Enabled(true);
510 button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
511 layout->addChild(button_scale9);
512
513 LinearLayoutParameter* lp3 = LinearLayoutParameter::create();
514 button_scale9->setLayoutParameter(lp3);
515 lp3->setGravity(LinearLayoutParameter::LinearGravity::CENTER_VERTICAL);
516 lp3->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f));
517
518
519 return true;
520 }
521
522 return false;
523}
cocos2d::Layer * _uiLayer
Definition: UIScene.h:44
virtual bool init() override
Definition: UIScene.cpp:46
cocos2d::ui::Layout * _widget
Definition: UIScene.h:45

引用了 UIScene::_uiLayer, UIScene::_widget , 以及 UIScene::init().

+ 函数调用图:

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