Mercurial > hg > wabletios
comparison 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 |
comparison
equal
deleted
inserted
replaced
14:4ba81a12b008 | 15:d5758530a039 |
---|---|
41 | 41 |
42 floating scan path, with interpolation | 42 floating scan path, with interpolation |
43 | 43 |
44 band limited touch points (invisible springs connecting to mesh?) | 44 band limited touch points (invisible springs connecting to mesh?) |
45 | 45 |
46 | 46 iphone |
47 */ | 47 */ |
48 extern GlobalForces globalForces; | 48 extern GlobalForces globalForces; |
49 extern GlobalUI globalUI; | 49 extern GlobalUI globalUI; |
50 extern ScanPath scanPath; | 50 extern ScanPath scanPath; |
51 extern PresetAlertViewController *presetAlertViewController; | 51 extern PresetAlertViewController *presetAlertViewController; |
108 setupMesh(); | 108 setupMesh(); |
109 scanPath.init(); | 109 scanPath.init(); |
110 | 110 |
111 globalUI.touchMode = globalUI.GRAB; | 111 globalUI.touchMode = globalUI.GRAB; |
112 scanPath.scanMode = scanPath.DISPLACEMENT; | 112 scanPath.scanMode = scanPath.DISPLACEMENT; |
113 | 113 globalUI.borderSize = ofGetWidth()/8; |
114 ofSoundStreamStart(); | 114 ofSoundStreamStart(); |
115 | 115 |
116 paused = false; | 116 paused = false; |
117 audioOn = true; | 117 audioOn = true; |
118 | 118 |
119 ofxiPhoneExternalDisplay::mirrorOn(); | 119 //ofxiPhoneExternalDisplay::mirrorOn(); |
120 | 120 |
121 | 121 cout << "Width: " << ofGetWidth() << endl; |
122 | 122 cout << "Height: " << ofGetHeight() << endl; |
123 | 123 |
124 // stupid hack for control vis | |
125 hideControls(); | |
126 showControls(); | |
124 //[ofxiPhoneGetGLView() updateDimensions]; | 127 //[ofxiPhoneGetGLView() updateDimensions]; |
125 | 128 |
126 | 129 |
127 } | 130 } |
128 | 131 |
318 | 321 |
319 } | 322 } |
320 | 323 |
321 } | 324 } |
322 handleMessages(); // !?!?? | 325 handleMessages(); // !?!?? |
323 if(ofxiPhoneExternalDisplay::isExternalScreenConnected()){ | 326 // if(ofxiPhoneExternalDisplay::isExternalScreenConnected()){ |
324 if(!ofxiPhoneExternalDisplay::isMirroring()){ | 327 // if(!ofxiPhoneExternalDisplay::isMirroring()){ |
325 ofxiPhoneExternalDisplay::mirrorOn(); | 328 // ofxiPhoneExternalDisplay::mirrorOn(); |
326 //printf("turned on Mirroring!\n"); | 329 // //printf("turned on Mirroring!\n"); |
327 } | 330 // } |
328 } | 331 // } |
329 | 332 |
330 } | 333 } |
331 | 334 |
332 //-------------------------------------------------------------- | 335 //-------------------------------------------------------------- |
333 void testApp::draw(){ | 336 void testApp::draw(){ |
336 theMesh->draw(); | 339 theMesh->draw(); |
337 } | 340 } |
338 if(controlsShowing){ | 341 if(controlsShowing){ |
339 drawSidePanels(); | 342 drawSidePanels(); |
340 }else{ | 343 }else{ |
341 scanPath.draw(); // uncomment if you want to see the output waveform | 344 if (!controlsShowing) scanPath.draw(); // uncomment if you want to see the output waveform |
342 } | 345 } |
343 } | 346 } |
344 //-------------------------------------------------------------- | 347 //-------------------------------------------------------------- |
345 // background for UI | 348 // background for UI |
346 void testApp::drawSidePanels(){ | 349 void testApp::drawSidePanels(){ |
347 ofSetColor(123, 123, 123); | 350 ofSetColor(123, 123, 123); |
348 ofRect(0, 0, 128, ofGetHeight()); | 351 ofRect(0, 0, globalUI.borderSize, ofGetHeight()); |
349 ofRect(ofGetWidth()-128, 0, 128, ofGetHeight()); | 352 ofRect(ofGetWidth()-globalUI.borderSize, 0, globalUI.borderSize, ofGetHeight()); |
350 } | 353 } |
351 //-------------------------------------------------------------- | 354 //-------------------------------------------------------------- |
352 void testApp::drawMessages(){ | 355 void testApp::drawMessages(){ |
353 for ( int i=0; i<NUM_MSG_STRINGS; i++ ) | 356 for ( int i=0; i<NUM_MSG_STRINGS; i++ ) |
354 { | 357 { |
1371 | 1374 |
1372 } | 1375 } |
1373 //-------------------------------------------------------------- | 1376 //-------------------------------------------------------------- |
1374 void testApp::setupGui(){ | 1377 void testApp::setupGui(){ |
1375 float xInit = OFX_UI_GLOBAL_WIDGET_SPACING; | 1378 float xInit = OFX_UI_GLOBAL_WIDGET_SPACING; |
1376 float length = 128-xInit*2; | 1379 |
1377 | 1380 int heightS = ofGetHeight(); |
1378 | 1381 int widthS = ofGetWidth(); |
1379 float dim = 42; | 1382 |
1380 | 1383 float sidebarWidth = widthS/8; |
1384 float length = sidebarWidth-xInit*2; | |
1385 | |
1386 | |
1387 float widgetHeight = heightS/18; | |
1388 | |
1389 /* | |
1390 setWidgetColor(OFX_UI_WIDGET_COLOR_BACK, cb); | |
1391 setWidgetColor(OFX_UI_WIDGET_COLOR_OUTLINE, co); | |
1392 setWidgetColor(OFX_UI_WIDGET_COLOR_OUTLINE_HIGHLIGHT, coh); | |
1393 setWidgetColor(OFX_UI_WIDGET_COLOR_FILL, cf); | |
1394 setWidgetColor(OFX_UI_WIDGET_COLOR_FILL_HIGHLIGHT, cfh); | |
1395 setWidgetColor(OFX_UI_WIDGET_COLOR_PADDED, cp); | |
1396 setWidgetColor(OFX_UI_WIDGET_COLOR_PADDED_OUTLINE, cpo); | |
1397 */ | |
1398 | |
1399 ofColor bgCol = ofColor(23,23,23); | |
1400 ofColor paddingCol = ofColor(56,56,56); | |
1401 ofColor padOutlineCol = ofColor(200,0,0); | |
1402 ofColor fillCol = ofColor(0,0,205); | |
1403 ofColor fillHicol = ofColor(0,0,255); | |
1404 ofColor outlineCol = ofColor(255,255,255); | |
1405 ofColor outlineHiCol = ofColor(255,255,255); | |
1381 // LEFT GUI ------------------ | 1406 // LEFT GUI ------------------ |
1382 guiL = new ofxUICanvas(0,0,128,ofGetHeight()); | 1407 |
1408 | |
1409 guiL = new ofxUICanvas(0,0,sidebarWidth,heightS); | |
1383 guiL->addSpacer(length-xInit, 2); | 1410 guiL->addSpacer(length-xInit, 2); |
1411 //guiL->setUIColors(bgCol, outlineCol, outlineHiCol, fillCol, fillHicol, paddingCol, padOutlineCol); | |
1412 | |
1413 | |
1384 guiL->addWidgetDown(new ofxUILabel("Physics", OFX_UI_FONT_LARGE)); | 1414 guiL->addWidgetDown(new ofxUILabel("Physics", OFX_UI_FONT_LARGE)); |
1385 | 1415 |
1386 ofxUIWidget *slider; | 1416 ofxUIWidget *slider; |
1387 slider = guiL->addWidgetDown(new ofxUISlider(length,dim,0.0,0.8,0.4,"SPRING K")); | 1417 //ofxUISlider_<<#typename T#>>(<#string _name#>, <#T _min#>, <#T _max#>, <#T _value#>, <#float w#>, <#float h#>) |
1418 slider = guiL->addWidgetDown(new ofxUISlider("SPRING K",0.0,0.8,0.4,length,widgetHeight)); | |
1388 slider->setDrawPadding(true); | 1419 slider->setDrawPadding(true); |
1389 slider->setColorFill(ofColor(0,0,255)); | 1420 slider->setDrawPaddingOutline(true); |
1390 slider->setColorFillHighlight(ofColor(0,0,255)); | 1421 slider->setColorFill(fillHicol); |
1391 | 1422 slider->setColorFillHighlight(fillHicol); |
1392 slider = guiL->addWidgetDown(new ofxUISlider(length,dim, 0.0, 4.0, 0.0, "GRAVITY")); | 1423 |
1424 slider = guiL->addWidgetDown(new ofxUISlider("GRAVITY", 0.0, 4.0, 0.0,length,widgetHeight )); | |
1393 slider->setDrawPadding(true); | 1425 slider->setDrawPadding(true); |
1394 slider->setColorFill(ofColor(0,0,255)); | 1426 slider->setDrawPaddingOutline(true); |
1395 slider->setColorFillHighlight(ofColor(0,0,255)); | 1427 slider->setColorFill(fillHicol); |
1396 | 1428 slider->setColorFillHighlight(fillHicol); |
1397 slider = guiL->addWidgetDown(new ofxUISlider(length,dim,0.0,0.3,0.0,"HOMING")); | 1429 |
1430 slider = guiL->addWidgetDown(new ofxUISlider("HOMING",0.0,0.3,0.0,length,widgetHeight)); | |
1398 slider->setDrawPadding(true); | 1431 slider->setDrawPadding(true); |
1399 slider->setColorFill(ofColor(0,0,255)); | 1432 slider->setDrawPaddingOutline(true); |
1400 slider->setColorFillHighlight(ofColor(0,0,255)); | 1433 slider->setColorFill(fillHicol); |
1401 | 1434 slider->setColorFillHighlight(fillHicol); |
1402 slider = guiL->addWidgetDown(new ofxUISlider(length,dim, 0.0, 0.5, 0.01, "SMOOTHING")); | 1435 |
1436 slider = guiL->addWidgetDown(new ofxUISlider("SMOOTHING", 0.0, 0.5, 0.01,length,widgetHeight)); | |
1403 slider->setDrawPadding(true); | 1437 slider->setDrawPadding(true); |
1404 slider->setColorFill(ofColor(0,0,255)); | 1438 slider->setDrawPaddingOutline(true); |
1405 slider->setColorFillHighlight(ofColor(0,0,255)); | 1439 slider->setColorFill(fillHicol); |
1406 | 1440 slider->setColorFillHighlight(fillHicol); |
1407 | 1441 |
1408 | 1442 |
1409 guiL->addSpacer(length-xInit, 2); | 1443 guiL->addSpacer(length-xInit, 2); |
1410 | 1444 |
1411 | 1445 |
1412 guiL->setWidgetPosition(OFX_UI_WIDGET_POSITION_DOWN); | 1446 //guiL->setWidgetPosition(OFX_UI_WIDGET_POSITION_DOWN); |
1413 slider = guiL->addSlider("PITCH", 2.0, 100.0, 80.0, length, 370); | 1447 slider = guiL->addSlider("PITCH", 2.0, 100.0, 80.0, length, heightS/2); |
1414 slider->setDrawPadding(true); | 1448 slider->setDrawPadding(true); |
1415 slider->setColorFill(ofColor(0,0,255)); | 1449 slider->setDrawPaddingOutline(true); |
1416 slider->setColorFillHighlight(ofColor(0,0,255)); | 1450 slider->setColorFill(fillHicol); |
1417 | 1451 slider->setColorFillHighlight(fillHicol); |
1452 | |
1418 ofAddListener(guiL->newGUIEvent, this, &testApp::guiLEvent); | 1453 ofAddListener(guiL->newGUIEvent, this, &testApp::guiLEvent); |
1419 | 1454 |
1420 // RIGHT GUI ----------------------- | 1455 //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) ); |
1421 | 1456 // RIGHT GUI ----------------------- |
1422 guiR = new ofxUICanvas(ofGetWidth()-128, 0, 128, ofGetHeight()-64); | 1457 |
1458 guiR = new ofxUICanvas(ofGetWidth()-sidebarWidth, 0, sidebarWidth, ofGetHeight()-64); | |
1423 | 1459 |
1424 | 1460 |
1425 guiR->addSpacer(length-xInit, 2); | 1461 guiR->addSpacer(length-xInit, 2); |
1426 | 1462 |
1427 vector<string> names; | 1463 vector<string> names; |
1432 names.push_back("UNSTICK"); | 1468 names.push_back("UNSTICK"); |
1433 names.push_back("NEWPATH"); | 1469 names.push_back("NEWPATH"); |
1434 | 1470 |
1435 | 1471 |
1436 ofxUIRadio* radio; | 1472 ofxUIRadio* radio; |
1437 radio = guiR->addRadio("TOUCH MODE", names, OFX_UI_ORIENTATION_VERTICAL, dim, dim); | 1473 radio = guiR->addRadio("TOUCH MODE", names, OFX_UI_ORIENTATION_VERTICAL, widgetHeight, widgetHeight); |
1438 radio->setDrawPadding(true); | 1474 radio->setDrawPadding(true); |
1439 radio->setColorFill(ofColor(0,0,255)); | 1475 radio->setColorFill(fillHicol); |
1440 radio->setColorFillHighlight(ofColor(0,0,255)); | 1476 radio->setColorFillHighlight(fillHicol); |
1441 | 1477 |
1442 slider = guiR->addWidgetDown(new ofxUISlider(length,dim, -0.4, 4.0, 1.0, "TOUCH AMT")); | 1478 slider = guiR->addWidgetDown(new ofxUISlider( "TOUCH AMT", -0.4, 4.0, 1.0,length,widgetHeight)); |
1443 slider->setDrawPadding(true); | 1479 slider->setDrawPadding(true); |
1444 slider->setColorFill(ofColor(0,0,255)); | 1480 slider->setColorFill(fillHicol); |
1445 slider->setColorFillHighlight(ofColor(0,0,255)); | 1481 slider->setColorFillHighlight(fillHicol); |
1446 | 1482 |
1447 guiR->addSpacer(length-xInit, 2); | 1483 guiR->addSpacer(length-xInit, 2); |
1448 | 1484 |
1449 guiR->addToggle("PAUSE", false, dim, dim); | 1485 guiR->addToggle("PAUSE", false, widgetHeight, widgetHeight); |
1450 guiR->addButton("RESET", false, dim, dim); | 1486 guiR->addButton("RESET", false, widgetHeight, widgetHeight); |
1451 guiR->addButton("NEW", false, dim, dim); | 1487 guiR->addButton("NEW", false, widgetHeight, widgetHeight); |
1452 guiR->addButton("SAVE", false, dim, dim); | 1488 guiR->addButton("SAVE", false, widgetHeight, widgetHeight); |
1453 guiR->addButton("LOAD", false, dim, dim); | 1489 guiR->addButton("LOAD", false, widgetHeight, widgetHeight); |
1454 | 1490 |
1455 ofAddListener(guiR->newGUIEvent, this, &testApp::guiREvent); | 1491 ofAddListener(guiR->newGUIEvent, this, &testApp::guiREvent); |
1456 //guiR->loadSettings(ofxiPhoneGetDocumentsDirectory() + "guiSettings.xml"); | 1492 //guiR->loadSettings(ofxiPhoneGetDocumentsDirectory() + "guiSettings.xml"); |
1457 radio->activateToggle("GRAB"); | 1493 radio->activateToggle("GRAB"); |
1458 | 1494 |
1459 // show hide ctrls | 1495 // show hide ctrls |
1460 guiSH = new ofxUICanvas(ofGetWidth()-128, ofGetHeight()-64, 128, 64); | 1496 guiSH = new ofxUICanvas(ofGetWidth() - sidebarWidth, ofGetHeight()-64, sidebarWidth, 64); |
1461 | 1497 |
1462 | 1498 |
1463 guiSH->addSpacer(length-xInit, 2); | 1499 guiSH->addSpacer(length-xInit, 2); |
1464 guiSH->addToggle("CTRLS", false, dim, dim); | 1500 ofxUIToggle* t = guiSH->addToggle("CTRLS", false, widgetHeight, widgetHeight); |
1501 // turn toggle on | |
1502 t->setState(true); | |
1503 | |
1465 ofAddListener(guiSH->newGUIEvent, this, &testApp::guiSHEvent); | 1504 ofAddListener(guiSH->newGUIEvent, this, &testApp::guiSHEvent); |
1466 | 1505 |
1467 } | 1506 } |
1468 //-------------------------------------------------------------- | 1507 //-------------------------------------------------------------- |
1469 void testApp::UIcallBack(int buttID){ | 1508 void testApp::UIcallBack(int buttID){ |
1470 cout << " BUTT ID " << buttID << "\n"; | 1509 cout << " BUTT ID " << buttID << "\n"; |
1471 | 1510 |
1511 } | |
1512 void testApp::hideControls(){ | |
1513 cout << "CTRLS ooff"; | |
1514 guiR->setVisible(false); | |
1515 guiL->setVisible(false); | |
1516 controlsShowing = false; | |
1517 } | |
1518 void testApp::showControls(){ | |
1519 cout << "CTRLS onnn"; | |
1520 guiR->setVisible(true); | |
1521 guiL->setVisible(true); | |
1522 controlsShowing = true; | |
1472 } | 1523 } |
1473 //-------------------------------------------------------------- | 1524 //-------------------------------------------------------------- |
1474 void testApp::guiSHEvent(ofxUIEventArgs &e) | 1525 void testApp::guiSHEvent(ofxUIEventArgs &e) |
1475 { | 1526 { |
1476 if(e.widget->getName() == "CTRLS"){ | 1527 if(e.widget->getName() == "CTRLS"){ |
1477 // ???? | 1528 // ???? |
1478 | 1529 |
1479 cout << ((ofxUIButton *)e.widget)->getValue(); | 1530 cout << ((ofxUIButton *)e.widget)->getValue(); |
1480 | 1531 |
1481 if( ((ofxUIButton *)e.widget)->getValue() == 0) { | 1532 if( ((ofxUIButton *)e.widget)->getValue() == 0) { |
1482 cout << "CTRLS oofff"; | 1533 hideControls(); |
1483 guiR->setVisible(false); | |
1484 guiL->setVisible(false); | |
1485 controlsShowing = false; | |
1486 }else{ | 1534 }else{ |
1487 cout << "CTRLS onnn"; | 1535 showControls(); |
1488 guiR->setVisible(true); | |
1489 guiL->setVisible(true); | |
1490 controlsShowing = true; | |
1491 } | 1536 } |
1492 | 1537 |
1493 } | 1538 } |
1494 } | 1539 } |
1495 | 1540 |