PuzzleSDK
UITextTest_IgnoreContentSize类 参考

#include <UITextTest.h>

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

Public 成员函数

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

详细描述

在文件 UITextTest.h67 行定义.

成员函数说明

◆ CREATE_FUNC()

UITextTest_IgnoreContentSize::CREATE_FUNC ( UITextTest_IgnoreContentSize  )

◆ init()

bool UITextTest_IgnoreContentSize::init ( )
overridevirtual

重载 UIScene .

在文件 UITextTest.cpp249 行定义.

250{
251 if (UIScene::init())
252 {
253 Size widgetSize = _widget->getContentSize();
254
255 Text* leftText = Text::create("ignore content",
256 "fonts/Marker Felt.ttf",10);
257 leftText->setPosition(Vec2(widgetSize.width / 2.0f - 50,
258 widgetSize.height / 2.0f));
259 leftText->ignoreContentAdaptWithSize(false);
260 leftText->setTextAreaSize(Size(60.0f,60.0f));
261 leftText->setString("Text line with break\nText line with break\nText line with break\nText line with break\n");
262 leftText->setTouchScaleChangeEnabled(true);
263 leftText->setTouchEnabled(true);
264 _uiLayer->addChild(leftText);
265
266
267 Text* rightText = Text::create("ignore content",
268 "fonts/Marker Felt.ttf",10);
269 rightText->setPosition(Vec2(widgetSize.width / 2.0f + 50,
270 widgetSize.height / 2.0f));
271 rightText->setString("Text line with break\nText line with break\nText line with break\nText line with break\n");
272 //note:setTextAreaSize must be used with ignoreContentAdaptWithSize(false)
273 rightText->setTextAreaSize(Size(100.0f,30.0f));
274 rightText->ignoreContentAdaptWithSize(false);
275 _uiLayer->addChild(rightText);
276
277
278 auto halighButton = Button::create();
279 halighButton->setTitleText("Alignment Right");
280 halighButton->addClickEventListener([=](Ref*){
281 leftText->setTextHorizontalAlignment(TextHAlignment::RIGHT);
282 rightText->setTextHorizontalAlignment(TextHAlignment::RIGHT);
283 });
284 halighButton->setPosition(Vec2(widgetSize.width/2 - 50,
285 widgetSize.height/2 - 50));
286 _uiLayer->addChild(halighButton);
287
288 return true;
289 }
290 return false;
291}
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().

+ 函数调用图:

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