QScriptValue UniversalInputDialogScript::add(const QScriptValue& def, const QScriptValue& description, const QScriptValue& id){ QWidget* w = 0; if (def.isArray()) { QStringList options; QScriptValueIterator it(def); while (it.hasNext()) { it.next(); if (it.flags() & QScriptValue::SkipInEnumeration) continue; if (it.value().isString() || it.value().isNumber()) options << it.value().toString(); else engine->currentContext()->throwError("Invalid default value in array (must be string or number): "+it.value().toString()); } w = addComboBox(ManagedProperty::fromValue(options), description.toString()); } else if (def.isBool()) { w = addCheckBox(ManagedProperty::fromValue(def.toBool()), description.toString()); } else if (def.isNumber()) { w = addDoubleSpinBox(ManagedProperty::fromValue(def.toNumber()), description.toString()); } else if (def.isString()) { w = addLineEdit(ManagedProperty::fromValue(def.toString()), description.toString()); } else { engine->currentContext()->throwError(tr("Invalid default value: %1").arg(def.toString())); return QScriptValue(); } if (id.isValid()) properties.last().name = id.toString(); return engine->newQObject(w); }
void ofxSimpleGuiToo::setup() { config = &defaultSimpleGuiConfig; doSave = false; changePage = false; titleButton = NULL; keyboardShortcutsEnabled = true; doDrawPageBoundary = false; headerPage = &addPage("Header"); headerPage->height = config->buttonHeight * 2; headerPage->width = 0; titleButton = &headerPage->addButton("title", changePage); headerPage->addToggle("Auto Save", doAutoSave); headerPage->addButton("Save Settings", doSave); headerPage->addFPSCounter(); cols = ceilf(ofGetWidth() / config->gridSize.x); rows = ceilf(ofGetHeight() / config->gridSize.y); addPage(); // default settings page addFPSCounter(); setAutoSave(true); setAlignRight(false); setDraw(false); //addToggle("", <#bool value#>) //addControl(*titleButton); page(1).addPageShortcut(addPage("Keyboard Shortcuts")); page(1).addPageShortcut(addPage("GUI")); //setPage("GUI"); addButton("save settings", doSave); addToggle("auto save", doAutoSave); //gui.addTitle("gui display"); gui.addTitle("controls"); string choices[] = {"simple","advanced","all"}; gui.addComboBox("display priority", ofxSimpleGuiPage::mainPriority, 3, choices); gui.addButton("collapse all", 't', this, &ofxSimpleGuiToo::closeAllTitles); gui.addButton("open all", 'T', this, &ofxSimpleGuiToo::openAllTitles); gui.addTitle("display mode"); string displayModeChoices[GUI_MODE_COUNT] = {"fixed","floating"}; addComboBox("display mode", displayMode, GUI_MODE_COUNT, displayModeChoices); gui.addTitle("floating parameters"); gui.addSlider("x", displayRect.x, 0, ofGetWidth()); gui.addSlider("y", displayRect.y, 0, ofGetHeight()); gui.addSlider("columns", cols, 1, 10); gui.addSlider("rows", rows, 5, 30); gui.addButton("reset", this, &ofxSimpleGuiToo::setDefaultDimensions); gui.addToggle("draw boundaries", doDrawPageBoundary); //gui.addSlider("gui width", displayRect.width, 256, ofGetWidth()); //gui.addSlider("gui height", displayRect.height, 256, ofGetHeight()); setPage(1); //addSlider("advanced gui", ofxSimpleGuiControl::mainPriority, 0, 2); ofAddListener(ofEvents.keyPressed, this, &ofxSimpleGuiToo::keyPressed); }