Mercurial > hg > tweakathon2ios
changeset 37:52dbd5b4cfa9
slider feedback and textures
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Wed, 03 Dec 2014 11:38:26 +0000 |
parents | 146033869165 |
children | fea11c3d1d94 |
files | MessageOrganiser.h MessageOrganiser.mm PDSynthWrapper.h SequenceController.h SequenceController.mm TrainingMessageOrganiser.h TrainingMessageOrganiser.mm TrainingScoreManager.h UI code/6Dbox.h UI code/6Dbox.mm UI code/ButtronSlider.h UI code/ButtronSlider.mm UI code/sliderPanel.h UI code/sliderPanel.mm globalVariables.h testApp.mm |
diffstat | 16 files changed, 126 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/MessageOrganiser.h Tue Dec 02 13:25:48 2014 +0000 +++ b/MessageOrganiser.h Wed Dec 03 11:38:26 2014 +0000 @@ -74,6 +74,7 @@ void hideMyPanels(); void showMyPanels(); void midiFromLeap(int ctl_num, int ctl_val); + void setPanelType(controlPanelType p); protected: PDSynthWrapper candidateSynth; @@ -113,6 +114,6 @@ void showTargetAsHints(); bool onlyChangeCandidateOnTrigger; bool okToGetMidi; - + controlPanelType panelType; };
--- a/MessageOrganiser.mm Tue Dec 02 13:25:48 2014 +0000 +++ b/MessageOrganiser.mm Wed Dec 03 11:38:26 2014 +0000 @@ -25,7 +25,7 @@ vector<UIElement*> UIElemHandles = controlPanel->generateControls(elemList, whichInterfaceAreWeUsing); mapSlidersToParams(UIElemHandles, mappingIDsForChangeableParams); - + panelType =whichInterfaceAreWeUsing; } @@ -47,7 +47,9 @@ control->addHandler(callbackF, mappingID); currentMapping.insert(std::pair<int,UIElement*>(mappingID,control)); } - +void MessageOrganiser::setPanelType(controlPanelType p){ + panelType = p; +} //---------------------------------------------------------------------------------- void MessageOrganiser::setControlPanel(SliderPanel* p){ // a bit specific?? controlPanel = p;
--- a/PDSynthWrapper.h Tue Dec 02 13:25:48 2014 +0000 +++ b/PDSynthWrapper.h Wed Dec 03 11:38:26 2014 +0000 @@ -287,6 +287,10 @@ core->pd.sendList("fromOF", toPD); } + void playDownbeatBlip(){ + List toPD; + core->pd.sendMessage("fromOF", "blip", toPD); + } void onTick(int tickNo){ //
--- a/SequenceController.h Tue Dec 02 13:25:48 2014 +0000 +++ b/SequenceController.h Wed Dec 03 11:38:26 2014 +0000 @@ -15,8 +15,8 @@ #include "TrainingScoreManager.h" #define MIN_TARGETS_IN_SEQUENCE 1 -#define NUM_REPETITIONS_AT_LEVEL 2 -#define MAX_TARGETS_IN_SEQUENCE 7 +#define NUM_REPETITIONS_AT_LEVEL 1 +#define MAX_TARGETS_IN_SEQUENCE 4 #define MIN_TEMPO 70 #define MAX_TEMPO 480 #define TEMPO_RANDOM_AMOUNT
--- a/SequenceController.mm Tue Dec 02 13:25:48 2014 +0000 +++ b/SequenceController.mm Wed Dec 03 11:38:26 2014 +0000 @@ -407,7 +407,7 @@ steps.push_back(nextStep); steps.back().isLastOfSeq = true; - curTempo += tempoInc*0.6; // easier!!! + curTempo += tempoInc*0.8; // easier!!! seqNo++; cout << endl;
--- a/TrainingMessageOrganiser.h Tue Dec 02 13:25:48 2014 +0000 +++ b/TrainingMessageOrganiser.h Wed Dec 03 11:38:26 2014 +0000 @@ -34,6 +34,7 @@ void onNextTickAnim(int tickNumber); void showMyPanels(); + //void midiFromLeap(int ctl_num, int ctl_val); //----------------------------------------------------------------------- protected: @@ -82,7 +83,7 @@ SequenceController sequenceController; TrainingScoreManager trainingScoreManager; - controlPanelType panelType; + }; #endif /* defined(__riftathon__TrainingMessageOrganiser__) */
--- a/TrainingMessageOrganiser.mm Tue Dec 02 13:25:48 2014 +0000 +++ b/TrainingMessageOrganiser.mm Wed Dec 03 11:38:26 2014 +0000 @@ -43,7 +43,11 @@ bottomPanel->show(); controlPanel->show(); middlePanel->show(); - okToGetMidi = true; // enables check that hand moves on startup? + if (panelType == LEAP6DOF){ + okToGetMidi = true; // allow midi input to thing + }else{ + okToGetMidi = false; + } } //----------------------------------------------------------------------- @@ -85,6 +89,11 @@ return; } + if(mappingID == TO_MENU_ID){ + // tell testapp to start again? + + } + } //----------------------------------------------------------------------------- @@ -208,6 +217,7 @@ Preset * currentTargetPreset; if(newStep.presetIndex == -1){ currentTargetPreset = expPresetManager.getNeutralPreset(); + }else{ currentTargetPreset = expPresetManager.getPresetAtIndex(newStep.presetIndex); @@ -259,7 +269,7 @@ //----------------------------------------------------------------------------- void TrainingMessageOrganiser::previewNeutralCount(AnimStep newStep, Preset * currentTargetPreset){ okToGetMidi = false; - + candidateSynth.playDownbeatBlip(); middlePanel->hide(); // your 'hand' is hidden @@ -445,7 +455,13 @@ if (newStep.showsGuides){ controlPanel->setColor(ofColor::seaGreen); }else{ - controlPanel->setColor(ofColor::darkMagenta); + if (newStep.showsIcons){ + controlPanel->setColor(ofColor::darkMagenta); + }else{ + controlPanel->setColor(ofColor::red); + // set sliders to default texture + controlPanel->setIndicatorTexture(NULL); + } } } //----------------------------------------------------------------------------- @@ -462,7 +478,7 @@ doHand(true); - displayInstructions("MATCHING FINISHED"); + //displayInstructions("MATCHING FINISHED"); showSeqNum(newStep.whichInSequence); triggerCandidateSound(); @@ -470,7 +486,11 @@ if (newStep.showsGuides){ controlPanel->setColor(ofColor::seaGreen); }else{ - controlPanel->setColor(ofColor::darkMagenta); + if (newStep.showsIcons){ + controlPanel->setColor(ofColor::darkMagenta); + }else{ + controlPanel->setColor(ofColor::red); + } } } //----------------------------------------------------------------------------- @@ -549,7 +569,11 @@ }else if(showControllableHand){ controlPanel->showValueIndicators(true); // for animation controlPanel->setActive(true); // allow user control - okToGetMidi = true; // allow midi input to thing + if (panelType == LEAP6DOF){ + okToGetMidi = true; // allow midi input to thing + }else{ + okToGetMidi = false; + } }else{ controlPanel->showValueIndicators(false); // hand/ slider bars invisible
--- a/TrainingScoreManager.h Tue Dec 02 13:25:48 2014 +0000 +++ b/TrainingScoreManager.h Wed Dec 03 11:38:26 2014 +0000 @@ -113,7 +113,7 @@ result.realDistanceToTarget = dist; result.targetBandHit = band; // eg bullseye = 0 edge = 7 result.timeAllowed = timeAllowed; - result.score = round(TP*10); + result.score = int(round(TP*10.0)); result.displayText = msg.str(); result.difficultyLevel = difficulty; @@ -129,11 +129,11 @@ }else if(result.targetBandHit == 4){ c = ofColor(0,255,0,255); // green 4 }else{ - c = ofColor(0,0,0,255); // black worst + c = ofColor(123,123,123,255); // grey worst } result.colorBand = c; - if(score > 0) totalScored += score; + if(result.score > 0) totalScored += result.score; vector<int> details;
--- a/UI code/6Dbox.h Tue Dec 02 13:25:48 2014 +0000 +++ b/UI code/6Dbox.h Wed Dec 03 11:38:26 2014 +0000 @@ -88,6 +88,9 @@ void drawIndicatorBlob(float x, float y, float z, ofColor c, bool isHint = false); void draw6DOFIndicatorBlob(float x, float y, float z, ofColor c, float r, float p, float yaw,ofImage* texImg, bool showResultColor = false); void setHandTexture(ofImage* img); + void setHandToDefaultTexture(){ + handTextureRef = &defaultImage; + }; void setValue(int index, int value); void setValueAndScale(int index, int value); @@ -129,6 +132,7 @@ ofMesh handMesh; ofImage* handTextureRef; ofImage defaultImage; + ofImage neutralPresetImage; ofImage hintImage; ofImage* hintImageRef; ofImage wallGrid;
--- a/UI code/6Dbox.mm Tue Dec 02 13:25:48 2014 +0000 +++ b/UI code/6Dbox.mm Wed Dec 03 11:38:26 2014 +0000 @@ -38,8 +38,11 @@ scale = 40; string fname = ofFilePath::getAbsolutePath(ofToDataPath("buttron.png")); + neutralPresetImage.loadImage(fname); + + fname = ofFilePath::getAbsolutePath(ofToDataPath("whiteHand.jpg")); defaultImage.loadImage(fname); - + fname = ofFilePath::getAbsolutePath(ofToDataPath("wallGrid.jpg")); wallGrid.loadImage(fname); @@ -107,10 +110,10 @@ void Leap6DBox::makeTexFace(ofPoint LT, ofPoint RT, ofPoint RB, ofPoint LB){ - ofPoint texCoordLT = ofPoint(0, 0.5); + ofPoint texCoordLT = ofPoint(0, 1.); ofPoint texCoordLB = ofPoint(0, 0); - ofPoint texCoordRT = ofPoint(0.5, 0.5); - ofPoint texCoordRB = ofPoint(0.5, 0); + ofPoint texCoordRT = ofPoint(1., 1.); + ofPoint texCoordRB = ofPoint(1., 0); handMesh.addVertex(LT); handMesh.addTexCoord(texCoordLT);
--- a/UI code/ButtronSlider.h Tue Dec 02 13:25:48 2014 +0000 +++ b/UI code/ButtronSlider.h Wed Dec 03 11:38:26 2014 +0000 @@ -40,6 +40,7 @@ ofDisableDepthTest(); drawIndicator(value); if(hintShowing) drawHintIndicator(); + ofEnableDepthTest(); } @@ -74,9 +75,16 @@ minVal = lo; maxVal = hi; } + + void setHandTexture(ofImage* img){ + handTextureRef = img; + + } void animateHintToNewValue(int newVal, float timeToTake); void animateToNewValue(int newVal, float timeToTake); void update(); + void flashScore(int score, ofColor col); + private: void drawIndicator(double proportion); float minVal; @@ -94,7 +102,12 @@ bool hintShowing; bool indicatorShowing; ofColor hintColor; + ofColor flashColor; bool animating; + int showScoreForFrames; + + ofImage* handTextureRef; + ofImage defaultImage; }; #endif /* defined(__emptyExample__ButtronSlider__) */
--- a/UI code/ButtronSlider.mm Tue Dec 02 13:25:48 2014 +0000 +++ b/UI code/ButtronSlider.mm Wed Dec 03 11:38:26 2014 +0000 @@ -45,8 +45,12 @@ maxVal = 127.; value = 0.6; hintShowing = false; + + string fname = ofFilePath::getAbsolutePath(ofToDataPath("buttron.png")); + defaultImage.loadImage(fname); + setHandTexture(&defaultImage); } -// +// //--------------------------------------------------------------------- void ButtronSlider::drawIndicator(double proportion){ if(!indicatorShowing) return; @@ -59,6 +63,12 @@ if(inactive){ ofSetColor(fgInactive); } + if(showScoreForFrames > 0){ + ofSetColor(flashColor); + showScoreForFrames--; + }else{ + ofSetColor(foregroundHi); + } if(sliderType == FILL){ double maxH = height - 2 * thickness; // @@ -66,7 +76,14 @@ double barheight = value*maxH; double top = y + height - thickness - barheight; ofRect(x+thickness, top, w, barheight); - + }else if(sliderType == TEXTURE_FILL){ + double maxH = height - 2 * thickness; // + double w = width - 2 * thickness;// + double barheight = value*maxH; + double top = y + height - thickness - barheight; + //ofRect(x+thickness, top, w, barheight); + ofSetColor(255,255, 255); + (*handTextureRef).draw(x+thickness, top, w, barheight); }else if(sliderType == LINE){ double loc = y + thickness + (1 -value)*(height-3*thickness); ofRect(x+thickness,loc, width-2*thickness,thickness); @@ -132,4 +149,8 @@ return true; } - +//-------------------------------------------------------------------- +void ButtronSlider::flashScore(int score, ofColor col){ + showScoreForFrames = 20; + flashColor = col; +}
--- a/UI code/sliderPanel.h Tue Dec 02 13:25:48 2014 +0000 +++ b/UI code/sliderPanel.h Wed Dec 03 11:38:26 2014 +0000 @@ -52,7 +52,7 @@ UIElement* getSlider(int index); void setHintTexture(ofImage* texture); - void setIndicatorTexture(ofImage* texture); + void setIndicatorTexture(ofImage* texture = NULL); void animateToNewHintValues(vector<int> newTargetValues, float timeToTake, ofImage* newTexture); void animateToNewValues(vector<int> newTargetValues, float timeToTake); void showValueIndicators(bool show);
--- a/UI code/sliderPanel.mm Tue Dec 02 13:25:48 2014 +0000 +++ b/UI code/sliderPanel.mm Wed Dec 03 11:38:26 2014 +0000 @@ -181,7 +181,7 @@ cout << l << endl; } - ButtronSlider * revslider = new ButtronSlider(l , top , myProps.sliderWidth, myProps.sliderHeight,FILL, myProps); + ButtronSlider * revslider = new ButtronSlider(l , top , myProps.sliderWidth, myProps.sliderHeight,TEXTURE_FILL, myProps); revslider->setLabel("unassigned"); subElements.push_back(revslider); revslider->showHint(false); @@ -262,6 +262,12 @@ box->setHintTexture(texture); } + }else if(thisPanelType == ALL_SLIDERS){ + + for(auto UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){ + ButtronSlider* thisSlider = (ButtronSlider *)(*UIitr); + thisSlider->setHandTexture(texture); + } } } //------------------------------------------ @@ -273,6 +279,12 @@ box->setHandTexture(texture); } + }else if(thisPanelType == ALL_SLIDERS){ + + for(auto UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){ + ButtronSlider* thisSlider = (ButtronSlider *)(*UIitr); + thisSlider->setHandTexture(texture); + } } } //--------------------------------------------- @@ -353,7 +365,11 @@ box->flashScore(5, c); } }else if(thisPanelType == ALL_SLIDERS){ - + for(auto UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){ + ButtronSlider* thisSlider = (ButtronSlider *)(*UIitr); + thisSlider->flashScore(5, c); + + } } } @@ -362,6 +378,7 @@ resultLight.setDiffuseColor(ofColor::white); resultLight.disable(); } + //--------------------------------------------- //--------------------------------------------- //---------------------------------------------
--- a/globalVariables.h Tue Dec 02 13:25:48 2014 +0000 +++ b/globalVariables.h Wed Dec 03 11:38:26 2014 +0000 @@ -26,6 +26,7 @@ #define VOLUME_CHANGE_ID 99263748 #define START_TRAINING_SEQUENCE_ID 99189938 #define SAVE_PRESET_HIT 99245748 +#define TO_MENU_ID 99545741 #define RECALL_PRESET_HIT 99298750 #define ALTERNATION_SPEED 180 // ms that target / candidate sounds play // globles @@ -41,7 +42,7 @@ typedef enum {SLIDER, XYPAD, BUTTON, LEAP3D, LEAP6D} controllerType; typedef enum {SEQUENTIAL, REVISITABLE, SIMULTANEOUS, MULTI_SIMPLE, MULTI_COMPLEX, ALL_SLIDERS, LEAP6DOF} controlPanelType; -typedef enum {FILL,LINE, BLOB} SliderType; +typedef enum {FILL,LINE, BLOB, TEXTURE_FILL} SliderType; typedef enum {SMALLFONT, MEDIUMFONT, LARGEFONT} FontSize;
--- a/testApp.mm Tue Dec 02 13:25:48 2014 +0000 +++ b/testApp.mm Wed Dec 03 11:38:26 2014 +0000 @@ -40,7 +40,6 @@ ofEnableDepthTest(); glEnable(GL_DEPTH_TEST); // ofEnableAlphaBlending(); - whichInterfaceAreWeUsing = ALL_SLIDERS; //-------------------------------------- @@ -140,6 +139,12 @@ playCandidateButton->setLabel("START RUN"); trainingMessageOrganiser.mapButtonToAction(playCandidateButton, START_TRAINING_SEQUENCE_ID); bottomButtonPanel->addButton(playCandidateButton); + + Buttron * menuButton = new Buttron(props->buttonWidth*1.4,680, *props); + menuButton->setLabel("TO MENU"); + trainingMessageOrganiser.mapButtonToAction(menuButton, TO_MENU_ID); + bottomButtonPanel->addButton(menuButton); + bottomButtonPanel->hide(); @@ -150,7 +155,7 @@ TextPanel * instructionPanel = new TextPanel("Instrcution panel", 10, 50, 300,150,(*props)); - instructionPanel->setFontSize(MEDIUMFONT); + instructionPanel->setFontSize(LARGEFONT); UIElements.push_back(instructionPanel); trainingMessageOrganiser.setInstructionPanel(instructionPanel); instructionPanel->hide(); @@ -697,7 +702,7 @@ void testApp::deviceOrientationChanged(int newOrientation){ - cout << "orientation: " << newOrientation; + //cout << "orientation: " << newOrientation; // do something here?