| 1960 | } |
| 1961 | |
| 1962 | LabelAlignmentTest::LabelAlignmentTest() |
| 1963 | { |
| 1964 | auto blockSize = Size(200, 160); |
| 1965 | auto s = Director::getInstance()->getWinSize(); |
| 1966 | |
| 1967 | auto pos = Vec2((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2); |
| 1968 | auto colorLayer = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height); |
| 1969 | colorLayer->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); |
| 1970 | colorLayer->setPosition(pos); |
| 1971 | |
| 1972 | this->addChild(colorLayer); |
| 1973 | |
| 1974 | MenuItemFont::setFontSize(30); |
| 1975 | auto menu = Menu::create( |
| 1976 | MenuItemFont::create("Left", AX_CALLBACK_1(LabelAlignmentTest::setAlignmentLeft, this)), |
| 1977 | MenuItemFont::create("Center", AX_CALLBACK_1(LabelAlignmentTest::setAlignmentCenter, this)), |
| 1978 | MenuItemFont::create("Right", AX_CALLBACK_1(LabelAlignmentTest::setAlignmentRight, this)), nullptr); |
| 1979 | menu->alignItemsVerticallyWithPadding(4); |
| 1980 | menu->setPosition(Vec2(50.0f, s.height / 2 - 20)); |
| 1981 | this->addChild(menu); |
| 1982 | |
| 1983 | menu = Menu::create(MenuItemFont::create("Top", AX_CALLBACK_1(LabelAlignmentTest::setAlignmentTop, this)), |
| 1984 | MenuItemFont::create("Middle", AX_CALLBACK_1(LabelAlignmentTest::setAlignmentMiddle, this)), |
| 1985 | MenuItemFont::create("Bottom", AX_CALLBACK_1(LabelAlignmentTest::setAlignmentBottom, this)), |
| 1986 | nullptr); |
| 1987 | menu->alignItemsVerticallyWithPadding(4); |
| 1988 | menu->setPosition(Vec2(s.width - 50, s.height / 2 - 20)); |
| 1989 | this->addChild(menu); |
| 1990 | |
| 1991 | TTFConfig ttfConfig("fonts/arial.ttf", 50); |
| 1992 | _label = Label::createWithTTF(ttfConfig, "abc efg hijk lmn opq rst uvw xyz"); |
| 1993 | _label->setDimensions(200, 160); |
| 1994 | _label->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); |
| 1995 | _label->setPosition(pos); |
| 1996 | addChild(_label); |
| 1997 | } |
| 1998 | |
| 1999 | void LabelAlignmentTest::setAlignmentLeft(Object* sender) |
| 2000 | { |
nothing calls this directly
no test coverage detected