MCPcopy Create free account
hub / github.com/axmolengine/axmol / LabelUnderline

Method LabelUnderline

tests/cpp-tests/Source/LabelTest/LabelTest.cpp:3549–3587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3547///
3548
3549LabelUnderline::LabelUnderline()
3550{
3551 auto s = Director::getInstance()->getWinSize();
3552
3553 // LabelBMFont
3554 auto label1 =
3555 Label::createWithBMFont("fonts/bitmapFontTest2.fnt", "hello non-underline", TextHAlignment::CENTER, s.width);
3556 addChild(label1, 0, kTagBitmapAtlas1);
3557 label1->setPosition(Vec2(s.width / 2, s.height * 4 / 6));
3558 // you can enable italics by calling this method
3559
3560 _label1a = Label::createWithBMFont("fonts/bitmapFontTest2.fnt", "hello underline", TextHAlignment::CENTER, s.width);
3561 addChild(_label1a, 0, kTagBitmapAtlas1);
3562 _label1a->setPosition(Vec2(s.width / 2, s.height * 3 / 6));
3563 // you can enable underline by calling this method
3564 _label1a->enableUnderline();
3565
3566 // LabelTTF
3567 TTFConfig ttfConfig("fonts/arial.ttf", 24);
3568 auto label2 = Label::createWithTTF(ttfConfig, "hello non-underline", TextHAlignment::CENTER, s.width);
3569 addChild(label2, 0, kTagBitmapAtlas2);
3570 label2->setPosition(Vec2(s.width / 2, s.height * 2 / 6));
3571
3572 // or by setting the italics parameter on TTFConfig
3573 ttfConfig.underline = true;
3574 _label2a = Label::createWithTTF(ttfConfig, "hello underline", TextHAlignment::CENTER, s.width);
3575 addChild(_label2a, 0, kTagBitmapAtlas2);
3576 _label2a->setPosition(Vec2(s.width / 2, s.height * 1 / 6));
3577
3578 auto menuItem = MenuItemFont::create("disable underline", [&](ax::Object* sender) {
3579 _label2a->disableEffect(LabelEffect::UNDERLINE);
3580 _label1a->disableEffect(LabelEffect::UNDERLINE);
3581 });
3582 menuItem->setFontSizeObj(12);
3583 auto menu = Menu::createWithItem(menuItem);
3584 addChild(menu);
3585 auto winSize = Director::getInstance()->getWinSize();
3586 menu->setPosition(winSize.width * 0.9, winSize.height * 0.25f);
3587}
3588
3589std::string LabelUnderline::title() const
3590{

Callers

nothing calls this directly

Calls 7

getInstanceFunction · 0.85
createFunction · 0.85
enableUnderlineMethod · 0.80
setFontSizeObjMethod · 0.80
Vec2Function · 0.50
setPositionMethod · 0.45
disableEffectMethod · 0.45

Tested by

no test coverage detected