diff testApp.mm @ 15:d5758530a039 tip

oF0.84 Retina, and iPhone support
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Tue, 12 May 2015 15:48:52 +0100
parents 4ba81a12b008
children
line wrap: on
line diff
--- a/testApp.mm	Mon Jul 14 16:26:30 2014 +0100
+++ b/testApp.mm	Tue May 12 15:48:52 2015 +0100
@@ -43,7 +43,7 @@
  
  band limited touch points (invisible springs connecting to mesh?)
 
- 
+ iphone
  */
 extern GlobalForces globalForces;
 extern GlobalUI globalUI;
@@ -110,17 +110,20 @@
     
     globalUI.touchMode = globalUI.GRAB;
     scanPath.scanMode = scanPath.DISPLACEMENT;
-    
+    globalUI.borderSize = ofGetWidth()/8;
     ofSoundStreamStart();
 
     paused = false;
     audioOn = true;
     
-    ofxiPhoneExternalDisplay::mirrorOn();
+    //ofxiPhoneExternalDisplay::mirrorOn();
     
+    cout << "Width: " << ofGetWidth() << endl;
+    cout << "Height: " << ofGetHeight() << endl;
     
-
-    
+    // stupid hack for control vis
+    hideControls();
+    showControls();
     //[ofxiPhoneGetGLView() updateDimensions];
     
     
@@ -320,12 +323,12 @@
 
     }
      handleMessages(); // !?!??   
-    if(ofxiPhoneExternalDisplay::isExternalScreenConnected()){
-        if(!ofxiPhoneExternalDisplay::isMirroring()){
-            ofxiPhoneExternalDisplay::mirrorOn();
-            //printf("turned on Mirroring!\n");
-        }
-    }
+//    if(ofxiPhoneExternalDisplay::isExternalScreenConnected()){
+//        if(!ofxiPhoneExternalDisplay::isMirroring()){
+//            ofxiPhoneExternalDisplay::mirrorOn();
+//            //printf("turned on Mirroring!\n");
+//        }
+//    }
     
 }
 
@@ -338,15 +341,15 @@
     if(controlsShowing){
         drawSidePanels();
     }else{
-        scanPath.draw(); // uncomment if you want to see the output waveform
+        if (!controlsShowing) scanPath.draw(); // uncomment if you want to see the output waveform
     }
 }
 //--------------------------------------------------------------
 // background for UI
 void testApp::drawSidePanels(){
     ofSetColor(123, 123, 123);
-    ofRect(0, 0, 128, ofGetHeight());
-    ofRect(ofGetWidth()-128, 0, 128, ofGetHeight());
+    ofRect(0, 0, globalUI.borderSize, ofGetHeight());
+    ofRect(ofGetWidth()-globalUI.borderSize, 0, globalUI.borderSize, ofGetHeight());
 }
 //--------------------------------------------------------------
 void testApp::drawMessages(){
@@ -1373,53 +1376,86 @@
 //--------------------------------------------------------------
 void testApp::setupGui(){
     float xInit = OFX_UI_GLOBAL_WIDGET_SPACING;
-    float length = 128-xInit*2;
     
+    int heightS = ofGetHeight();
+    int widthS = ofGetWidth();
     
-    float dim = 42;
+    float sidebarWidth = widthS/8;
+    float length = sidebarWidth-xInit*2;
     
+    
+    float widgetHeight = heightS/18;
+    
+    /*
+    setWidgetColor(OFX_UI_WIDGET_COLOR_BACK, cb);
+    setWidgetColor(OFX_UI_WIDGET_COLOR_OUTLINE, co);
+    setWidgetColor(OFX_UI_WIDGET_COLOR_OUTLINE_HIGHLIGHT, coh);
+    setWidgetColor(OFX_UI_WIDGET_COLOR_FILL, cf);
+    setWidgetColor(OFX_UI_WIDGET_COLOR_FILL_HIGHLIGHT, cfh);
+    setWidgetColor(OFX_UI_WIDGET_COLOR_PADDED, cp);
+    setWidgetColor(OFX_UI_WIDGET_COLOR_PADDED_OUTLINE, cpo);
+    */
+    
+    ofColor bgCol = ofColor(23,23,23);
+    ofColor paddingCol = ofColor(56,56,56);
+    ofColor padOutlineCol = ofColor(200,0,0);
+    ofColor fillCol = ofColor(0,0,205);
+    ofColor fillHicol = ofColor(0,0,255);
+    ofColor outlineCol = ofColor(255,255,255);
+    ofColor outlineHiCol = ofColor(255,255,255);
     // LEFT GUI ------------------
-    guiL = new ofxUICanvas(0,0,128,ofGetHeight());
+    
+    
+    guiL = new ofxUICanvas(0,0,sidebarWidth,heightS);
     guiL->addSpacer(length-xInit, 2);
+    //guiL->setUIColors(bgCol, outlineCol, outlineHiCol, fillCol, fillHicol, paddingCol, padOutlineCol);
+    
+    
     guiL->addWidgetDown(new ofxUILabel("Physics", OFX_UI_FONT_LARGE));
     
     ofxUIWidget *slider;
-    slider = guiL->addWidgetDown(new ofxUISlider(length,dim,0.0,0.8,0.4,"SPRING K"));
+    //ofxUISlider_<<#typename T#>>(<#string _name#>, <#T _min#>, <#T _max#>, <#T _value#>, <#float w#>, <#float h#>)
+    slider = guiL->addWidgetDown(new ofxUISlider("SPRING K",0.0,0.8,0.4,length,widgetHeight));
     slider->setDrawPadding(true);
-    slider->setColorFill(ofColor(0,0,255));
-    slider->setColorFillHighlight(ofColor(0,0,255));
+    slider->setDrawPaddingOutline(true);
+    slider->setColorFill(fillHicol);
+    slider->setColorFillHighlight(fillHicol);
     
-    slider = guiL->addWidgetDown(new ofxUISlider(length,dim, 0.0, 4.0, 0.0, "GRAVITY"));
+    slider = guiL->addWidgetDown(new ofxUISlider("GRAVITY", 0.0, 4.0, 0.0,length,widgetHeight ));
     slider->setDrawPadding(true);
-    slider->setColorFill(ofColor(0,0,255));
-    slider->setColorFillHighlight(ofColor(0,0,255));
-    
-    slider = guiL->addWidgetDown(new ofxUISlider(length,dim,0.0,0.3,0.0,"HOMING"));
+    slider->setDrawPaddingOutline(true);
+    slider->setColorFill(fillHicol);
+    slider->setColorFillHighlight(fillHicol);
+
+    slider = guiL->addWidgetDown(new ofxUISlider("HOMING",0.0,0.3,0.0,length,widgetHeight));
     slider->setDrawPadding(true);
-    slider->setColorFill(ofColor(0,0,255));
-    slider->setColorFillHighlight(ofColor(0,0,255));
-    
-    slider = guiL->addWidgetDown(new ofxUISlider(length,dim, 0.0, 0.5, 0.01, "SMOOTHING"));
+    slider->setDrawPaddingOutline(true);
+    slider->setColorFill(fillHicol);
+    slider->setColorFillHighlight(fillHicol);
+
+    slider = guiL->addWidgetDown(new ofxUISlider("SMOOTHING", 0.0, 0.5, 0.01,length,widgetHeight));
     slider->setDrawPadding(true);
-    slider->setColorFill(ofColor(0,0,255));
-    slider->setColorFillHighlight(ofColor(0,0,255));
-    
+    slider->setDrawPaddingOutline(true);
+    slider->setColorFill(fillHicol);
+    slider->setColorFillHighlight(fillHicol);
     
     
     guiL->addSpacer(length-xInit, 2);
+
     
-    
-    guiL->setWidgetPosition(OFX_UI_WIDGET_POSITION_DOWN);
-	slider = guiL->addSlider("PITCH", 2.0, 100.0, 80.0, length, 370);
+    //guiL->setWidgetPosition(OFX_UI_WIDGET_POSITION_DOWN);
+	slider = guiL->addSlider("PITCH", 2.0, 100.0, 80.0, length, heightS/2);
     slider->setDrawPadding(true);
-    slider->setColorFill(ofColor(0,0,255));
-    slider->setColorFillHighlight(ofColor(0,0,255));
-    
+    slider->setDrawPaddingOutline(true);
+    slider->setColorFill(fillHicol);
+    slider->setColorFillHighlight(fillHicol);
+
     ofAddListener(guiL->newGUIEvent, this, &testApp::guiLEvent);
     
-    // RIGHT GUI -----------------------
+    //guiL->setUIColors( ofColor(56,56,56), ofColor(255,255,56), ofColor(255,255,56), ofColor(0,0,255), ofColor(0,0,255), ofColor(0,0,255), ofColor(0,0,255) );
+     // RIGHT GUI -----------------------
     
-    guiR = new ofxUICanvas(ofGetWidth()-128, 0, 128, ofGetHeight()-64);
+    guiR = new ofxUICanvas(ofGetWidth()-sidebarWidth, 0, sidebarWidth, ofGetHeight()-64);
     
     
     guiR->addSpacer(length-xInit, 2);
@@ -1434,34 +1470,37 @@
     
     
     ofxUIRadio* radio;
-    radio = guiR->addRadio("TOUCH MODE", names, OFX_UI_ORIENTATION_VERTICAL, dim, dim);
+    radio = guiR->addRadio("TOUCH MODE", names, OFX_UI_ORIENTATION_VERTICAL, widgetHeight, widgetHeight);
     radio->setDrawPadding(true);
-    radio->setColorFill(ofColor(0,0,255));
-    radio->setColorFillHighlight(ofColor(0,0,255));
+    radio->setColorFill(fillHicol);
+    radio->setColorFillHighlight(fillHicol);
     
-    slider = guiR->addWidgetDown(new ofxUISlider(length,dim, -0.4, 4.0, 1.0, "TOUCH AMT"));
+    slider = guiR->addWidgetDown(new ofxUISlider( "TOUCH AMT", -0.4, 4.0, 1.0,length,widgetHeight));
     slider->setDrawPadding(true);
-    slider->setColorFill(ofColor(0,0,255));
-    slider->setColorFillHighlight(ofColor(0,0,255));
+    slider->setColorFill(fillHicol);
+    slider->setColorFillHighlight(fillHicol);
     
     guiR->addSpacer(length-xInit, 2);
     
-    guiR->addToggle("PAUSE", false, dim, dim);
-    guiR->addButton("RESET", false, dim, dim);
-    guiR->addButton("NEW", false, dim, dim);
-    guiR->addButton("SAVE", false, dim, dim);
-    guiR->addButton("LOAD", false, dim, dim);
+    guiR->addToggle("PAUSE", false, widgetHeight, widgetHeight);
+    guiR->addButton("RESET", false, widgetHeight, widgetHeight);
+    guiR->addButton("NEW", false, widgetHeight, widgetHeight);
+    guiR->addButton("SAVE", false, widgetHeight, widgetHeight);
+    guiR->addButton("LOAD", false, widgetHeight, widgetHeight);
     
     ofAddListener(guiR->newGUIEvent, this, &testApp::guiREvent);
     //guiR->loadSettings(ofxiPhoneGetDocumentsDirectory() + "guiSettings.xml");
     radio->activateToggle("GRAB");
     
     // show hide ctrls
-    guiSH = new ofxUICanvas(ofGetWidth()-128, ofGetHeight()-64, 128, 64);
+    guiSH = new ofxUICanvas(ofGetWidth() - sidebarWidth, ofGetHeight()-64, sidebarWidth, 64);
     
     
     guiSH->addSpacer(length-xInit, 2);
-    guiSH->addToggle("CTRLS", false, dim, dim);
+    ofxUIToggle* t = guiSH->addToggle("CTRLS", false, widgetHeight, widgetHeight);
+    // turn toggle on
+    t->setState(true);
+    
     ofAddListener(guiSH->newGUIEvent, this, &testApp::guiSHEvent);
     
 }
@@ -1470,6 +1509,18 @@
     cout << " BUTT ID " << buttID << "\n";
     
 }
+void testApp::hideControls(){
+    cout << "CTRLS ooff";
+    guiR->setVisible(false);
+    guiL->setVisible(false);
+    controlsShowing = false;
+}
+void testApp::showControls(){
+    cout << "CTRLS onnn";
+    guiR->setVisible(true);
+    guiL->setVisible(true);
+    controlsShowing = true;
+}
 //--------------------------------------------------------------
 void testApp::guiSHEvent(ofxUIEventArgs &e)
 {
@@ -1479,15 +1530,9 @@
         cout << ((ofxUIButton *)e.widget)->getValue();
         
         if( ((ofxUIButton *)e.widget)->getValue() == 0) {
-            cout << "CTRLS oofff";
-            guiR->setVisible(false);
-            guiL->setVisible(false);
-            controlsShowing = false;
+            hideControls();
         }else{
-            cout << "CTRLS onnn";
-            guiR->setVisible(true);
-            guiL->setVisible(true);
-            controlsShowing = true;
+            showControls();
         }
         
     }