Mercurial > hg > soniczoomios
diff testApp.mm @ 1:23efe1f0cd8a
work on event logging
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Thu, 22 Nov 2012 17:59:13 +0000 |
parents | 307e5fb699fb |
children | fcb512cef986 |
line wrap: on
line diff
--- a/testApp.mm Mon Nov 19 12:56:47 2012 +0000 +++ b/testApp.mm Thu Nov 22 17:59:13 2012 +0000 @@ -1,9 +1,11 @@ #include "testApp.h" #include "grid.h" #include "presetManager.h" +#include "eventLogger.h" extern Grid theGridView; extern PresetManager presetManager; +extern EventLogger eventLogger; //-------------------------------------------------------------- void testApp::setup(){ ofSetOrientation(OF_ORIENTATION_90_LEFT); @@ -54,11 +56,13 @@ ofxiPhoneSetOrientation( OF_ORIENTATION_90_RIGHT ); + + } //-------------------------------------------------------------- void testApp::setupZoomGui(){ zoomGUI = new ofxUICanvas(ofGetWidth()-200,0,190,125); - zoomGUI->setTheme(OFX_UI_THEME_HIPSTER); + zoomGUI->setTheme(OFX_UI_THEME_HACKER ); ofxUIWidget *bwidge = zoomGUI->addLabelToggle("SWITCH VIEW", false); @@ -138,8 +142,14 @@ ofxUISlider *slider; slider = (ofxUISlider *)standardGUI->addWidgetDown(new ofxUISlider(length,dim,0.0,127,64,ss.str())); slider->setDrawPadding(true); - slider->setColorFill(ofColor(0,0,255)); - slider->setColorFillHighlight(ofColor(0,0,255)); + if(i <= 5){ + slider->setColorFill(ofColor(0,0,255)); + slider->setColorFillHighlight(ofColor(0,0,255)); + }else{ + slider->setColorFill(ofColor(255,0,0)); + slider->setColorFillHighlight(ofColor(255,0,0)); + } + sliders.push_back(slider); } @@ -179,8 +189,8 @@ //-------------------------------------------------------------- void testApp::setGUISliders(vector<int> vals){ for(int i = 0; i<10;i++){ - // uh shit need to have reference to this lot sliders[i]->setValue(vals[i]); + sliderVals[i] = vals[i]; } } //-------------------------------------------------------------- @@ -211,8 +221,9 @@ theGridView.update(); vector<int> params = theGridView.getParams(); // FILTER HERE? NEED FLOATS... setGUISliders(params); + // sendOSCParams(); - + // sendMIDIParams(); } //-------------------------------------------------------------- void testApp::sendOSCParams(){ @@ -239,8 +250,8 @@ } theGridView.draw(); - ofSetColor(20, 160, 240, 255); - ofDrawBitmapString("text entered = "+ keyboard->getText() , 2, 70); + //ofSetColor(20, 160, 240, 255); + //ofDrawBitmapString("text entered = "+ keyboard->getText() , 2, 70); } //-------------------------------------------------------------- @@ -284,13 +295,17 @@ //-------------------------------------------------------------- void testApp::touchMoved(ofTouchEventArgs &touch){ + + //cout << "touch id " << touch.id << "\n"; + //cout << "active touches " << numActiveTouches << "\n"; + + if(standardGUIShowing){ // check if in GUI area if(touch.x < 256) return; } - // - // which one? + // which one? keep track of each touch point if(touch.id == 0){ touch0.setCoord(touch.x,touch.y); @@ -299,62 +314,61 @@ touch1.setCoord(touch.x,touch.y); } + if(numActiveTouches == 1){ - //cout << "touch id " << touch.id << "\n"; - //cout << "active touches " << numActiveTouches << "\n"; - - - if(numActiveTouches == 1){ - // TODO: when num touches goes down to 1 after zoom prevTouch can be hugely different! - - TwoVector move = touch0 - prevTouch0; - moveVel = move*0.3 + prevMove*0.34 + prevMove2*0.38; // broke? - prevMove2 = prevMove; - prevMove = move; - - theGridView.move(move.x,move.y); - - - + handleScroll(); }else if(numActiveTouches == 2){ - // work out change in difference - double dist = touch1.distanceTo(touch0); - double zoomFactor = prevDist/dist; - - cout << "Zoom: " << zoomFactor << "\n"; - //TODO check for sensible maximums, e.g. spurious touch data - if(zoomFactor > 2.0 || zoomFactor < 0.5){ - cout << "Zoom too much!!!!" << zoomFactor; - zoomFactor = 1.0; - } - - zoomVel = (zoomFactor-1)*0.3 + prevZoom*0.34 + prevZoom2*0.38; - prevZoom2 = prevZoom; - prevZoom = (zoomFactor-1); - - theGridView.zoom(zoomFactor); - - prevDist = dist; - // TODO: when num touches goes down to 1 after zoom prevTouch can be hugely different! - // also if try to move with other finger after zoom , this is touch1 :( - // prevTouch0 = ??? + handleZoom(); } prevTouch0 = touch0; } - +//-------------------------------------------------------------- +void testApp::handleScroll(){ + + TwoVector move = touch0 - prevTouch0; + moveVel = move*0.3 + prevMove*0.34 + prevMove2*0.38; // broke? + prevMove2 = prevMove; + prevMove = move; + + theGridView.move(move.x,move.y); +} +//-------------------------------------------------------------- +void testApp::handleZoom(){ + // work out change in difference + double dist = touch1.distanceTo(touch0); + double zoomFactor = prevDist/dist; + + //TODO check for sensible maximums, e.g. spurious touch data + if(zoomFactor > 2.0 || zoomFactor < 0.5){ + cout << "Zoom too much!!!!" << zoomFactor; + zoomFactor = 1.0; + } + + zoomVel = (zoomFactor-1)*0.3 + prevZoom*0.34 + prevZoom2*0.38; + prevZoom2 = prevZoom; + prevZoom = (zoomFactor-1); + + theGridView.zoom(zoomFactor); + + prevDist = dist; + // TODO: when num touches goes down to 1 after zoom prevTouch can be hugely different! + // also if try to move with other finger after zoom , this is touch1 :( + // prevTouch0 = ??? +} //-------------------------------------------------------------- void testApp::touchUp(ofTouchEventArgs &touch){ + if(numActiveTouches > 0) numActiveTouches--; // dirty + if(standardGUIShowing){ // check if in GUI area if(touch.x < 256) - if(numActiveTouches > 0) numActiveTouches--; // dirty + return; } - - numActiveTouches--; + // which one? if(touch.id == 0){ // tricky situation - we tried to zoom but may have left non-move finger on