void TDDSwitchTest::subTest(Ref *sender) { log("this is a sample subTest"); TDDSwitch *switchControl = new TDDSwitch(Size(150, 40), Color4B::BLUE, Color4B::WHITE); switchControl->setPosition(Point(100, 50)); addChild(switchControl); }
void TDDSwitchTest::testSetSwitches(Ref *sender) { log("testSetSwitches"); TDDSwitch *switchControl = new TDDSwitch(Size(150, 40), Color4B::WHITE, Color4B::BLUE); switchControl->setPosition(Point(100, 50)); addChild(switchControl); std::vector<std::string> switches; switches.push_back("all"); switches.push_back("history"); switchControl->setSwitches(switches, CC_CALLBACK_3(TDDSwitchTest::switchSelected, this)); }
void TDDSwitchTest::testThreeSwitch(Ref *sender) { log("testSetSwitches"); TDDSwitch *switchControl = new TDDSwitch(Size(200, 50), Color4B::WHITE, Color4B::BLUE, Color3B::GRAY, Color3B::YELLOW, "GillSans", 16); switchControl->setPosition(Point(10, 150)); addChild(switchControl); std::vector<std::string> switches; switches.push_back("all"); switches.push_back("history"); switches.push_back("top"); switchControl->setSwitches(switches, CC_CALLBACK_3(TDDSwitchTest::switchSelected, this)); }
// Tool bar constains the following elements // Back button // Filter Input // Switch // Layout: | BACK | INPUT .... SWITCH | // 800 or 480 // Landscape: | 80 // Portrait: | 80 | 80 | ... 120 | 400 - 120 = 280 - Layer *TDDSuiteLayer::createToolBarLayer() { float scale = TDDHelper::getBestScale(); // bool isLandscape = TDDHelper::isLandscape(); Size screenSize = TDDHelper::getScreenSize(); int midY = kToolBarHeight/2; int buttonW = (int)(scale * 90); int inputW = (int)(scale * 200); int switchW = (int)(scale * 130); int backX = buttonW/2; int inputH = kToolBarHeight - 10; int inputX = inputW / 2 + buttonW; int clearX = buttonW + buttonW/2; int switchY = 5; int switchX = screenSize.width - switchW - 10; int switchH = kToolBarHeight - switchY * 2; // Layer containter LayerColor *menuLayer = LayerColor::create(kColorToolBar, screenSize.width, kToolBarHeight); // Back Button Menu *menuBack = TDDHelper::createMenu(Point(backX, midY), "Back", CC_CALLBACK_1(TDDSuiteLayer::goBack, this)); menuLayer->addChild(menuBack); // Clear History button Menu *menuClear = TDDHelper::createMenu(Point(clearX, midY), "Clear", CC_CALLBACK_1(TDDSuiteLayer::clearHistory, this)); menuLayer->addChild(menuClear); mClearMenu = menuClear; mClearMenu->setVisible(false); // Filter Input mEditFilter = TDDHelper::createEditBox(menuLayer, Point(inputX, midY), Size(inputW, inputH)); mEditFilter->setText(TDDHelper::getFilter()); mEditFilter->setPlaceHolder("Testcase Filter"); mEditFilter->setDelegate(this); // Menu *menuFind = TDDHelper::createMenu(Point(findX, midY), "Find", // CC_CALLBACK_1(TDDSuiteLayer::filterTest, this)); // menuLayer->addChild(menuFind); // Switch TDDSwitch *switchControl = new TDDSwitch(Size(switchW, switchH), kColorSwitchBg, kColorSwitch, kColorSwitchOffText, kColorSwitchOnText, TDD_FONT_NAME, (int)(scale * TDD_FONT_SIZE2 )); switchControl->setPosition(Point(switchX, switchY)); menuLayer->addChild(switchControl); std::vector<std::string> switches; switches.push_back("all"); switches.push_back("history"); TDDMenuMode savedMode = TDDData::instance()->getMenuMode(); int index = 0; if(savedMode == TDDMenuModeHistory) { index = 1; } switchControl->setSwitches(switches, CC_CALLBACK_3(TDDSuiteLayer::switchSelected, this), index); return menuLayer; }