PuzzleSDK
LabelResizeTest类 参考

#include <LabelTestNew.h>

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

Public 成员函数

 CREATE_FUNC (LabelResizeTest)
 
 LabelResizeTest ()
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
- Public 成员函数 继承自 LabelLayoutBaseTest
 LabelLayoutBaseTest ()
 
void updateDrawNodeSize (const cocos2d::Size &drawNodeSize)
 
cocos2d::extension::ControlStepper * makeControlStepper ()
 
void valueChanged (cocos2d::Ref *sender, cocos2d::extension::Control::EventType controlEvent)
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
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
 
virtual void onEnter () override
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 成员函数 继承自 LabelLayoutBaseTest
void setAlignmentLeft (cocos2d::Ref *sender)
 
void setAlignmentCenter (cocos2d::Ref *sender)
 
void setAlignmentRight (cocos2d::Ref *sender)
 
void setAlignmentTop (cocos2d::Ref *sender)
 
void setAlignmentMiddle (cocos2d::Ref *sender)
 
void setAlignmentBottom (cocos2d::Ref *sender)
 
void initWrapOption (const cocos2d::Size &size)
 
void initToggleLabelTypeOption (const cocos2d::Size &size)
 
void initAlignmentOption (const cocos2d::Size &size)
 
void initFontSizeChange (const cocos2d::Size &size)
 
void initSliders (const cocos2d::Size &size)
 
void initTestLabel (const cocos2d::Size &size)
 
void initDrawNode (const cocos2d::Size &size)
 
- Protected 属性 继承自 LabelLayoutBaseTest
cocos2d::DrawNode * _drawNode
 
cocos2d::Label * _label
 
int _labelType
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 LabelTestNew.h764 行定义.

构造及析构函数说明

◆ LabelResizeTest()

LabelResizeTest::LabelResizeTest ( )

在文件 LabelTestNew.cpp2608 行定义.

2609{
2610 _label->setLineSpacing(5);
2611 _label->setAdditionalKerning(2);
2612 _label->setVerticalAlignment(TextVAlignment::TOP);
2613 _label->setOverflow(Label::Overflow::RESIZE_HEIGHT);
2614
2615
2616 this->updateDrawNodeSize(_label->getContentSize());
2617
2618 auto slider1 = (ui::Slider*)this->getChildByTag(1);
2619
2620 auto slider2 = (ui::Slider*)this->getChildByTag(2);
2621 slider2->setVisible(false);
2622
2623 auto winSize = Director::getInstance()->getVisibleSize();
2624 slider1->addEventListener([=](Ref* ref, Slider::EventType event){
2625 float percent = slider1->getPercent();
2626 auto drawNodeSize = Size(percent / 100.0 * winSize.width,_label->getContentSize().height);
2627 if(drawNodeSize.height <= 0){
2628 drawNodeSize.height = 0.1f;
2629 }
2630 _label->setDimensions(drawNodeSize.width, drawNodeSize.height);
2631 this->updateDrawNodeSize(drawNodeSize);
2632 });
2633
2634 auto stepper = (ControlStepper*)this->getChildByName("stepper");
2635 stepper->setValue(12);
2636
2637 auto label = Label::createWithSystemFont("Char Line break:", "Arial", 10);
2638 label->setColor(Color3B::WHITE);
2639 label->setPosition(Vec2(winSize.width * 0.1f, winSize.height * 0.8f));
2640 this->addChild(label);
2641
2642 CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png",
2643 "cocosui/check_box_normal_press.png",
2644 "cocosui/check_box_active.png",
2645 "cocosui/check_box_normal_disable.png",
2646 "cocosui/check_box_active_disable.png");
2647 checkBox->setPosition(Vec2(winSize.width * 0.2f , winSize.height * 0.8f));
2648 checkBox->setScale(0.5);
2649 checkBox->setSelected(false);
2650 checkBox->setName("LineBreak");
2651
2652 checkBox->addEventListener([=](Ref* ref, CheckBox::EventType event){
2653 if (event == CheckBox::EventType::SELECTED) {
2654 _label->setLineBreakWithoutSpace(true);
2655 }else{
2656 _label->setLineBreakWithoutSpace(false);
2657 }
2658 this->updateDrawNodeSize(_label->getContentSize());
2659 });
2660 this->addChild(checkBox);
2661
2662}
void updateDrawNodeSize(const cocos2d::Size &drawNodeSize)
cocos2d::Label * _label
Definition: LabelTestNew.h:705

引用了 LabelLayoutBaseTest::_label , 以及 LabelLayoutBaseTest::updateDrawNodeSize().

+ 函数调用图:

成员函数说明

◆ CREATE_FUNC()

LabelResizeTest::CREATE_FUNC ( LabelResizeTest  )

◆ subtitle()

std::string LabelResizeTest::subtitle ( ) const
overridevirtual

重载 TestCase .

在文件 LabelTestNew.cpp2669 行定义.

2670{
2671 return "";
2672}

◆ title()

std::string LabelResizeTest::title ( ) const
overridevirtual

重载 TestCase .

在文件 LabelTestNew.cpp2664 行定义.

2665{
2666 return "Resize content Test";
2667}

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