Mercurial > hg > soniczoomios
diff testApp.mm @ 25:f42a00e3f22d
Logs condensed slightly. Questionnaire button enable.
double precision location!!!
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Fri, 01 Feb 2013 17:39:19 +0000 |
parents | a4908ad8c78e |
children | 2e1fdac115af |
line wrap: on
line diff
--- a/testApp.mm Fri Feb 01 11:16:56 2013 +0000 +++ b/testApp.mm Fri Feb 01 17:39:19 2013 +0000 @@ -1,6 +1,7 @@ #include "testApp.h" #define SLIDER_GUI_WIDTH 256 +#define NUM_PARAMS 10 extern Grid theGridView; extern PresetManager presetManager; extern EventLogger eventLogger; @@ -89,17 +90,26 @@ topButtonViewController = [[TopButtonViewController alloc] initWithNibName:@"TopButtonViewController" bundle:nil]; [ofxiPhoneGetGLParentView() addSubview:topButtonViewController.view]; - [topButtonViewController setAppRef:(id)this]; [topButtonViewController show:(id)this]; - topButtonViewController.view.frame = CGRectMake(0,0,getWidth(),44); + usernameAlertViewController = [[UsernameAlertViewController alloc] init]; + /* + sliderViewController = [[SliderViewController alloc] initWithNibName:@"SLiderViewController" bundle:nil]; + [ofxiPhoneGetGLParentView() addSubview:sliderViewController.view]; + + [sliderViewController setAppRef:(id)this]; + [sliderViewController show:(id)this]; + + sliderViewController.view.frame = CGRectMake(0,getHeight()-43 - 363,getWidth(),44); + */ + // initialise user logging stuff presetManager.startupLoadAll(); eventLogger.init(); - + whichInterfaceShowing = BOTH; // GO paused = false; @@ -108,17 +118,16 @@ //-------------------------------------------------------------- void testApp::exit(){ - if(consentGiven){ - presetManager.exitAndSaveAll(); - eventLogger.exitAndSave(); - } - - // else - don't save anything and app will boot up into consent/intro screen + + presetManager.exitAndSaveAll(); + eventLogger.exitAndSave(); + core.exit(); - [introViewController release]; - [topButtonViewController release]; - [bottomTabViewController release]; + // are these handled automatically? + //[introViewController release]; + //[topButtonViewController release]; + //[bottomTabViewController release]; delete sliderGUI; @@ -139,115 +148,21 @@ } #pragma mark GUI - -//-------------------------------------------------------------- -/* -void testApp::setupZoomGui(){ - // width = height - int buttonHeight = 45; - zoomGUI = new ofxUICanvas(getWidth()-200,0,190,buttonHeight*7); - zoomGUI->setTheme(OFX_UI_THEME_METALGEAR ); - - zoomGUI->addLabelToggle("START/STOP", false); - zoomGUI->addLabelButton("SAVE PRESET", false); - zoomGUI->addLabelButton("ZOOM MIN", false); - zoomGUI->addLabelButton("ZOOM MAX", false); - zoomGUI->addLabelButton("QUESTIONS", false); - - - ofxUILabelToggle * butt = zoomGUI->addLabelToggle("LOCK SEQUENCE (X)", false); - butt->setColorFill(ofColor(0,0,255)); - butt->setColorFillHighlight(ofColor(0,0,255)); - - ofxUILabelToggle * butt2 = zoomGUI->addLabelToggle("LOCK SYNTH (Y)", false); - butt2->setColorFill(ofColor(255,0,0)); - butt2->setColorFillHighlight(ofColor(255,0,0)); - - - ofAddListener(zoomGUI->newGUIEvent, this, &testApp::zoomGUIEvent); -} - -//-------------------------------------------------------------- -void testApp::zoomGUIEvent(ofxUIEventArgs &e){ - - if(e.widget->getName() == "SAVE PRESET") - { - - if(((ofxUIButton *)e.widget)->getValue()==0){ // touchup - cout << "SAVE PRESET\n"; - presetManager.showNameDialog(); - - } - - }else if(e.widget->getName() == "ZOOM MIN") - { - if(((ofxUIButton *)e.widget)->getValue()==0){ // touchup - cout << "ZOOM MIN\n"; - theGridView.setMinZoom(); - eventLogger.logEvent(SET_MIN_ZOOM); - } - }else if(e.widget->getName() == "ZOOM MAX") - { - if(((ofxUIButton *)e.widget)->getValue()==0){ // touchup - cout << "ZOOM MAX\n"; - theGridView.setMaxZoom(); - eventLogger.logEvent(SET_MAX_ZOOM); - - } - }else if(e.widget->getName() == "QUESTIONS") - { - if(((ofxUIButton *)e.widget)->getValue()==0){ // touchup - showQuestionnaire(); - } - }else if(e.widget->getName() == "LOCK SEQUENCE (X)") - { - - cout << "LOCK SEQUENCE (X)\n"; - // lock - theGridView.shiftCentreToSnapped(); - xLocked = !xLocked; - - }else if(e.widget->getName() == "LOCK SYNTH (Y)") - { - - cout << "LOCK SYNTH (Y)\n"; - // lock - theGridView.shiftCentreToSnapped(); - if(((ofxUIButton *)e.widget)->getValue()){ - yLocked = true; - }else{ - yLocked = false; - - } - - }else if(e.widget->getName() == "START/STOP") - { - - - //pd.startMessage(); - /// pd.addSymbol("hello"); - /// pd.addFloat(1.23); - /// pd.finishList("test"); - }else{ - cout << "GUI error : unknown event recieved\n"; - } - -} - */ - - //////////////////////////// // These functions called from iOS toolbars //-------------------------------------------------------------- void testApp::lockSequencerPressed(bool locked){ theGridView.shiftCentreToSnapped(); xLocked = locked; + eventLogger.logEvent(SEQ_LOCKED); + } //-------------------------------------------------------------- void testApp::lockSynthPressed(bool locked){ theGridView.shiftCentreToSnapped(); yLocked = locked; + eventLogger.logEvent(SYNTH_LOCKED); } //-------------------------------------------------------------- @@ -256,11 +171,13 @@ core.pd.startMessage(); core.pd.addFloat(0); core.pd.finishMessage("fromOF", "seqStartStop"); + eventLogger.logEvent(PAUSE_PRESSED); }else { // play //stopSequencer(); core.pd.startMessage(); core.pd.addFloat(1); core.pd.finishMessage("fromOF", "seqStartStop"); + eventLogger.logEvent(PLAY_PRESSED); } } //-------------------------------------------------------------- @@ -305,7 +222,7 @@ //-------------------------------------------------------------- void testApp::showIntro(){ paused = true; - consentGiven = false; + cout << "SHOW INTRO\n"; introViewController = [[IntroViewController alloc] initWithNibName:@"IntroViewController" bundle:nil]; @@ -322,8 +239,10 @@ void testApp::introHidden(bool OK){ if(OK){ paused = false; - consentGiven = true; + eventLogger.consentGiven = true; whichInterfaceShowing = BOTH; + // show username prompt + [usernameAlertViewController showUserNamePrompt]; } // no unOK } @@ -338,6 +257,7 @@ // set the slider values to stuff got from zoomer sliderVals = theGridView.getParams(); setAllGUISliders(sliderVals); + break; case 1: @@ -353,7 +273,7 @@ whichInterfaceShowing = ZOOMER; break; } - + eventLogger.logEvent(SWAP_VIEW,TwoVector(),0.0, which); } //-------------------------------------------------------------- //-------------------------------------------------------------- @@ -375,7 +295,7 @@ for(int i = 1; i<=10;i++){ ofxUISlider *slider; - slider = (ofxUISlider *)sliderGUI->addWidgetDown(new ofxUISlider(width,dim,0.0,127,64,sliderParamNames[i-1])); + slider = (ofxUISlider *)sliderGUI->addWidgetDown(new ofxUISlider(length,dim,0.0,127,64,sliderParamNames[i-1])); slider->setDrawPadding(true); if(i <= 5){ slider->setColorFill(ofColor(0,0,255)); @@ -426,13 +346,29 @@ //-------------------------------------------------------------- void testApp::setAllGUISliders(vector<int> vals){ // an update caused by zoomer view being moved - for(int i = 0; i<10;i++){ + for(int i = 0; i<NUM_PARAMS;i++){ sliders[i]->setValue(vals[i]); sliderVals[i] = vals[i]; } } //-------------------------------------------------------------- +void testApp::randomise(){ + // pick random settings for all params + for(int i=0; i < NUM_PARAMS ; i++){ + sliderVals[i] = ofRandom(0, 127); + + } + + // send to grid, sliders and PD + theGridView.setParams(sliderVals); + setAllGUISliders(sliderVals); + sendParametersToPD(); + + eventLogger.logEvent(RANDOMISE, theGridView.getCoord() ,0.0); + +} +//-------------------------------------------------------------- void testApp::sendParametersToPD(){ // frequencer stuff to get 16 steps vector<double> vals; @@ -721,7 +657,17 @@ //-------------------------------------------------------------- void testApp::touchDoubleTap(ofTouchEventArgs &touch){ // preset? - + + /* ballses everything for some reason + TwoVector centre = TwoVector(getWidth()*0.5,getHeight()*0.5); + // if near centre + if((touch.x < centre.x+10) && (touch.x > centre.x-10) && (touch.y < centre.y+10) && (touch.y > centre.y-10)){ + numActiveTouches = 0; // dirty + presetManager.showNameDialog(); + + } + */ + } //--------------------------------------------------------------