PuzzleSDK
LabelAlignmentTest类 参考

#include <LabelTestNew.h>

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

Public 成员函数

 CREATE_FUNC (LabelAlignmentTest)
 
 LabelAlignmentTest ()
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
- 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
 

Private 成员函数

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)
 

Private 属性

cocos2d::Label * _label
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 LabelTestNew.h433 行定义.

构造及析构函数说明

◆ LabelAlignmentTest()

LabelAlignmentTest::LabelAlignmentTest ( )

在文件 LabelTestNew.cpp1620 行定义.

1621{
1622 auto blockSize = Size(200, 160);
1623 auto s = Director::getInstance()->getWinSize();
1624
1625 auto pos = Vec2((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2);
1626 auto colorLayer = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height);
1627 colorLayer->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
1628 colorLayer->setPosition(pos);
1629
1630 this->addChild(colorLayer);
1631
1632 MenuItemFont::setFontSize(30);
1633 auto menu = Menu::create(
1634 MenuItemFont::create("Left", CC_CALLBACK_1(LabelAlignmentTest::setAlignmentLeft, this)),
1635 MenuItemFont::create("Center", CC_CALLBACK_1(LabelAlignmentTest::setAlignmentCenter, this)),
1636 MenuItemFont::create("Right", CC_CALLBACK_1(LabelAlignmentTest::setAlignmentRight, this)),
1637 nullptr);
1638 menu->alignItemsVerticallyWithPadding(4);
1639 menu->setPosition(Vec2(50.0f, s.height / 2 - 20));
1640 this->addChild(menu);
1641
1642 menu = Menu::create(
1643 MenuItemFont::create("Top", CC_CALLBACK_1(LabelAlignmentTest::setAlignmentTop, this)),
1644 MenuItemFont::create("Middle", CC_CALLBACK_1(LabelAlignmentTest::setAlignmentMiddle, this)),
1645 MenuItemFont::create("Bottom", CC_CALLBACK_1(LabelAlignmentTest::setAlignmentBottom, this)),
1646 nullptr);
1647 menu->alignItemsVerticallyWithPadding(4);
1648 menu->setPosition(Vec2(s.width - 50, s.height / 2 - 20));
1649 this->addChild(menu);
1650
1651 TTFConfig ttfConfig("fonts/arial.ttf", 50);
1652 _label = Label::createWithTTF(ttfConfig, "abc efg hijk lmn opq rst uvw xyz");
1653 _label->setDimensions(200, 160);
1654 _label->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
1655 _label->setPosition(pos);
1656 addChild(_label);
1657}
void setAlignmentTop(cocos2d::Ref *sender)
void setAlignmentRight(cocos2d::Ref *sender)
cocos2d::Label * _label
Definition: LabelTestNew.h:449
void setAlignmentLeft(cocos2d::Ref *sender)
void setAlignmentCenter(cocos2d::Ref *sender)
void setAlignmentMiddle(cocos2d::Ref *sender)
void setAlignmentBottom(cocos2d::Ref *sender)

引用了 _label, setAlignmentBottom(), setAlignmentCenter(), setAlignmentLeft(), setAlignmentMiddle(), setAlignmentRight() , 以及 setAlignmentTop().

+ 函数调用图:

成员函数说明

◆ CREATE_FUNC()

LabelAlignmentTest::CREATE_FUNC ( LabelAlignmentTest  )

◆ setAlignmentBottom()

void LabelAlignmentTest::setAlignmentBottom ( cocos2d::Ref *  sender)
private

在文件 LabelTestNew.cpp1684 行定义.

1685{
1686 _label->setVerticalAlignment(TextVAlignment::BOTTOM);
1687}

引用了 _label.

被这些函数引用 LabelAlignmentTest().

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

◆ setAlignmentCenter()

void LabelAlignmentTest::setAlignmentCenter ( cocos2d::Ref *  sender)
private

在文件 LabelTestNew.cpp1664 行定义.

1665{
1666 _label->setHorizontalAlignment(TextHAlignment::CENTER);
1667}

引用了 _label.

被这些函数引用 LabelAlignmentTest().

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

◆ setAlignmentLeft()

void LabelAlignmentTest::setAlignmentLeft ( cocos2d::Ref *  sender)
private

在文件 LabelTestNew.cpp1659 行定义.

1660{
1661 _label->setHorizontalAlignment(TextHAlignment::LEFT);
1662}

引用了 _label.

被这些函数引用 LabelAlignmentTest().

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

◆ setAlignmentMiddle()

void LabelAlignmentTest::setAlignmentMiddle ( cocos2d::Ref *  sender)
private

在文件 LabelTestNew.cpp1679 行定义.

1680{
1681 _label->setVerticalAlignment(TextVAlignment::CENTER);
1682}

引用了 _label.

被这些函数引用 LabelAlignmentTest().

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

◆ setAlignmentRight()

void LabelAlignmentTest::setAlignmentRight ( cocos2d::Ref *  sender)
private

在文件 LabelTestNew.cpp1669 行定义.

1670{
1671 _label->setHorizontalAlignment(TextHAlignment::RIGHT);
1672}

引用了 _label.

被这些函数引用 LabelAlignmentTest().

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

◆ setAlignmentTop()

void LabelAlignmentTest::setAlignmentTop ( cocos2d::Ref *  sender)
private

在文件 LabelTestNew.cpp1674 行定义.

1675{
1676 _label->setVerticalAlignment(TextVAlignment::TOP);
1677}

引用了 _label.

被这些函数引用 LabelAlignmentTest().

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

◆ subtitle()

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

重载 TestCase .

在文件 LabelTestNew.cpp1694 行定义.

1695{
1696 return "Test text alignment";
1697}

◆ title()

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

重载 TestCase .

在文件 LabelTestNew.cpp1689 行定义.

1690{
1691 return "Testing New Label";
1692}

类成员变量说明

◆ _label

cocos2d::Label* LabelAlignmentTest::_label
private

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