void ofApp::guiEvent(ofxUIEventArgs &e) { string name = e.getName(); int kind = e.getKind(); cout << "got event from: " << name << endl; if(name == "RED") { ofxUISlider *slider = (ofxUISlider *) e.getSlider(); cout << "RED " << slider->getScaledValue() << endl; red = slider->getScaledValue(); } else if(name == "GREEN") { ofxUISlider *slider = (ofxUISlider *) e.getSlider(); cout << "GREEN " << slider->getScaledValue() << endl; green = slider->getScaledValue(); } else if(name == "BLUE") { ofxUISlider *slider = (ofxUISlider *) e.getSlider(); cout << "BLUE " << slider->getScaledValue() << endl; blue = slider->getScaledValue(); } else if(name == "BUTTON") { ofxUIButton *button = (ofxUIButton *) e.getButton(); bdrawGrid = button->getValue(); } else if(name == "TOGGLE") { ofxUIToggle *toggle = (ofxUIToggle *) e.getToggle(); bdrawGrid = toggle->getValue(); } else if(name == "TEXT INPUT") { ofxUITextInput *textinput = (ofxUITextInput *) e.widget; if(textinput->getTriggerType() == OFX_UI_TEXTINPUT_ON_ENTER) { cout << "ON ENTER: "; } else if(textinput->getTriggerType() == OFX_UI_TEXTINPUT_ON_FOCUS) { cout << "ON FOCUS: "; } else if(textinput->getTriggerType() == OFX_UI_TEXTINPUT_ON_UNFOCUS) { cout << "ON BLUR: "; } string output = textinput->getTextString(); cout << output << endl; } }
void testApp::guiEvent(ofxUIEventArgs &e) { string name = e.widget->getName(); if ( name == "PLAYHEAD" && videoPlayer.isPlaying() ) videoPlayer.setPosition( e.getSlider()->getValue() ); else if ( name == "MUTE" ) videoPlayer.setVolume( e.getToggle()->getValue() ? 0.0 : 1.0 ); else if ( name == "USE WEBCAM" ) { if ( e.getToggle()->getValue() ) { if ( videoSource != &videoGrabber ) { cout << "switching back to webcam" << endl; videoSource = &videoGrabber; vfx1.setVideoSource( videoSource ); videoPlayer.stop(); } } else { // if there is no video loaded, we stick with webcam if ( !videoPlayer.isLoaded() ) { cout << "no video loaded... sticking with webcam" << endl; e.getToggle()->setValue( true ); } else { // make sure the video player is still playing if ( !videoPlayer.isPlaying() ) videoPlayer.play(); videoSource = &videoPlayer; vfx1.setVideoSource( videoSource ); videoPlayer.play(); } } } }
//-------------------------------------------------------------- void AnimationWaves::guiEvent(ofxUIEventArgs &e) { Animation::guiEvent(e); string name = e.getName(); if (name == "nbWavePoints") { m_nbWavePoints = (int) e.getSlider()->getScaledValue(); updateNbPointsForWaves(); } }
//------------------------------------------------------------------------------------ //GUI STUFF void ofApp::guiEvent(ofxUIEventArgs &e) { string name = e.getName(); if(name == "Load Video"){ videoLoaded = false; ofxUIButton *button = (ofxUIButton *) e.getButton(); if (button->getValue()){ timeline.stop(); //pausePlayback = true; ofFileDialogResult result = ofSystemLoadDialog("Choose a Video File",false); if(result.bSuccess){ //need to clear old data //timeline.removeTrack("Video"); loadVideo(result.getPath(),result.getName()); } } } else if (name == "Toggle Min Movement"){ minMovementBool = e.getToggle()->getValue(); minMove->setVisible(minMovementBool); } else if (name == "Toggle Max Movement"){ maxMovementBool = e.getToggle()->getValue(); maxMove->setVisible(maxMovementBool); } else if(name == "Min Movement") { minMovementThresh = e.getSlider()->getValue(); } else if(name == "Max Movement") { maxMovementThresh = e.getSlider()->getValue(); } else if(name == "Length Range"){ if(loopLengthSlider->getState() != OFX_UI_STATE_DOWN){ timeline.stop(); minPeriod = (int)(fps*minPeriodSecs); maxPeriod = (int)(fps*maxPeriodSecs); } } }
void ofApp::guiEvent(ofxUIEventArgs &e) { string name = e.getName(); cout << "got event from: " << name << endl; if(name == "VAR") { ofxUISlider *sliderValue = (ofxUISlider *) e.getSlider(); ofxOscMessage m; m.setAddress("/var"); m.addFloatArg(sliderValue->getValue()); sender.sendMessage(m); } }
void testApp::guiEvent(ofxUIEventArgs &e) { if(e.getName() == "FULLSCREEN") { ofxUIToggle *toggle = e.getToggle(); ofSetFullscreen(toggle->getValue()); }else if(e.getName() == "Meditation_Level") { ofxUISlider *slider = e.getSlider(); meditationLevel = slider->getScaledValue(); }else if(e.getName() == "camera_distance"){ ofxUISlider *slider = e.getSlider(); camDistance = slider->getScaledValue(); }else if(e.getName() == "background_color"){ ofxUISlider *slider = e.getSlider(); ofBackground(slider->getScaledValue()); }else if(e.getName() == "Whole_Scene_Position_x"){ ofxUISlider *slider = e.getSlider(); whole_scene_x = slider->getScaledValue(); }else if(e.getName() == "Whole_Scene_Position_y"){ ofxUISlider *slider = e.getSlider(); whole_scene_y = slider->getScaledValue(); }else if(e.getName() == "Whole_Scene_Position_z"){ ofxUISlider *slider = e.getSlider(); whole_scene_z = slider->getScaledValue(); }else if(e.getName() == "Whole_Scene_Rotate_x"){ ofxUISlider *slider = e.getSlider(); scene_rx = slider->getScaledValue(); }else if(e.getName() == "Whole_Scene_Rotate_y"){ ofxUISlider *slider = e.getSlider(); scene_ry = slider->getScaledValue(); }else if(e.getName() == "Whole_Scene_Rotate_z"){ ofxUISlider *slider = e.getSlider(); scene_rz = slider->getScaledValue(); }else if(e.getName() == "particle_Size"){ ofxUISlider *slider = e.getSlider(); particleSize = slider->getScaledValue(); }else if(e.getName() == "PlaneX"){ ofxUISlider *slider = e.getSlider(); planeX = slider->getScaledValue(); }else if(e.getName() == "PlaneY"){ ofxUISlider *slider = e.getSlider(); planeY = slider->getScaledValue(); }else if(e.getName() == "PlaneZ"){ ofxUISlider *slider = e.getSlider(); planeZ = slider->getScaledValue(); }else if(e.getName() == "whole_scene_scale"){ ofxUISlider *slider = e.getSlider(); whole_scene_scale = slider->getScaledValue(); }else if(e.getName() == "tv_x"){ ofxUISlider *slider = e.getSlider(); tv_x = slider->getScaledValue(); }else if(e.getName() == "tv_y"){ ofxUISlider *slider = e.getSlider(); tv_y = slider->getScaledValue(); }else if(e.getName() == "tv_z"){ ofxUISlider *slider = e.getSlider(); tv_z = slider->getScaledValue(); }else if(e.getName() == "gif_x"){ ofxUISlider *slider = e.getSlider(); image_x = slider->getScaledValue(); }else if(e.getName() == "gif_y"){ ofxUISlider *slider = e.getSlider(); image_y = slider->getScaledValue(); }else if(e.getName() == "gif_z"){ ofxUISlider *slider = e.getSlider(); image_z = slider->getScaledValue(); }else if(e.getName() == "gif_scale"){ ofxUISlider *slider = e.getSlider(); image_scale = slider->getScaledValue(); } }
void Calibration::guiEvent(ofxUIEventArgs &e) { if(e.getName() == "ps3_gain") { ofxUIIntSlider *slider = (ofxUIIntSlider *) e.getSlider(); ps3eye.setGain(slider->getValue()); } else if(e.getName() == "ps3_brightness") { ofxUIIntSlider *slider = (ofxUIIntSlider *) e.getSlider(); ps3eye.setBrightness(slider->getValue()); } else if(e.getName() == "ps3_contrast") { ofxUIIntSlider *slider = (ofxUIIntSlider *) e.getSlider(); ps3eye.setContrast(slider->getValue()); } else if(e.getName() == "ps3_redbalance") { ofxUIIntSlider *slider = (ofxUIIntSlider *) e.getSlider(); ps3eye.setRedBalance(slider->getValue()); } else if(e.getName() == "ps3_bluebalance") { ofxUIIntSlider *slider = (ofxUIIntSlider *) e.getSlider(); ps3eye.setBlueBalance(slider->getValue()); } else if(e.getName() == "ps3_exposure") { ofxUIIntSlider *slider = (ofxUIIntSlider *) e.getSlider(); ps3eye.setExposure(slider->getValue()); } else if(e.getName() == "ps3_hue") { ofxUIIntSlider *slider = (ofxUIIntSlider *) e.getSlider(); ps3eye.setHue(slider->getValue()); } else if(e.getName() == "ps3_sharpness") { ofxUIIntSlider *slider = (ofxUIIntSlider *) e.getSlider(); ps3eye.setSharpness(slider->getValue()); } else if(e.getName() == "save_camera") { ofxUIButton *btn = (ofxUIButton *) e.getButton(); if (btn->getValue()) guihash["1"]->saveSettings("settings/"+guihash["1"]->getName()+"Settings.xml"); } else if(e.getName() == "load_camera") { ofxUIButton *btn = (ofxUIButton *) e.getButton(); if (btn->getValue()) guihash["1"]->loadSettings("settings/"+guihash["1"]->getName()+"Settings.xml"); } else if(e.getName() == "save_blobtracker") { ofxUIButton *btn = (ofxUIButton *) e.getButton(); if (btn->getValue()) guihash["1"]->saveSettings("settings/"+guihash["1"]->getName()+"Settings.xml"); } else if(e.getName() == "load_blobtracker") { ofxUIButton *btn = (ofxUIButton *) e.getButton(); if (btn->getValue()) guihash["2"]->loadSettings("settings/"+guihash["2"]->getName()+"Settings.xml"); } else if(e.getName() == "save_warper") { ofxUIButton *btn = (ofxUIButton *) e.getButton(); if (btn->getValue()) warper.save("settings/warper.xml"); } else if(e.getName() == "load_warper") { ofxUIButton *btn = (ofxUIButton *) e.getButton(); if (btn->getValue()) warper.load("settings/warper.xml"); } else if(e.getName() == "warper_mode") { ofxUIToggle *tgl = (ofxUIToggle *) e.getToggle(); if (tgl->getValue()) warper.activate(); else warper.deactivate(); } // else if(e.getName() == "FULLSCREEN") // { // ofxUIToggle *toggle = e.getToggle(); // ofSetFullscreen(toggle->getValue()); // } }
//-------------------------------------------------------------- void testApp::guiEvent(ofxUIEventArgs &e) { string name = e.widget->getName(); int kind = e.widget->getKind(); if(kind == OFX_UI_WIDGET_TOGGLE) { ofxUIToggle *toggle = (ofxUIToggle *) e.widget; if (name == "ENEMIES") { creatingEnemies = true; } if (name == "COLLECTABLES") { creatingEnemies = false; } } if (name == "Included Patterns") { if (patternList->isOpen() == true) { cout << "Show Remove Button" << endl; removeButton->setVisible(true); removeButton->setLabelText("REMOVE"); } else { cout << "Hide Remove Button" << endl; removeButton->setVisible(false); } } if (name == "Starting") { ofxUISlider *speedSlider = (ofxUISlider *) e.getSlider(); speed = speedSlider->getScaledValue(); currentSpeed = speed; } if (name == "Multiplier") { ofxUISlider *multiSlider = (ofxUISlider *) e.getSlider(); multiplier = multiSlider->getScaledValue(); } if(name == "SIZE") { ofxUISlider *slider = (ofxUISlider *) e.getSlider(); pointSize = slider->getScaledValue(); } if(name == "clear pattern") { buttonCount++; if(buttonCount ==2) { enemies.clear(); collectables.clear(); XML.clear(); } } if (name == "save pattern") { buttonCount++; if (buttonCount == 2) { savePattern(); buttonCount = 0; } } if (name == "add to level") { buttonCount++; if (buttonCount == 2) { patterns.push_back(patternInput->getTextString() + ".xml"); patternList->addToggle(patternInput->getTextString()); savePattern(); buttonCount = 0; } } if (name == "REMOVE PATTERN") { buttonCount++; if (buttonCount ==2) { vector<ofxUIWidget *> &selected = patternList->getSelected(); for(int i = 0; i < selected.size(); i++) { cout << "SELECTED: " << selected[i]->getName() << endl; patterns.erase(patterns.begin() + i); patternList->removeToggle(selected[i]->getName()); } buttonCount = 0; } } if (name == "SAVE LEVEL") { buttonCount++; if (buttonCount == 2) { ofxXmlSettings levelXML; levelXML.setValue("name", levelInput->getTextString()); levelXML.setValue("author", authorInput->getTextString()); levelXML.setValue("complete", completeInput->getTextString()); levelXML.setValue("speed", speedSlider->getValue()); levelXML.setValue("multiplier", multiSlider->getValue()); for (int i = 0; i < patterns.size(); i++) { levelXML.setValue("file", patterns[i], i); } levelXML.saveFile("new.level"); levelXML.clear(); buttonCount = 0; } } if(name == "OPEN EXISTING PATTERN") { buttonCount++; if (buttonCount == 2) { ofFileDialogResult openFileResult= ofSystemLoadDialog("Select a pattern to open"); //Check if the user opened a file if (openFileResult.bSuccess){ cout << openFileResult.getName() << endl; ofLogVerbose("User selected a file"); //We have a file, check it and process it ofFile file (openFileResult.getPath()); if (file.exists()){ string fileExtension = ofToUpper(file.getExtension()); if (fileExtension == "XML") { cout << "it's XML" << " " << file.getAbsolutePath() << endl; patternInput->setTextString(file.getBaseName()); canvasLocation.set(0, 500); if( XML.loadFile(file.getAbsolutePath()) ){ enemies.clear(); collectables.clear(); for (int i = 0; i < XML.getNumTags("enemy"); i++) { ofPoint tmpPoint; tmpPoint.set(XML.getValue("enemy:x", 0, i), XML.getValue("enemy:y", 0, i), XML.getValue("enemy:size", 0, i)); enemies.push_back(tmpPoint); } for (int i = 0; i < XML.getNumTags("collectables"); i++) { ofPoint tmpPoint; tmpPoint.set(XML.getValue("collectable:x", 0, i), XML.getValue("collectable:y", 0, i), XML.getValue("collectable:size", 0, i)); collectables.push_back(tmpPoint); } } else { cout << "can't load file" << endl; } } else { cout << "it's not XML" << endl; } } } buttonCount = 0; } } }