PuzzleSDK
LabelToggleTypeTest类 参考

#include <LabelTestNew.h>

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

Public 成员函数

 CREATE_FUNC (LabelToggleTypeTest)
 
 LabelToggleTypeTest ()
 
void initToggleCheckboxes ()
 
void onChangedRadioButtonSelect (cocos2d::ui::RadioButton *radioButton, cocos2d::ui::RadioButton::EventType type)
 
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.h775 行定义.

构造及析构函数说明

◆ LabelToggleTypeTest()

LabelToggleTypeTest::LabelToggleTypeTest ( )

在文件 LabelTestNew.cpp2674 行定义.

2675{
2676 _label->setLineSpacing(5);
2677 _label->setAdditionalKerning(2);
2678 _label->setVerticalAlignment(TextVAlignment::CENTER);
2679 _label->setOverflow(Label::Overflow::NONE);
2680
2681
2682 this->updateDrawNodeSize(_label->getContentSize());
2683
2684 auto slider1 = (ui::Slider*)this->getChildByTag(1);
2685
2686 auto slider2 = (ui::Slider*)this->getChildByTag(2);
2687 slider2->setVisible(false);
2688
2689 auto winSize = Director::getInstance()->getVisibleSize();
2690 slider1->addEventListener([=](Ref* ref, Slider::EventType event){
2691 float percent = slider1->getPercent();
2692 auto drawNodeSize = Size(percent / 100.0 * winSize.width,_label->getContentSize().height);
2693 if(drawNodeSize.height <= 0){
2694 drawNodeSize.height = 0.1f;
2695 }
2696 _label->setDimensions(drawNodeSize.width, drawNodeSize.height);
2697 this->updateDrawNodeSize(drawNodeSize);
2698 });
2699
2700 auto stepper = (ControlStepper*)this->getChildByName("stepper");
2701 stepper->setValue(12);
2702
2703 auto label = Label::createWithSystemFont("Char Line break:", "Arial", 10);
2704 label->setColor(Color3B::WHITE);
2705 label->setPosition(Vec2(winSize.width * 0.1f, winSize.height * 0.8f));
2706 this->addChild(label);
2707
2708 CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png",
2709 "cocosui/check_box_normal_press.png",
2710 "cocosui/check_box_active.png",
2711 "cocosui/check_box_normal_disable.png",
2712 "cocosui/check_box_active_disable.png");
2713 checkBox->setPosition(Vec2(winSize.width * 0.2f , winSize.height * 0.8f));
2714 checkBox->setScale(0.5);
2715 checkBox->setSelected(false);
2716 checkBox->setName("LineBreak");
2717
2718 checkBox->addEventListener([=](Ref* ref, CheckBox::EventType event){
2719 if (event == CheckBox::EventType::SELECTED) {
2720 _label->setLineBreakWithoutSpace(true);
2721 }else{
2722 _label->setLineBreakWithoutSpace(false);
2723 }
2724 this->updateDrawNodeSize(_label->getContentSize());
2725 });
2726 this->addChild(checkBox);
2727
2728 this->initToggleCheckboxes();
2729}
void updateDrawNodeSize(const cocos2d::Size &drawNodeSize)
cocos2d::Label * _label
Definition: LabelTestNew.h:705

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

+ 函数调用图:

成员函数说明

◆ CREATE_FUNC()

LabelToggleTypeTest::CREATE_FUNC ( LabelToggleTypeTest  )

◆ initToggleCheckboxes()

void LabelToggleTypeTest::initToggleCheckboxes ( )

在文件 LabelTestNew.cpp2731 行定义.

2732{
2733 const float BUTTON_WIDTH = 100;
2734 float startPosX = 0;
2735 Size winSize = Director::getInstance()->getVisibleSize();
2736
2737 // Create a radio button group
2738 auto radioButtonGroup = RadioButtonGroup::create();
2739 this->addChild(radioButtonGroup);
2740
2741 // Create the radio buttons
2742 static const int NUMBER_OF_BUTTONS = 4;
2743 startPosX = winSize.width / 2.0f - (NUMBER_OF_BUTTONS - 1 ) * 0.5 * BUTTON_WIDTH - 30;
2744 std::vector<std::string> labelTypes = {"Normal", "Clamp", "Shrink", "RESIZE"};
2745
2746 for(int i = 0; i < NUMBER_OF_BUTTONS; ++i)
2747 {
2748
2749 RadioButton* radioButton = RadioButton::create("cocosui/radio_button_off.png", "cocosui/radio_button_on.png");
2750 float posX = startPosX + BUTTON_WIDTH * i;
2751 radioButton->setPosition(Vec2(posX, winSize.height / 2.0f + 70));
2752 radioButton->setScale(1.2f);
2753 radioButton->addEventListener(CC_CALLBACK_2(LabelToggleTypeTest::onChangedRadioButtonSelect, this));
2754 radioButton->setTag(i);
2755 radioButtonGroup->addRadioButton(radioButton);
2756 this->addChild(radioButton);
2757
2758 auto label = Label::createWithSystemFont(labelTypes.at(i), "Arial", 20);
2759 label->setPosition(radioButton->getPosition() + Vec2(50.0f,0.0f));
2760 this->addChild(label);
2761 }
2762}
static float startPosX
static const float BUTTON_WIDTH
void onChangedRadioButtonSelect(cocos2d::ui::RadioButton *radioButton, cocos2d::ui::RadioButton::EventType type)

引用了 BUTTON_WIDTH, onChangedRadioButtonSelect() , 以及 startPosX.

被这些函数引用 LabelToggleTypeTest().

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

◆ onChangedRadioButtonSelect()

void LabelToggleTypeTest::onChangedRadioButtonSelect ( cocos2d::ui::RadioButton *  radioButton,
cocos2d::ui::RadioButton::EventType  type 
)

在文件 LabelTestNew.cpp2775 行定义.

2776{
2777 if(radioButton == nullptr)
2778 {
2779 return;
2780 }
2781
2782 switch (type)
2783 {
2784 case RadioButton::EventType::SELECTED:
2785 {
2786 switch (radioButton->getTag()) {
2787 case 0:
2788 _label->setOverflow(Label::Overflow::NONE);
2789 break;
2790 case 1:
2791 _label->setOverflow(Label::Overflow::CLAMP);
2792 break;
2793 case 2:
2794 _label->setOverflow(Label::Overflow::SHRINK);
2795 break;
2796 case 3:
2797 _label->setOverflow(Label::Overflow::RESIZE_HEIGHT);
2798 break;
2799 default:
2800 break;
2801 }
2802 break;
2803 }
2804 default:
2805 break;
2806 }
2807 auto checkbox = (CheckBox*)(this->getChildByName("toggleWrap"));
2808 checkbox->setSelected(_label->isWrapEnabled());
2809 this->updateDrawNodeSize(_label->getContentSize());
2810}

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

被这些函数引用 initToggleCheckboxes().

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

◆ subtitle()

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

重载 TestCase .

在文件 LabelTestNew.cpp2769 行定义.

2770{
2771 return "";
2772}

◆ title()

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

重载 TestCase .

在文件 LabelTestNew.cpp2764 行定义.

2765{
2766 return "Toggle Label Type Test";
2767}

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