| 3010 | } |
| 3011 | |
| 3012 | LabelResizeTest::LabelResizeTest() |
| 3013 | { |
| 3014 | _label->setLineSpacing(5); |
| 3015 | _label->setAdditionalKerning(2); |
| 3016 | _label->setVerticalAlignment(TextVAlignment::TOP); |
| 3017 | _label->setOverflow(Label::Overflow::RESIZE_HEIGHT); |
| 3018 | |
| 3019 | this->updateDrawNodeSize(_label->getContentSize()); |
| 3020 | |
| 3021 | auto slider1 = (ui::Slider*)this->getChildByTag(1); |
| 3022 | |
| 3023 | auto slider2 = (ui::Slider*)this->getChildByTag(2); |
| 3024 | slider2->setVisible(false); |
| 3025 | |
| 3026 | auto winSize = Director::getInstance()->getVisibleSize(); |
| 3027 | slider1->addEventListener([this, slider1, winSize](Object* /*sender*/, Slider::EventType event) { |
| 3028 | float percent = slider1->getPercent(); |
| 3029 | auto drawNodeSize = Size(percent / 100.0 * winSize.width, _label->getContentSize().height); |
| 3030 | if (drawNodeSize.height <= 0) |
| 3031 | { |
| 3032 | drawNodeSize.height = 0.1f; |
| 3033 | } |
| 3034 | _label->setDimensions(drawNodeSize.width, drawNodeSize.height); |
| 3035 | this->updateDrawNodeSize(drawNodeSize); |
| 3036 | }); |
| 3037 | |
| 3038 | auto stepper = (ControlStepper*)this->getChildByName("stepper"); |
| 3039 | stepper->setValue(12); |
| 3040 | |
| 3041 | auto label = Label::createWithSystemFont("Char Line break:", "Arial", 10); |
| 3042 | label->setColor(Color3B::WHITE); |
| 3043 | label->setPosition(Vec2(winSize.width * 0.1f, winSize.height * 0.8f)); |
| 3044 | this->addChild(label); |
| 3045 | |
| 3046 | CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png", "cocosui/check_box_normal_press.png", |
| 3047 | "cocosui/check_box_active.png", "cocosui/check_box_normal_disable.png", |
| 3048 | "cocosui/check_box_active_disable.png"); |
| 3049 | checkBox->setPosition(Vec2(winSize.width * 0.2f, winSize.height * 0.8f)); |
| 3050 | checkBox->setScale(0.5); |
| 3051 | checkBox->setSelected(false); |
| 3052 | checkBox->setName("LineBreak"); |
| 3053 | |
| 3054 | checkBox->addEventListener([this](Object* /*sender*/, CheckBox::EventType event) { |
| 3055 | if (event == CheckBox::EventType::SELECTED) |
| 3056 | { |
| 3057 | _label->setLineBreakWithoutSpace(true); |
| 3058 | } |
| 3059 | else |
| 3060 | { |
| 3061 | _label->setLineBreakWithoutSpace(false); |
| 3062 | } |
| 3063 | this->updateDrawNodeSize(_label->getContentSize()); |
| 3064 | }); |
| 3065 | this->addChild(checkBox); |
| 3066 | } |
| 3067 | |
| 3068 | std::string LabelResizeTest::title() const |
| 3069 | { |
nothing calls this directly
no test coverage detected