| 3076 | } |
| 3077 | |
| 3078 | LabelToggleTypeTest::LabelToggleTypeTest() |
| 3079 | { |
| 3080 | _label->setLineSpacing(5); |
| 3081 | _label->setAdditionalKerning(2); |
| 3082 | _label->setVerticalAlignment(TextVAlignment::CENTER); |
| 3083 | _label->setOverflow(Label::Overflow::NONE); |
| 3084 | |
| 3085 | this->updateDrawNodeSize(_label->getContentSize()); |
| 3086 | |
| 3087 | auto slider1 = (ui::Slider*)this->getChildByTag(1); |
| 3088 | |
| 3089 | auto slider2 = (ui::Slider*)this->getChildByTag(2); |
| 3090 | slider2->setVisible(false); |
| 3091 | |
| 3092 | auto winSize = Director::getInstance()->getVisibleSize(); |
| 3093 | slider1->addEventListener([this, slider1, winSize](Object* /*sender*/, Slider::EventType event) { |
| 3094 | float percent = slider1->getPercent(); |
| 3095 | auto drawNodeSize = Size(percent / 100.0 * winSize.width, _label->getContentSize().height); |
| 3096 | if (drawNodeSize.height <= 0) |
| 3097 | { |
| 3098 | drawNodeSize.height = 0.1f; |
| 3099 | } |
| 3100 | _label->setDimensions(drawNodeSize.width, drawNodeSize.height); |
| 3101 | this->updateDrawNodeSize(drawNodeSize); |
| 3102 | }); |
| 3103 | |
| 3104 | auto stepper = (ControlStepper*)this->getChildByName("stepper"); |
| 3105 | stepper->setValue(12); |
| 3106 | |
| 3107 | auto label = Label::createWithSystemFont("Char Line break:", "Arial", 10); |
| 3108 | label->setColor(Color3B::WHITE); |
| 3109 | label->setPosition(Vec2(winSize.width * 0.1f, winSize.height * 0.8f)); |
| 3110 | this->addChild(label); |
| 3111 | |
| 3112 | CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png", "cocosui/check_box_normal_press.png", |
| 3113 | "cocosui/check_box_active.png", "cocosui/check_box_normal_disable.png", |
| 3114 | "cocosui/check_box_active_disable.png"); |
| 3115 | checkBox->setPosition(Vec2(winSize.width * 0.2f, winSize.height * 0.8f)); |
| 3116 | checkBox->setScale(0.5); |
| 3117 | checkBox->setSelected(false); |
| 3118 | checkBox->setName("LineBreak"); |
| 3119 | |
| 3120 | checkBox->addEventListener([this](Object* /*sender*/, CheckBox::EventType event) { |
| 3121 | if (event == CheckBox::EventType::SELECTED) |
| 3122 | { |
| 3123 | _label->setLineBreakWithoutSpace(true); |
| 3124 | } |
| 3125 | else |
| 3126 | { |
| 3127 | _label->setLineBreakWithoutSpace(false); |
| 3128 | } |
| 3129 | this->updateDrawNodeSize(_label->getContentSize()); |
| 3130 | }); |
| 3131 | this->addChild(checkBox); |
| 3132 | |
| 3133 | this->initToggleCheckboxes(); |
| 3134 | } |
| 3135 |
nothing calls this directly
no test coverage detected