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

Method initToggleCheckboxes

tests/cpp-tests/Source/LabelTest/LabelTest.cpp:1514–1544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1512 return slider2;
1513}
1514void LabelTTFSDF::initToggleCheckboxes()
1515{
1516 float startPosY = 0;
1517 Size winSize = Director::getInstance()->getVisibleSize();
1518
1519 // Create a radio button group
1520 auto radioButtonGroup = RadioButtonGroup::create();
1521 this->addChild(radioButtonGroup);
1522
1523 // Create the radio buttons
1524 static const int NUMBER_OF_BUTTONS = 3;
1525 startPosY = winSize.height * 0.25;
1526 std::vector<std::string> labelTypes = {"Normal", "Glow", "Outline"};
1527
1528 for (int i = 0; i < NUMBER_OF_BUTTONS; ++i)
1529 {
1530
1531 RadioButton* radioButton = RadioButton::create("cocosui/radio_button_off.png", "cocosui/radio_button_on.png");
1532 float posY = startPosY + (radioButton->getContentSize().height + 5) * i;
1533 radioButton->setPosition(Vec2(winSize.width * 0.8, posY));
1534 radioButton->addEventListener(AX_CALLBACK_2(LabelTTFSDF::onChangedRadioButtonSelect, this));
1535 radioButton->setTag(i);
1536 radioButtonGroup->addRadioButton(radioButton);
1537 this->addChild(radioButton);
1538
1539 auto label = Label::createWithSystemFont(labelTypes.at(i), "Arial", 15);
1540 label->setPosition(radioButton->getPosition() + Vec2(radioButton->getContentSize().width + 1, 0.0f));
1541 label->setAnchorPoint(Vec2(0, 0.5));
1542 this->addChild(label);
1543 }
1544}
1545void LabelTTFSDF::onChangedRadioButtonSelect(RadioButton* radioButton, RadioButton::EventType type)
1546{
1547 if (radioButton == nullptr)

Callers 2

LabelToggleTypeTestMethod · 0.80
LabelSystemFontTestMethod · 0.80

Calls 14

getInstanceFunction · 0.85
createFunction · 0.85
setTagMethod · 0.80
Vec2Function · 0.50
getVisibleSizeMethod · 0.45
addChildMethod · 0.45
getContentSizeMethod · 0.45
setPositionMethod · 0.45
addEventListenerMethod · 0.45
addRadioButtonMethod · 0.45
atMethod · 0.45
getPositionMethod · 0.45

Tested by

no test coverage detected