Mercurial > hg > soniczoomios
diff testApp.mm @ 27:ae4d2c3ce5e0
Details. Zoom trailing finger move sorted. Qs rephrased.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Wed, 13 Feb 2013 17:03:56 +0000 |
parents | 2e1fdac115af |
children | e2c62db1e265 |
line wrap: on
line diff
--- a/testApp.mm Fri Feb 01 18:31:43 2013 +0000 +++ b/testApp.mm Wed Feb 13 17:03:56 2013 +0000 @@ -42,7 +42,7 @@ prevTouch1.setCoord(10,20); prevDist = 10; slowFactor = 0.98; - + preventingMovePostScroll = false; // the 5 harmonics for the frequencer freqIndexes.push_back(0); @@ -96,6 +96,11 @@ usernameAlertViewController = [[UsernameAlertViewController alloc] init]; + helpViewController = [[HelpViewController alloc] initWithNibName:@"HelpViewController" bundle:nil]; + [ofxiPhoneGetGLParentView() addSubview:helpViewController.view]; + [helpViewController setAppRef:(id)this]; + helpViewController.view.hidden = YES; + /* sliderViewController = [[SliderViewController alloc] initWithNibName:@"SLiderViewController" bundle:nil]; [ofxiPhoneGetGLParentView() addSubview:sliderViewController.view]; @@ -110,7 +115,8 @@ presetManager.startupLoadAll(); eventLogger.init(); - whichInterfaceShowing = BOTH; + whichInterfaceShowing = SLIDERS; + setAllGUISliders(theGridView.getParams()); // GO paused = false; @@ -187,12 +193,11 @@ // if(eventLogger.questionnaireCompleted) return; - paused = true; + paused = true; // need to set button + [topButtonViewController pausePressed:(id)this]; //stopSequencer - core.pd.startMessage(); - core.pd.addFloat(0); - core.pd.finishMessage("fromOF", "seqStartStop"); + seqStartStop(false); questionnaireViewController = [[QuestionnaireViewController alloc] initWithNibName:@"QuestionnaireViewController" bundle:nil]; [ofxiPhoneGetGLParentView() addSubview:questionnaireViewController.view]; @@ -211,11 +216,7 @@ // set "we've done questionnaire" to true in event logger paused = false; - - //startSequencer (TODO what about the toggle ? ?) - core.pd.startMessage(); - core.pd.addFloat(1); - core.pd.finishMessage("fromOF", "seqStartStop"); + whichInterfaceShowing = BOTH; // tell bottomtabviewcontroller @@ -239,7 +240,6 @@ //-------------------------------------------------------------- void testApp::introHidden(bool OK){ if(OK){ - paused = false; eventLogger.consentGiven = true; whichInterfaceShowing = BOTH; // show username prompt @@ -369,6 +369,19 @@ eventLogger.logEvent(RANDOMISE, theGridView.getCoord() ,0.0); } +//- +void testApp::showHelp(){ + paused = true; + seqStartStop(false); + [topButtonViewController pausePressed:(id)this]; + helpViewController.view.hidden = NO; + eventLogger.logEvent(HELP_PRESSED); +} +void testApp::helpHidden(){ + paused = false; + // start seq? + +} //-------------------------------------------------------------- void testApp::sendParametersToPD(){ // frequencer stuff to get 16 steps @@ -398,22 +411,18 @@ sendModFreq(sliderVals[9]); } +void testApp::setupNewUser(){ + // this function is for supervised trials with my ipad + eventLogger.newUser(); +} //-------------------------------------------------------------- #pragma mark STANDARD OF FUNCTIONS //-------------------------------------------------------------- void testApp::update(){ - //we do a heartbeat on iOS as the phone will shut down the network connection to save power - //this keeps the network alive as it thinks it is being used. + if(paused) return; - if( ofGetFrameNum() % 120 == 0 ){ - ofxOscMessage m; - m.setAddress( "/misc/heartbeat" ); - m.addIntArg( ofGetFrameNum() ); - sender.sendMessage( m ); - } - - // continiue to move at velocity, unless snapped + // continiue to move or zoom at velocity, unless snapped if (numActiveTouches == 0){ // no touches, use momentum @@ -484,14 +493,12 @@ break; } - } //-------------------------------------------------------------- void testApp::touchDown(ofTouchEventArgs &touch){ - - // TODO check if in gui area!!! + // in slider gui area? if(whichInterfaceShowing == SLIDERS){ return; }else if (whichInterfaceShowing == BOTH && touch.x < (SLIDER_GUI_WIDTH+10)){ @@ -500,8 +507,8 @@ }// otherwise we're good to let the zoomer handle touch numActiveTouches++; - // absolute position doesn't matter - // which one? + preventingMovePostScroll = false; + if(touch.id == 0){ touch0.setCoord(touch.x,touch.y); prevTouch0 = touch0; @@ -515,6 +522,7 @@ moveVel.setCoord(0.0, 0.0); prevMove.setCoord(0.0, 0.0); prevMove2.setCoord(0.0, 0.0); + }else if(numActiveTouches == 2){ zoomVel = 0.0; prevZoom = 0.0; @@ -534,13 +542,9 @@ }else if (whichInterfaceShowing == BOTH && touch.x < (SLIDER_GUI_WIDTH+10)){ return; - }// otherwise we're good to let the zoomer handle touch + } - - // check if in other gui area - if(touch.x > getWidth()-200 && touch.y < 300){ - return; - } + // otherwise we're good to let the zoomer handle touch // which one? keep track of each touch point if(touch.id == 0){ @@ -552,7 +556,7 @@ } if(numActiveTouches == 1){ - + if(preventingMovePostScroll) return; handleScroll(); }else if(numActiveTouches == 2){ handleZoom(); @@ -564,6 +568,7 @@ } //-------------------------------------------------------------- +// handle a finger being dragged void testApp::handleScroll(){ TwoVector move = touch0 - prevTouch0; @@ -596,6 +601,7 @@ sendParametersToPD(); } //-------------------------------------------------------------- +// handle pinch movememnt void testApp::handleZoom(){ // work out change in difference double dist = touch1.distanceTo(touch0); @@ -619,7 +625,7 @@ //-------------------------------------------------------------- void testApp::touchUp(ofTouchEventArgs &touch){ if(numActiveTouches > 0) numActiveTouches--; // dirty - + preventingMovePostScroll = false; // TODO check if in gui area!!! if(whichInterfaceShowing == SLIDERS){ return; @@ -651,6 +657,10 @@ } lastMoveTime = moveTime; + }else if (numActiveTouches == 1){ + // just zoomed , but now lifted one of the fingers + // can be bad if moved so create special mode to stop scroll (special modes bad!) + preventingMovePostScroll = true; } }