void ShapeTextureSample::createAlignmentIndicators() { ci::TextBox labelText; labelText.text("Press letter grid to change Alignment:"); labelText.color(ci::Color(1, 1, 1)); labelText.size(85, ci::TextBox::GROW); TextBoxRef alignLabel = TextBox::create(labelText); alignLabel->setPosition(300, 15); addChild(alignLabel); mAlignIndicatorNames = { "O: NONE", "Q: TOP_LEFT", "A: CENTER_LEFT", "Z: BOTTOM_LEFT", "W: TOP_CENTER", "S: CENTER_CENTER", "X: BOTTOM_CENTER", "E: TOP_RIGHT", "D: CENTER_RIGHT", "C: BOTTOM_RIGHT" }; // Create a container to hold the indicators mAlignIndicatorContainer = NodeContainer::create(); addChild(mAlignIndicatorContainer); mAlignIndicatorContainer->setPosition(390, 10); // Create and add indicators to the container // Add them to a map to reference later for (int i = 0; i < mAlignIndicatorNames.size(); i++) { std::string indicatorText = mAlignIndicatorNames[i]; IndicatorRef indicator = Indicator::create(indicatorText); mAlignIndicatorContainer->addChild(indicator); if (i == 0) { indicator->setPosition((indicator->getWidth() * 3) + 20, i * (indicator->getHeight() + 5)); } else if (i < 4) { indicator->setPosition(0, (i-1) * (indicator->getHeight() + 5)); } else if (i < 7) { indicator->setPosition(indicator->getWidth(), (i-4) * (indicator->getHeight() + 5)); } else { indicator->setPosition((indicator->getWidth() * 2) + 20, (i-7) * (indicator->getHeight() + 5)); } mAlignIndicators[mAlignIndicatorNames[i]] = indicator; } }
void ViewController::createIndicators() { // Indicator names same as Alignment type names mIndicatorNames = { "NONE", "TOP_LEFT", "TOP_CENTER", "TOP_RIGHT", "CENTER_LEFT", "CENTER_CENTER", "CENTER_RIGHT", "BOTTOM_LEFT", "BOTTOM_CENTER", "BOTTOM_RIGHT" }; // Create a container to hold the indicators mIndicatorContainer = View::create(); getView()->addSubview(mIndicatorContainer); mIndicatorContainer->setPosition(10, 10); // Create and add indicators to the container // Add them to a map to reference later for (int i = 0; i < mIndicatorNames.size(); i++) { std::string indicatorText = std::to_string(i) + ": " + mIndicatorNames[i]; IndicatorRef indicator = Indicator::create(indicatorText); mIndicatorContainer->addSubview(indicator); if (i == 0) { indicator->setPosition(indicator->getWidth() * 3, i * (indicator->getHeight() + 5)); } else if (i < 4) { indicator->setPosition(0, (i - 1) * (indicator->getHeight() + 5)); } else if (i < 7) { indicator->setPosition(indicator->getWidth(), (i - 4) * (indicator->getHeight() + 5)); } else { indicator->setPosition(indicator->getWidth() * 2, (i - 7) * (indicator->getHeight() + 5)); } mIndicators[mIndicatorNames[i]] = indicator; } }