Beispiel #1
0
void ofxUITabBar::mainUiEvent(ofxUIEventArgs &event)
{
    string name = event.getName();
    for (map<ofxUIToggle*, ofxUICanvas*>::iterator it=canvases.begin(); it!=canvases.end(); ++it)
    {
        if(active != NULL && active->getName() == name)
        {
            it->first->setValue(false);
            it->second->disable();
            active = NULL;
        }
        else if(it->second->getName() == name && event.getToggle()->getValue())
        {
            active = it->second;
            it->first->setValue(true);
            it->second->enable();
            it->second->setPosition(rect->getX() + rect->getWidth() + padding*0.5, this->rect->getY());
        }
        else
        {
            it->first->setValue(false);
            it->second->disable();
        }
    }
}
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();
      }
    }
        
  }
}
Beispiel #3
0
void GUIAxes::checkOverlapingDDL(ofxUIEventArgs & e){

    switch (e.getKind()) {
        case OFX_UI_WIDGET_DROPDOWNLIST:
        {bool hideothers = ((ofxUIDropDownList*)e.widget)->getValue();
            
            if(e.getCanvasParent()!=NULL){
                
                vector<ofxUIWidget*> vv = e.getCanvasParent()->getWidgetsOfType(OFX_UI_WIDGET_DROPDOWNLIST);
                for(vector<ofxUIWidget*>::iterator it = vv.begin() ; it !=vv.end() ; ++it){
                    if(e.widget->getRect()->x ==  (*it)->getRect()->x && e.widget->getRect()->y <  (*it)->getRect()->y &&((ofxUIDropDownList*)*it)!=e.widget){
                        
                        ((ofxUIDropDownList*)*it)->setVisible(!hideothers);
                    }
                }
            }
        }
            break;
            
            
        default:
            break;
    }
    
}
void TestScene::guiEvent(ofxUIEventArgs &e)
{
    
    string name = e.getName();
	int kind = e.getKind();
	//cout << "got event from: " << name << endl;
    
}
//-------------
void ofApp::selectAudioUnit(ofxUIEventArgs &e) {
    if (e.getButton()->getValue())  return;
    if (e.getName() == "Aalto") {
        setupAalto();
    }
    else if (e.getName() == "Kaivo") {
        setupKaivo();
    }
}
Beispiel #6
0
void ofApp::guiEvent(ofxUIEventArgs &e)
{
	string name = e.getName();
	int kind = e.getKind();
	cout << "got event from: " << name << endl;
    if(kind == OFX_UI_WIDGET_NUMBERDIALER)
    {
        ofxUINumberDialer *n = (ofxUINumberDialer *) e.widget;
        cout << n->getValue() << endl;
    }
	
    if(name == "SAMPLER")
    {
        ofxUIImageSampler *is = (ofxUIImageSampler *) e.widget;
        ofColor clr = is->getColor();
        red = clr.r;
        blue = clr.b;
        green = clr.g;
    }
	else if(name == "BUTTON")
	{
		ofxUIButton *button = (ofxUIButton *) e.getButton();
		bdrawGrid = button->getValue();
	}
	else if(name == "TOGGLE")
	{
		ofxUIToggle *toggle = (ofxUIToggle *) e.getToggle();
		bdrawGrid = toggle->getValue();
        if(textInput != NULL)
        {
            textInput->setFocus(bdrawGrid);
        }
	}
    else if(name == "RADIO VERTICAL")
    {
        ofxUIRadio *radio = (ofxUIRadio *) e.widget;
        cout << radio->getName() << " value: " << radio->getValue() << " active name: " << radio->getActiveName() << endl; 
    }
    else if(name == "TEXT INPUT")
    {
        ofxUITextInput *ti = (ofxUITextInput *) e.widget;
        if(ti->getInputTriggerType() == OFX_UI_TEXTINPUT_ON_ENTER)
        {
            cout << "ON ENTER: ";
        }
        else if(ti->getInputTriggerType() == OFX_UI_TEXTINPUT_ON_FOCUS)
        {
            cout << "ON FOCUS: ";
        }
        else if(ti->getInputTriggerType() == OFX_UI_TEXTINPUT_ON_UNFOCUS)
        {
            cout << "ON BLUR: ";
        }
        string output = ti->getTextString();
        cout << output << endl;
    }
}
Beispiel #7
0
//--------------------------------------------------------------
void TestScene::guiEvent(ofxUIEventArgs &e) {
    name = e.getName() ; 
    if ( name == "LOAD SETTINGS" && e.getButton()->getValue() == true )
        loadSettings() ;
    
    if ( name == "SAVE SETTINGS" && e.getButton()->getValue() == true )
        saveSettings() ;
    
}
Beispiel #8
0
//--------------------------------------------------------------
void AnimationWaves::guiEvent(ofxUIEventArgs &e)
{
	Animation::guiEvent(e);

	string name = e.getName();
	if (name == "nbWavePoints")
	{
		m_nbWavePoints = (int) e.getSlider()->getScaledValue();
		updateNbPointsForWaves();
	}
}
void CloudsVisualSystemPaintBrush::guiSystemEvent(ofxUIEventArgs &e)
{
    if (e.widget->getKind() == OFX_UI_WIDGET_TOGGLE && e.getToggle()->getValue()) {
		string name = e.getName();
        for (map<string, ofPixels *>::iterator it = colorMapPixelsMap.begin(); it != colorMapPixelsMap.end(); it++) {
			if (it->first == name) {
				colorMap = it->second;
			}
		}
	}
}
void ofApp::guiEvent(ofxUIEventArgs &e){
    string name = e.getName();
    int kind = e.getKind();
    
    if (name=="simulate") {
        simulate = ((ofxUIToggle *)e.widget)->getValue();
    } else if (name == "enable actuator 1"){
        enableActuator(1);
    } else if (name == "enable actuator 2"){
        enableActuator(2);
    }
    
}
Beispiel #11
0
void ofApp::guiEvent(ofxUIEventArgs &e)
{
    if (e.getName() == "FULLSCREEN")
    {
        ofxUIToggle* toggle = e.getToggle();
        ofSetFullscreen(toggle->getValue());
    }
    else if (e.getName() == "ENABLE FACE TRACKING")
    {
        ofxUIToggle* toggle = e.getToggle();
        trackingEnabled = toggle->getValue();
    }
    else if (e.getName() == "SHOW TRACKER")
    {
        ofxUIToggle* toggle = e.getToggle();
        showTracker = toggle->getValue();
    }
    else if (e.getName() == "SET TRACKER OFFSET") {
        ofxUIButton *button = (ofxUIButton *)e.widget;
        if (button->getValue()) {
            trackerOffset = ofVec2f(cam.getPosition().x - trackerOffset.x,
                    cam.getPosition().y - trackerOffset.y);
        }
    }
    else if (e.getName() == "REMOVE TRACKER OFFSET") {
        ofxUIButton *button = (ofxUIButton *)e.widget;
        if (button->getValue()) {
            trackerOffset = ofVec2f();
        }
    }
}
Beispiel #12
0
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 CloudsVisualSystemFlocking::guiSystemEvent(ofxUIEventArgs &e){
    string name = e.getName();
    if(name == "ADD PARTICLE")
    {
        if(e.getButton()->getValue())
        {
            for(int i = 0; i < 100; i++)
            {
                ofxBoidParticle *bp = new ofxBoidParticle(ofVec3f(ofRandom(-debugGridSize, debugGridSize), ofRandom(-debugGridSize, debugGridSize), ofRandom(-debugGridSize, debugGridSize)));
                bp->setParticlesRef(&ps->getParticles());
                ps->addParticle(bp);
            }
        }
    }
    else if(name == "BORDER")
    {
        *(ps->bWidth) = debugGridSize;
        *(ps->bHeight) = debugGridSize;
        *(ps->bDepth) = debugGridSize;
    }
    else if(name == "ZONE RADIUS")
    {
        (*ps->zoneRadiusHalf) = (*ps->zoneRadius)/2.0;
        (*ps->zoneRadiusSqrd) = powf((*ps->zoneRadius), 2.0);
    }
    else if(name == "KILL PARTICLES")
    {
        if(e.getButton()->getValue())
        {
            ps->clear();
        }
    }
    else if(name == "PRINT SETTINGS")
    {
        if(e.getButton()->getValue())
        {
            ps->printSettings();
        }
    }
    else if(name == "RANDOMIZE")
    {
        if(e.getButton()->getValue())
        {
            randomize();
        }
    }
}
void SuperColliderLoopElement::guiEvent(ofxUIEventArgs &e) {
    if (e.getName() == "Play") {
        setPlaying(isPlay);
    }
    else if (e.getName() == "Rec") {
        setToRecord(toRecord);
    }
    else if (e.getName() == "Solo") {
        setSolo(solo);
        SuperColliderLoopElement *ref = this;
        ofNotifyEvent(soloEvent, ref);
    }
    else if (e.getName() == "Del") {
        SuperColliderLoopElement *ref = this;
        ofNotifyEvent(deleteEvent, ref);
    }
    else if (e.getName() == "Skip") {
        skip = pow((float) 2, (float) ((ofxUIRadio *) gui->getWidget("Skip"))->getValue());
        count = beat % (numBeats * getSkip());
    }
    else if (e.getName() == "BusIn") {
        int channel = ((ofxUIRadio *) gui->getWidget("BusIn"))->getValue();
        bufWriter->set("channel", channel);
    }
    else if (e.getName() == "Volume") {
        cout << "write vol " << volume << endl;
        bufReader->set("volume", volume);
    }
}
Beispiel #15
0
//--------------------------------------------------------------
void ofApp::guiEvent(ofxUIEventArgs &e)
{
    string name = e.getName();
    string alignment = "alignment";
    if(name == "pixelWidth" || name == "pixelWidthLarge"){
        ((ofxUITextInput*)settingCanvas->getWidget("pixelWidthText"))->setTextString(ofToString(float(desideredPixelWidthLarge)+desideredPixelWidth));
    }else if(name == "pixelWidthText"){
        string val = ((ofxUITextInput*)e.widget)->getTextString();
        float fval = ofToFloat(val);
        desideredPixelWidth = fmodf(fval,1.0);
        desideredPixelWidthLarge = floor(fval);
        
        
    }else if(name == "Calibrate Menu"){
        lastState = state;
        state = Calibratig;
        settingCanvas->setVisible(false);
        calibrateCanvas->setVisible(true);
    }else if(name.substr(0,alignment.size()) == alignment ){
        int start = alignment.size()+1;
        int x = ofToInt(name.substr(start,start+1));
        int y = ofToInt(name.substr(start+2,start+3));
        texAlign.x = x == 0 ? 0 : x == 1 ? 0.5 : 1.0;
        texAlign.y = y == 0 ? 1.0 : y == 1 ? 0.5 : 0.0;

    }else if(name == "Settings Menu"){
        lastState = state;
        state = Settings;
        settingCanvas->setVisible(true);
        calibrateCanvas->setVisible(false);
        
    }else if(name == "Calibration Size"){
        ofxUIRadio* w = ((ofxUIRadio*)e.widget);
        string active = w->getActiveName();
        vector<string> names(calibrationSizeOptionsNames,end(calibrationSizeOptionsNames));
        int pos = find(names.begin(), names.end(), active) - names.begin();
        ((ofxUILabel*)calibrateCanvas->getWidget("selected_calibration"))->setLabel(calibrationSizeOptionsNames[pos]);
        currentCalibratorTolLengthInMM = calibrationSizeOptionsValues[pos];
        
    }else if(name == "Read From Marker"){
        outPixelPerMM = calibratorTool.getLength() / currentCalibratorTolLengthInMM;
        
    }else if(name == "Syphon Servers"){
        ofxUIRadio *syphon_list = (ofxUIRadio*)e.widget;
        string active = syphon_list->getActiveName();
        vector<string> parts = ofSplitString(active, "::");
        syphonServerDesc = ofxSyphonServerDescription(parts[0],parts[1]);
        syphonClient.set(syphonServerDesc);
    }else if(name == "Mode"){
        ofxUIRadio *mode_list = (ofxUIRadio*)e.widget;
        if(mode_list->getActiveName() == "Round"){
            mode = 0;
        }else {
            mode = 1;
        }
    }
}
void CloudsVisualSystemMazeGenerator::selfGuiEvent(ofxUIEventArgs &e)
{
    if (e.getName() == "GROUND CAM") {
        if (!settings.groundCam)
        {
            mazeCam.setFlyOver(maze[0]->getWidth()/2);
        }        
    }
}
Beispiel #17
0
void testApp::onGuiEvent( ofxUIEventArgs &e){
    // Send Message To Log. Where is message coming from?
    cout << "I got a message" << e.getName() << endl;
    
    // Force Slider
    if( e.getName() == "Mass"){
        ofxUISlider * ForceSlider = (ofxUISlider*)e.widget;
        
        mass = ForceSlider -> getScaledValue();
    }
    if( e.getName() == "Alpha"){
        ofxUISlider * ForceSlider = (ofxUISlider*)e.widget;
        
        alphaLevel = ForceSlider -> getScaledValue();
    }
    // Alpha Slider
    if( e.getName() == "Field"){
        ofxUISlider * AlphaSlider = (ofxUISlider*)e.widget;
        
       fieldForce = AlphaSlider -> getScaledValue();
    }
}
Beispiel #18
0
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;
    }
}
Beispiel #19
0
void ofApp::guiEvent(ofxUIEventArgs &e)
{
	string name = e.getName();
	int kind = e.getKind();
	cout << "got event from: " << name << endl;
    if(name=="NUMPATTERN")
    {
        mesh.clear();
        for(int i = 0 ; i < numPattern ; i++)
        {
            for( int j = 0 ; j < numStroke ; j++)
            {
                
                mesh.addVertex(ofVec3f(0,0));
                mesh.addVertex(ofVec3f(0,0));
            }
        }

        vbo = mesh;
    }
    if(name=="NUMSTROKE")
    {
        mesh.clear();
        for(int i = 0 ; i < numPattern ; i++)
        {
            for( int j = 0 ; j < numStroke ; j++)
            {
                
                mesh.addVertex(ofVec3f(0,0));
                mesh.addVertex(ofVec3f(0,0));
            }
        }
        vbo = mesh;

    }

}
Beispiel #20
0
void GUIAxes::guiEvent(ofxUIEventArgs &e){
    // events based on mouse released
    if(ofGetMousePressed()){return;}
    
    
    
    string name = e.getName();
    
    
    int axe = getNumAxe(e.getParent());
    ofLogNotice("GUI") << e.getParent()->getName() << " // " << e.getName() << "// " <<  axe ;
    
    // attributes and aggregator modification
    if( axe!=-1 && attr[axe]->getSelected().size()>0 ){
        if(isAnAttributeList(e.getParent())){
            shouldUpdateAggregator = axe;
        }
        else if (aggr[axe]->getSelected().size()>0 && scaleType[axe]->getSelectedIndeces().size()>0) {
            reorderAxe(axe);
        }
        
    }
    else if(e.getParent() == coordinateType){
        for(int i = 0 ; i <3; i++){
            reorderAxe(i);
        }
    }
    
    
    // mins maxs modifications
    else if (e.getKind() == OFX_UI_WIDGET_NUMBERDIALER){
        axe = getNumAxe(e.widget);
        float s =((ofxUINumberDialer*)e.widget)->getValue();
        
        ofVec3f mask(axe==0?1:0,axe==1?1:0,axe==2?1:0);
        if(name.substr(0,name.length()-1)=="min"){
            Physics::mins = s*mask + (-mask+ofVec3f(1))*Physics::mins;
        }
        if(name.substr(0,name.length()-1)=="max"){
            Physics::maxs = s*mask + (-mask+ofVec3f(1))*Physics::maxs;
        }
        scaleType[axe]->getToggles()[2]->setValue(true);
        scaleType[axe]->getToggles()[2]->triggerSelf();
        Physics::orderByAttributes(attr[axe]->getSelected()[0]->getName()+"."+aggr[axe]->getSelected()[0]->getName(), axe, scaleType[axe]->getSelectedIndeces()[0]);
        
    }
    
    
    checkOverlapingDDL(e);
        
}
Beispiel #21
0
void GUIMidi::guiEvent(ofxUIEventArgs & e){
    
    if(e.getParent() == midiPorts){
        Midi::i()->midiIn.closePort();
        Midi::i()->midiIn.openPort(e.getName());
    }
    
    else if(e.widget == midiVelCenter || e.widget == midiVelRange){
        Midi::velScale.set(midiVelCenter->getValue() - midiVelRange->getValue()/2.0,midiVelCenter->getValue() + midiVelRange->getValue()/2.0);
    }
    else if(e.widget == resetNoteMap && !resetNoteMap->getValue()){
        Midi::midiNotes.clear();
        
    }
    else if(e.widget == midiRadius){
        Midi::radius = midiRadius->getValue();
        for(auto & m:Midi::midiSpots){
            m.radius = Midi::radius;
        }
    }
    else if(e.widget == midiHold){
        Midi::hold=midiHold->getValue();
    }
    else if(e.widget == midiLink2Cam){
        Midi::link2Cam = midiLink2Cam->getValue();
    }
    else if(e.widget == vel2Vol ){
        Midi::vel2VolScale.set(vel2Vol->getValueLow(),vel2Vol->getValueHigh());
    }
    else if(e.widget == midiSpots){
        Midi::bMidiSpot = e.getBool();
    }
    else if(e.widget==randomMidi){
        Midi::random = e.getDouble();
    }
}
void ofApp::guiEvent(ofxUIEventArgs &e)
{
//    if(e.getName() == "Background")
//    {
//        ofxUISlider *slider = new ofxUISlider();
//        ofBackground(slider->getScaledValue());
//    }
    if(e.getName() == "fogNear")
    {
        ofxUISlider *slider = new ofxUISlider();
        
    }
//    else if(e.getName() == "tunnelLength")
//    {
//        ofxUISlider *slider = new ofxUISlider();
//        
//    }
//    else if(e.getName() == "tunnelSeparation")
//    {
//        
//    }
//    else if(e.getName() == "tunnelRadius")
//    {
//        
//    }
//    else if(e.getName() == "rotationChange")
//    {
//        
//    }
//    else if(e.getName() == "xRotation")
//    {
//        
//    }
//    else if(e.getName() == "yRotation")
//    {
//        
//    }
//    else if(e.getName() == "moveSpeed")
//    {
//        
//    }
//    else if(e.getName() == "circleResolution")
//    {
//        
//    }
    
}
void PMUICanvasRibbonRenderer::handleEvents(ofxUIEventArgs &e)
{
    PMUICanvasBaseRenderer::handleEvents(e);

    string name = e.getName();

    if (name == STR_BRUSH_COLORMODE_RADIO)
    {
        ofxUIRadio *colorModeRadio = (ofxUIRadio *)(e.widget);
        colorMode = (RibbonColorMode)(colorModeRadio->getValue());

        ofxUIIntSlider *slColorR = (ofxUIIntSlider *)getWidget(STR_BRUSH_COLORMODE_R);
        colorR = slColorR->getValue();
        ofxUIIntSlider *slColorG = (ofxUIIntSlider *)getWidget(STR_BRUSH_COLORMODE_G);
        colorG = slColorG->getValue();
        ofxUIIntSlider *slColorB = (ofxUIIntSlider *)getWidget(STR_BRUSH_COLORMODE_B);
        colorB = slColorB->getValue();
    }
}
//--------------------------------------------------------------
void toolCalibration::handleEvents(ofxUIEventArgs& e)
{
	string name = e.getName();
	OFAPPLOG->begin("toolCalibration::handleEvents('"+name+"')");
	OFAPPLOG->println("- kind="+ofToString(e.getKind()));
	
	if (e.getKind() == OFX_UI_WIDGET_TOGGLE)
	{

	 ofxUIToggle* pToggle = e.getToggle();
	 if (pToggle->getValue())
	 {

		 mp_modelData = 0;
		 m_editModelPropertyName = name;
		 if (pToggle->getParent() == mp_radioApparel)
		 {
			 m_editModel = EDIT_APPAREL;
			 mp_modelData = &m_apparelData;
		 }
		 else
		 if (pToggle->getParent() == mp_radioManikin)
		 {
			 m_editModel = EDIT_MANIKIN;
			 mp_modelData = &m_manikinData;
		 }

		 if (mp_modelData)
		 {
			 mp_modelData->reset();
			 mp_modelData->m_modelPositionSensitivity = m_modelPositionSensitivity;
			 mp_modelData->m_modelScaleSensitivity = m_modelScaleSensitivity;
		 }

	 }

	}
	else if (e.getKind() == OFX_UI_WIDGET_LABELBUTTON)
	{
		if (name == "savePropertiesDevice" && e.getButton()->getValue()==1)
		{
			GLOBALS->getApp()->apparelModel.saveProperties();

			OSC_SENDER->saveCalibration();
		}
	}

	OFAPPLOG->end();
}
void SuperColliderLooper::guiEvent(ofxUIEventArgs &evt) {
    if (evt.getName() == "Bpm") {
        setBpm(bpm);
    }
    else if (evt.getName() == "Record") {
        string filename = ofSystem("Filename");
    }
    else if (evt.getName() == "+1" && ((ofxUILabelButton *) gui->getWidget("+1"))->getValue()) {
        addNewElement(1, elements.size());
    }
    else if (evt.getName() == "+2" && ((ofxUILabelButton *) gui->getWidget("+2"))->getValue()) {
        addNewElement(2, elements.size());
    }
    else if (evt.getName() == "+4" && ((ofxUILabelButton *) gui->getWidget("+4"))->getValue()) {
        addNewElement(4, elements.size());
    }
    else if (evt.getName() == "+8" && ((ofxUILabelButton *) gui->getWidget("+8"))->getValue()) {
        addNewElement(8, elements.size());
    }
    else if (evt.getName() == "+16" && ((ofxUILabelButton *) gui->getWidget("+16"))->getValue()) {
        addNewElement(16, elements.size());
    }
}
Beispiel #26
0
//------------------------------------------------------------------------------------
//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);
        }
    }
}
Beispiel #27
0
void testApp::guiEvent(ofxUIEventArgs &e){
	string name = e.widget->getName();
	int kind = e.widget->getKind();
    
    if(e.getName() == "FULLSCREEN"){
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        ofSetFullscreen(toggle->getValue());
        
        
        /*----------------- PARTICLES -----------------*/
	}else if(name == "PARTICLE GUI MODE"){
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        particleGUImode = toggle->getValue();
        
	}else if(name == "EXPANSION"){
		ofxUISlider *slider = (ofxUISlider *) e.widget;
		expansion = slider->getScaledValue();
        
    }else if(name == "ROTATION"){
		ofxUISlider *slider = (ofxUISlider *) e.widget;
		rotation = slider->getScaledValue();
        
    }else if(name == "SHAPE SIZE"){
		ofxUISlider *slider = (ofxUISlider *) e.widget;
		shapeSize = slider->getScaledValue();
        
    }else if(name == "VERTICES"){
		ofxUISlider *slider = (ofxUISlider *) e.widget;
		nVertices = slider->getScaledValue();
        
    }else if(name == "PARTICLE SIZE"){
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        particleSize = slider->getScaledValue();
        
    }else if(name == "SHAPES"){
        ofxUIRadio *radio = (ofxUIRadio *) e.widget;
        cout << radio->getName() << " value: " << radio->getValue() << " active name: " << radio->getActiveName() << endl;
        selectedShape = radio->getActiveName();
        
    }else if(name == "MODES"){
        ofxUIRadio *radio = (ofxUIRadio *) e.widget;
        cout << radio->getName() << " value: " << radio->getValue() << " active name: " << radio->getActiveName() << endl;
        selectedMode = radio->getActiveName();
        
        
        /*---------------- BACKGROUND -----------------*/

	}else if(name == "TILE GUI MODE"){
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        tileGUImode = toggle->getValue();
        
    }else if(name == "TILE MODES"){
        ofxUIRadio *radio = (ofxUIRadio *) e.widget;
        cout << radio->getName() << " value: " << radio->getValue() << " active name: " << radio->getActiveName() << endl;
        selectedTileMode = radio->getActiveName();
        
    }else if(name == "HUE"){
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        hue = slider->getScaledValue();

    }else if(name == "VIDEO"){
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        videoAlpha = slider->getScaledValue();
        
    }else if(name == "THRESHOLD"){
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        threshold = slider->getScaledValue();
    }
}
void testApp::menuEvent(ofxUIEventArgs &e)
{
    zoom_in = false;
    zoom_out = false;
    
    string name = e.getName();
    if (name == "Straight Links") {
        ((ofxUIImageToggle*)menu->getWidget("Straight Links"))->setValue(true);
        ((ofxUIImageToggle*)menu->getWidget("Segmented Links"))->setValue(false);
        ((ofxUIImageToggle*)menu->getWidget("Curved Links"))->setValue(false);
        composer->setLinkType(STRAIGHT_LINKS);
    }
    else if (name == "Curved Links") {
        ((ofxUIImageToggle*)menu->getWidget("Curved Links"))->setValue(true);
        ((ofxUIImageToggle*)menu->getWidget("Segmented Links"))->setValue(false);
        ((ofxUIImageToggle*)menu->getWidget("Straight Links"))->setValue(false);
        composer->setLinkType(CURVE_LINKS);
    }
    else if (name == "Segmented Links") {
        ((ofxUIImageToggle*)menu->getWidget("Segmented Links"))->setValue(true);
        ((ofxUIImageToggle*)menu->getWidget("Curved Links"))->setValue(false);
        ((ofxUIImageToggle*)menu->getWidget("Straight Links"))->setValue(false);
        composer->setLinkType(PATH_LINKS);
    }
    else if (name == "Create Node") {
        
        if (newNodeInput == NULL)
            this->createNodeInput((ofGetWidth()/2)-75, ofGetHeight()/2);
        else if (!newNodeInput->isClicked()){
            newNodeInput->getRect()->setX((ofGetWidth()/2)-75);
            newNodeInput->getRect()->setY(ofGetHeight()/2);
            
            newNodeInput->getDropdownList()->getRect()->setX((ofGetWidth()/2)-75);
            newNodeInput->getDropdownList()->getRect()->setY(ofGetHeight()/2);
            
            newNodeInput->setFocus(true);
        }
    }
    else if (name == "Edit Mode on/off") {
        
        if (composer->getEdit())
            composer->setEdit(false);
        else composer->setEdit(true);
    }
    else if (name == "Inspect"){
        if (open_flyout) open_flyout = false;
        else open_flyout = true;
    }
    else if (name == "Zoom In"){
        
        if(((ofxUIMultiImageButton*)e.widget)->getValue() == 1){
            zoom_in = true;
            scale -= 10*SCALE_SENSITIVITY;
            cam.setScale(scale);
        }
    }
    else if (name == "Zoom Out"){
        
        if(((ofxUIMultiImageButton*)e.widget)->getValue() == 1){
            zoom_out = true;
            scale += 10*SCALE_SENSITIVITY;
            cam.setScale(scale);
        }
    }
    else if (name == "Save Snippet"){
        if(((ofxUIMultiImageButton*)e.widget)->getValue() == 1){
            composer->saveSnippet();
        }
    }
    else if (name == "Open Snippet"){
        if(((ofxUIMultiImageButton*)e.widget)->getValue() == 1){
            composer->loadSnippet();
        }
    }
}
//--------------------------------------------------------------
void ofApp::guiEvent(ofxUIEventArgs &e){
    
    if(e.getName()=="Fullscreen"){
        ofToggleFullscreen();
    }
}
Beispiel #30
0
//--------------------------------------------------------------
void Animation::guiEvent(ofxUIEventArgs &e)
{
	string name = e.widget->getName();
	int kind = e.widget->getKind();
	


    if (kind == OFX_UI_WIDGET_SLIDER_H || kind == OFX_UI_WIDGET_SLIDER_V)
    {
		if (name == "volume")
		{
			m_soundPlayer.setVolume( ((ofxUISlider*) e.widget)->getScaledValue() );
		}
		else
		{
			if (mp_obj)
    	    {
			    ofxJSValue retVal;
        	    ofxJSValue args[2];
            	args[0] = string_TO_ofxJSValue( name );
            	args[1] = float_TO_ofxJSValue( ((ofxUISlider*) e.widget)->getScaledValue() );
				ofxJSCallFunctionNameObject_IfExists(mp_obj,"eventUI", args,2,retVal);
			}
		}
    }
	else
	if (kind == OFX_UI_WIDGET_TOGGLE)
	{
		// TODO : not cool here

		if (guiEventTogglesSound(name))
		{
			m_soundPlayer.m_listSoundNames.clear();
			for (int i=0; i<m_listSoundNames.size(); i++){
				ofxUIToggle* pSoundToggle = (ofxUIToggle*) mp_UIcanvas->getWidget( m_listSoundNames[i] );
				if (pSoundToggle->getValue()){
//					 ofLog() << m_name << " / " << m_listSoundNames[i];
					m_soundPlayer.add( m_listSoundNames[i] );
				}
			}
		}
		else
		{
			if (mp_obj)
    	    {
				bool valToggle = ((ofxUIToggle*) e.widget)->getValue() ;

			    ofxJSValue retVal;
	            ofxJSValue args[2];
    	        args[0] = string_TO_ofxJSValue( name );
        	    args[1] = int_TO_ofxJSValue( valToggle ? 1 : 0 );
				ofxJSCallFunctionNameObject_IfExists(mp_obj,"eventUI", args,2,retVal);
			}
		}
	}
    else if (kind == OFX_UI_WIDGET_LABELBUTTON)
	{
		
		if ( e.getButton()->getValue())
		{
			if (name == "Save")
			{
				string filename = mp_teConfigName->getTextString();
				saveConfiguration(filename);

				m_configurationCurrent = filename;
			}
			else if (name == "Load")
			{
				string filename = mp_teConfigName->getTextString();
				m_configurationCurrent = filename;
				loadConfiguration(filename);
			}
			else if (name == "exportTemplate")
			{
				 exportMidiSettingsTemplate();
			}
		}
	}
}