| 2630 | } |
| 2631 | |
| 2632 | void 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 | |
| 2669 | void LabelLayoutBaseTest::initAlignmentOption(const ax::Size& size) |
| 2670 | { |
no test coverage detected