diff options
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/src/chainImage.cpp | 30 | ||||
| -rw-r--r-- | gui/src/chainImage.h | 7 | ||||
| -rw-r--r-- | gui/src/ofApp.cpp | 85 | ||||
| -rw-r--r-- | gui/src/ofApp.h | 4 |
4 files changed, 77 insertions, 49 deletions
diff --git a/gui/src/chainImage.cpp b/gui/src/chainImage.cpp index 6fdca96..a9ef602 100644 --- a/gui/src/chainImage.cpp +++ b/gui/src/chainImage.cpp @@ -221,13 +221,11 @@ void chainImageSet::drawOutput(){ } -void chainImageSet::drawGui(int x,int y){ +void chainImageSet::drawGui(int x,int y,bool is_selected){ float t_xoffs=0.0; float borderwidth=THUMB_SIZE*0.1; //ofGetWindowHeight()*(1.0-THUMB_BORDER_RATIO)*0.5; - glPushMatrix(); - /* @@ -238,6 +236,10 @@ void chainImageSet::drawGui(int x,int y){ //draw each image, outlined + glPushMatrix(); + + glTranslatef(x,y,0); + for(std::list<chainImage>::iterator ii=images.begin(); ii != images.end(); ii++){ ofSetColor(255,255,255); @@ -246,9 +248,7 @@ void chainImageSet::drawGui(int x,int y){ float thumby=ii->thumbnail.getHeight()/2; float thumbscale=ii->thumbnail.getWidth()/ii->getWidth(); - glPushMatrix(); - - glTranslatef(x,y,0); + //why do I have to set this every time?? ii->thumbnail.setAnchorPercent(0.5,0.5); @@ -333,6 +333,8 @@ void chainImageSet::drawGui(int x,int y){ ofDrawLine(p3,p4); ofDrawLine(p4,p1); + + glPopMatrix(); } @@ -340,8 +342,22 @@ void chainImageSet::drawGui(int x,int y){ t_xoffs+=ii->thumbnail.getWidth()+(borderwidth*2); - glPopMatrix(); + + } + + if (is_selected) { + ofSetColor(0,0,255); + ofPolyline box; + box.addVertex(ofPoint(5,5)); + box.addVertex(ofPoint(t_xoffs-5,5)); + box.addVertex(ofPoint(t_xoffs-5,(THUMB_SIZE/THUMB_BORDER_RATIO)-10)); + box.addVertex(ofPoint(5,(THUMB_SIZE/THUMB_BORDER_RATIO)-10)); + box.addVertex(ofPoint(5,5)); + box.draw(); } + + + glPopMatrix(); } diff --git a/gui/src/chainImage.h b/gui/src/chainImage.h index a4f4367..aa7301d 100644 --- a/gui/src/chainImage.h +++ b/gui/src/chainImage.h @@ -80,8 +80,11 @@ class chainImageSet{ additive=false; intensity=1.0f; fitFactor=0.9f; + dragScale=0.0f; + dragRotate=0.0f; + dragPoint=ofPoint(0,0); } - void drawGui(int x,int y); + void drawGui(int x,int y,bool is_selected); void drawOutput(); void update(); bool add(std::string filename,glm::vec2 pos); @@ -96,7 +99,7 @@ class chainImageSet{ ofPoint outputSize; std::list <chainImage> images; - std::list <chainImage> images2; + float currentDefaultImageRatio; std::list<chainImage>::iterator selected; diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp index 797f729..4f73e90 100644 --- a/gui/src/ofApp.cpp +++ b/gui/src/ofApp.cpp @@ -33,7 +33,11 @@ void ofApp::setup(){ dmxIntensity=255; - next_update=ofGetElapsedTimef()+5.0f; + next_update=ofGetElapsedTimef()+0.1f; + + sets.push_back(chainImageSet()); + sets.push_back(chainImageSet()); + selected_set=0; } //-------------------------------------------------------------- @@ -48,9 +52,9 @@ void ofApp::update(){ void ofApp::updateOutput(ofEventArgs & args){ - images.update(); - images2.update(); - + for (int i=0;i<sets.size();i++){ + sets[i].update(); + } } @@ -58,15 +62,19 @@ void ofApp::updateOutput(ofEventArgs & args){ //-------------------------------------------------------------- void ofApp::draw(){ ofBackground(0,0,0); - images.drawGui(0,0); - images2.drawGui(0,200); + + for (int i=0;i<sets.size();i++){ + sets[i].drawGui(0,i*200,i==selected_set); + } + } void ofApp::drawOutput(ofEventArgs & args){ ofBackground(0,0,0); - images.drawOutput(); - images2.drawOutput(); +for (int i=0;i<sets.size();i++){ + sets[i].drawOutput(); + } if (dmx.isConnected()&&ofGetElapsedTimef()>next_update){ //if (dmx.isConnected()&&()){ @@ -130,14 +138,14 @@ void ofApp::newMidiMessage(ofxMidiMessage& msg) { //from .9 to 1.1 but reaching numbers very near 1 float signed_value=(float)msg.value-64; if (signed_value<0){ - images.decayFactor=1.0 + (pow(4.0f,abs(signed_value)/8)/pow(4,8)); + sets[0].decayFactor=1.0 + (pow(4.0f,abs(signed_value)/8)/pow(4,8)); } else { - images.decayFactor=1.0 - (pow(4.0f,(signed_value)/8)/pow(4,8)); + sets[0].decayFactor=1.0 - (pow(4.0f,(signed_value)/8)/pow(4,8)); } - images2.decayFactor=images.decayFactor; + sets[1].decayFactor=sets[0].decayFactor; - printf("Val %i, decay: %f \n",msg.value,images.decayFactor); + printf("Val %i, decay: %f \n",msg.value,sets[0].decayFactor); } if (msg.channel==1&&msg.control==65+offet){ @@ -161,14 +169,14 @@ void ofApp::newMidiMessage(ofxMidiMessage& msg) { } if (msg.channel==1&&msg.control==65+offet){ //top button 1 - images.additive=(msg.value==127); + sets[0].additive=(msg.value==127); } if (msg.channel==1&&msg.control==73+offet){ //bottom button 1 } if (msg.channel==1&&msg.control==81+offet){ //fader 1 - images.intensity=((float)msg.value)/127.0f; + sets[0].intensity=((float)msg.value)/127.0f; } //column 6 for image set 1 @@ -180,14 +188,14 @@ void ofApp::newMidiMessage(ofxMidiMessage& msg) { } if (msg.channel==1&&msg.control==65+offet){ //top button 1 - images.additive=(msg.value==127); + sets[0].additive=(msg.value==127); } if (msg.channel==1&&msg.control==73+offet){ //bottom button 1 } if (msg.channel==1&&msg.control==81+offet){ //fader 1 - images2.intensity=((float)msg.value)/127.0f; + sets[1].intensity=((float)msg.value)/127.0f; } //column 1 for more controls @@ -195,10 +203,11 @@ void ofApp::newMidiMessage(ofxMidiMessage& msg) { if (msg.channel==1&&msg.control==1+offet){ //pot 1 - images.fitFactor=1.0f+(((float)msg.value-64)/64.0f); - images2.fitFactor=1.0f+(((float)msg.value-64)/64.0f); + for (int i=0;i<sets.size();i++){ + sets[i].fitFactor=1.0f+(((float)msg.value-64)/64.0f); + }; - printf("Val %i, fitfactor: %f \n",msg.value,images.fitFactor); + printf("Val %i, fitfactor: %f \n",msg.value,sets[0].fitFactor); } if (msg.channel==1&&msg.control==65+offet){ //top button 1 @@ -215,10 +224,18 @@ void ofApp::newMidiMessage(ofxMidiMessage& msg) { } //-------------------------------------------------------------- -void ofApp::keyPressed(ofKeyEventArgs &keyargs){ - images.keyPressed(keyargs); +void ofApp::keyPressed(ofKeyEventArgs &args){ + sets[selected_set].keyPressed(args); - + + if(args.key == '-'){ + selected_set-=1; + if (selected_set<0) selected_set=sets.size()-1; + } + if(args.key == '='){ + selected_set+=1; + if (selected_set==sets.size()) selected_set=0; + } } void ofApp::outputKeyPressed(ofKeyEventArgs &args){ @@ -240,26 +257,17 @@ void ofApp::mouseMoved(int x, int y ){ //-------------------------------------------------------------- void ofApp::mouseDragged(int x, int y, int button){ - if (y<ofGetHeight()/2){ - images.mouseDragged(x,y,button); - } - else images2.mouseDragged(x,y,button); + sets[selected_set].mouseDragged(x,y,button); } //-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ - if (y<ofGetHeight()/2){ - images.mousePressed(x,y,button); - } - else images2.mousePressed(x,y,button); + sets[selected_set].mousePressed(x,y,button); } //-------------------------------------------------------------- void ofApp::mouseReleased(int x, int y, int button){ - if (y<ofGetHeight()/2){ - images.mouseReleased(x,y,button); - } - else images2.mouseReleased(x,y,button); + sets[selected_set].mouseReleased(x,y,button); } //-------------------------------------------------------------- @@ -279,8 +287,9 @@ void ofApp::windowResized(int w, int h){ void ofApp::outputWindowResized(ofResizeEventArgs &resizeargs){ //printf("Output window: %i,%i \n",resizeargs.width,resizeargs.height); - images.outputSize=ofPoint(resizeargs.width,resizeargs.height); - images2.outputSize=ofPoint(resizeargs.width,resizeargs.height); + for (int i=0;i<sets.size();i++){ + sets[i].outputSize=ofPoint(resizeargs.width,resizeargs.height); + } } //-------------------------------------------------------------- @@ -299,9 +308,9 @@ void ofApp::dragEvent(ofDragInfo dragInfo){ filenames=filenames+*f; if (dragInfo.position.y<200){ - images.add(*f,dragInfo.position); + sets[0].add(*f,dragInfo.position); } - else images2.add(*f,dragInfo.position); + else sets[1].add(*f,dragInfo.position); } diff --git a/gui/src/ofApp.h b/gui/src/ofApp.h index 181c4c7..1df35e0 100644 --- a/gui/src/ofApp.h +++ b/gui/src/ofApp.h @@ -115,8 +115,8 @@ class ofApp : public ofBaseApp, public ofxMidiListener{ vector<string> arguments; - chainImageSet images; - chainImageSet images2; + vector<chainImageSet> sets; + int selected_set; ofxDmx dmx; //ofxArtnet artnet; |
