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

Method initToggleLabelTypeOption

tests/cpp-tests/Source/LabelTest/LabelTest.cpp:2632–2667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2630}
2631
2632void LabelLayoutBaseTest::initToggleLabelTypeOption(const ax::Size& size)
2633{
2634 auto label = Label::createWithSystemFont("Toggle Label Type:", "Arial", 10);
2635 label->setColor(Color3B::WHITE);
2636 label->setPosition(Vec2(size.width * 0.8f + 15, size.height * 0.8f));
2637 this->addChild(label);
2638
2639 CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png", "cocosui/check_box_normal_press.png",
2640 "cocosui/check_box_active.png", "cocosui/check_box_normal_disable.png",
2641 "cocosui/check_box_active_disable.png");
2642 checkBox->setPosition(Vec2(size.width * 0.8f + 70, size.height * 0.8f));
2643 checkBox->setScale(0.5);
2644 checkBox->setName("toggleType");
2645 checkBox->setSelected(true);
2646
2647 auto stepper = (ControlStepper*)this->getChildByName("stepper");
2648
2649 checkBox->addEventListener([this, stepper](Object* /*sender*/, CheckBox::EventType event) {
2650 float fontSize = stepper->getValue();
2651
2652 if (event == CheckBox::EventType::SELECTED)
2653 {
2654 _labelType = 0;
2655 auto ttfConfig = _label->getTTFConfig();
2656 ttfConfig.fontSize = fontSize;
2657 _label->setTTFConfig(ttfConfig);
2658 }
2659 else
2660 {
2661 _labelType = 1;
2662 _label->setBMFontFilePath("fonts/enligsh-chinese.fnt");
2663 _label->setBMFontSize(fontSize);
2664 }
2665 });
2666 this->addChild(checkBox);
2667}
2668
2669void LabelLayoutBaseTest::initAlignmentOption(const ax::Size& size)
2670{

Callers 1

LabelLayoutBaseTestMethod · 0.95

Calls 14

createFunction · 0.85
setTTFConfigMethod · 0.80
setBMFontSizeMethod · 0.80
Vec2Function · 0.50
setColorMethod · 0.45
setPositionMethod · 0.45
addChildMethod · 0.45
setScaleMethod · 0.45
setNameMethod · 0.45
setSelectedMethod · 0.45
getChildByNameMethod · 0.45
addEventListenerMethod · 0.45

Tested by

no test coverage detected