# HG changeset patch # User Robert Tubb # Date 1431442132 -3600 # Node ID d5758530a0394fff5e6ab4be9086a4e28ae55610 # Parent 4ba81a12b00834d609b9068ed113ad0c244bd186 oF0.84 Retina, and iPhone support diff -r 4ba81a12b008 -r d5758530a039 main.mm --- a/main.mm Mon Jul 14 16:26:30 2014 +0100 +++ b/main.mm Tue May 12 15:48:52 2015 +0100 @@ -7,7 +7,20 @@ int main(){ //ofSetupOpenGL(480,320, OF_FULLSCREEN); // <-------- setup the GL context - ofSetupOpenGL(1024,768, OF_FULLSCREEN); - ofRunApp(new testApp); + //ofSetupOpenGL(1024,768, OF_FULLSCREEN); + //ofRunApp(new testApp); + + + ofAppiOSWindow * window = new ofAppiOSWindow(); + window->enableHardwareOrientation(); + window->enableOrientationAnimation(); + window->enableAntiAliasing(4); + window->enableDepthBuffer(); + window->enableRetina(); + + ofSeedRandom(); + + ofSetupOpenGL(window, 768, 1024,OF_FULLSCREEN); + ofRunApp(new testApp); } diff -r 4ba81a12b008 -r d5758530a039 mesh.mm --- a/mesh.mm Mon Jul 14 16:26:30 2014 +0100 +++ b/mesh.mm Tue May 12 15:48:52 2015 +0100 @@ -481,7 +481,7 @@ if(sqrt(k/m) > 0.9){ m = k/0.9; } - cout << "k/m = " << k/m << endl; + //cout << "k/m = " << k/m << endl; double im = 1/aM; for(int i = 0; i < lumps.size(); i++){ lumps[i].setInvMass(im); diff -r 4ba81a12b008 -r d5758530a039 testApp.h --- a/testApp.h Mon Jul 14 16:26:30 2014 +0100 +++ b/testApp.h Tue May 12 15:48:52 2015 +0100 @@ -1,13 +1,14 @@ -// oF 072 +// oF 084 +// V 1.3sonic #ifndef _TEST_APP #define _TEST_APP #include "ofMain.h" -#include "ofxiPhone.h" -#include "ofxiPhoneExtras.h" -#include "ofxiPhoneExternalDisplay.h" -#include "ofxiPhoneAppDelegate.h" + + +#include "ofxiOS.h" +#include "ofxiOSExtras.h" #include "2dvector.h" #include "lump.h" @@ -36,7 +37,7 @@ -class testApp : public ofxiPhoneApp, public ofxiPhoneExternalDisplay, public ofxMidiListener, public ofxMidiConnectionListener { +class testApp : public ofxiOSApp, public ofxMidiListener, public ofxMidiConnectionListener { public: int timesOpened; @@ -80,7 +81,8 @@ void removeTouch(); void UIcallBack(int buttID); - + void showControls(); + void hideControls(); void keyPressed (int key); void keyReleased(int key); diff -r 4ba81a12b008 -r d5758530a039 testApp.mm --- 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(); } }