diff testApp.mm @ 5:5ee5ef99e117

presets have "icons" and save OK. Snapping works. move velocity still frustrating.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Wed, 05 Dec 2012 18:42:02 +0000
parents 7541aeaebcdc
children 34eba1046890
line wrap: on
line diff
--- a/testApp.mm	Tue Dec 04 18:36:00 2012 +0000
+++ b/testApp.mm	Wed Dec 05 18:42:02 2012 +0000
@@ -17,7 +17,7 @@
 	sender.setup( HOST, PORT );
     ofSetFrameRate(30);
     // reciever
-    
+    framesSinceLastScroll = 0;
     
     prevTouchX = 0;
     prevTouchY = 0;
@@ -84,6 +84,8 @@
 	// setup OF sound stream
 	ofSoundStreamSetup(2, 1, this, 44100, ofxPd::blockSize()*ticksPerBuffer, 3);
     
+    presetManager.startupLoadAll();
+    
 }
 #pragma mark GUI
 //--------------------------------------------------------------
@@ -130,6 +132,7 @@
             string name = n.str();
             
             presetManager.addPreset(theGridView.getCoord(),name);
+            eventLogger.logEvent(SAVE_PRESET, theGridView.getCoord());
         }
         /*
         if(!keyboard->isKeyboardShowing()){
@@ -149,23 +152,33 @@
             cout << "LOCK SEQUENCE (X)\n";
             // lock
             xLocked = !xLocked;
+        presetManager.clearAll();
 
     }else if(e.widget->getName() == "LOCK SYNTH (Y)")
     {
         
         cout << "LOCK SYNTH (Y)\n";
         // lock
-        
-        yLocked = !yLocked;
+        if(((ofxUIButton *)e.widget)->getValue()){
+            yLocked = true;
+        }else{
+            yLocked = false;
+            
+        }
     }else if(e.widget->getName() == "ZOOM MIN")
     {
         if(((ofxUIButton *)e.widget)->getValue()){
         cout << "ZOOM MIN\n";
+            theGridView.setMinZoom();
+            eventLogger.logEvent(SET_MIN_ZOOM);
         }
     }else if(e.widget->getName() == "ZOOM MAX")
     {
         if(((ofxUIButton *)e.widget)->getValue()){
         cout << "ZOOM MAX\n";
+            theGridView.setMaxZoom();
+            eventLogger.logEvent(SET_MAX_ZOOM);
+            //eventLogger.printAll();
         }
     }else{
         cout << "GUI error :  unknown event recieved\n";
@@ -225,6 +238,8 @@
             ofxUISlider *slider = (ofxUISlider *) e.widget;
             sliderMoved(i-1,slider->getScaledValue()); // internal array 0 indexed
             
+            
+            
         }
     }
     
@@ -240,6 +255,9 @@
     // TODO if <5 do frequencer stuff and send list to PD
     // if > 5 send control value to PD
     sendParametersToPD();
+    
+    eventLogger.logEvent(CHANGE_SLIDER, which , value);
+    
 }
 //--------------------------------------------------------------
 void testApp::setAllGUISliders(vector<int> vals){
@@ -295,23 +313,24 @@
 		sender.sendMessage( m );
 	}
     
-    // continiue to move at velocity
+    // continiue to move at velocity, unless snapped
     
     if (numActiveTouches == 0){ // no touches, use momentum
         // TODO set velocity to 0 when hits walls
 
-        if(moveVel.norm() > 0.1){
+        if(moveVel.norm() > 0.3 && !theGridView.snapped){
             theGridView.move(moveVel);
             moveVel = moveVel*slowFactor;
          
          // and get new parameter values
-            if(standardGUIShowing)setAllGUISliders(theGridView.getParams());
+            setAllGUISliders(theGridView.getParams());
             sendParametersToPD();
-        }else if(moveVel.norm() > 0.01){
+        }else if(moveVel.norm() > 0.01 || theGridView.snapped){
             // stop it
             moveVel.setCoord(0.0,0.0);
-            if(standardGUIShowing)setAllGUISliders(theGridView.getParams());
+            setAllGUISliders(theGridView.getParams());
             sendParametersToPD();
+            eventLogger.logEvent(SCROLL_STOPPED, theGridView.getCoord() );
         }else{
             // stopped - do nothing
         }
@@ -322,6 +341,7 @@
         theGridView.zoom(zoomVel + 1.0); // +1 because zoomVel factor is + or - , wheras zoom is a multiplier near 1 
         zoomVel = zoomVel*slowFactor;
     }
+    framesSinceLastScroll++;
 }
 //--------------------------------------------------------------
 void testApp::sendOSCParams(){
@@ -428,20 +448,31 @@
    
     
 }
+
 //--------------------------------------------------------------
 void testApp::handleScroll(){
+ 
     
     TwoVector move = touch0 - prevTouch0;
-    moveVel = move*0.3 + prevMove*0.34 + prevMove2*0.38; // broke?
+    if(yLocked){
+        move.y = 0.0;
+    }
+    if(xLocked){
+        move.x = 0.0;
+    }
+
+    moveVel = (move*0.3 + prevMove*0.34 + prevMove2*0.38)* (1.0/(float)framesSinceLastScroll); // use the time
+
     prevMove2 = prevMove;
     prevMove = move;
     
+
     theGridView.move(move);
     
     // and get new parameter values
     setAllGUISliders(theGridView.getParams());
     sendParametersToPD();
-    
+    framesSinceLastScroll = 0;
 }
 //--------------------------------------------------------------
 void testApp::handleZoom(){