From d1a44d34955133815d2c322b600a79cceecf5a95 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 21 Sep 2012 17:02:21 +0100 Subject: beginning gui --- liveengine/addons.make | 1 + liveengine/bin/data/birds.xml | 127 ++++++++++++++++----------------- liveengine/bin/data/computers.xml | 68 ++++++++++++++++++ liveengine/bin/data/food.xml | 68 ++++++++++++++++++ liveengine/bin/data/mil_historic.xml | 132 ++++++++++++++++++----------------- liveengine/bin/data/panel.xml | 4 ++ liveengine/bin/data/tools.xml | 68 ++++++++++++++++++ liveengine/bin/data/trainers.xml | 68 ++++++++++++++++++ liveengine/liveengine.layout | 24 +++---- liveengine/src/layers.cpp | 25 ++++--- liveengine/src/layers.h | 12 ++-- liveengine/src/testApp.cpp | 123 +++++++++++++++++++++----------- liveengine/src/testApp.h | 37 ++++++++-- liveengine/src/viewport.cpp | 6 +- liveengine/src/viewport.h | 2 +- 15 files changed, 559 insertions(+), 206 deletions(-) create mode 100644 liveengine/bin/data/computers.xml create mode 100644 liveengine/bin/data/food.xml create mode 100644 liveengine/bin/data/panel.xml create mode 100644 liveengine/bin/data/tools.xml create mode 100644 liveengine/bin/data/trainers.xml diff --git a/liveengine/addons.make b/liveengine/addons.make index d84b231..c930a97 100755 --- a/liveengine/addons.make +++ b/liveengine/addons.make @@ -3,3 +3,4 @@ ofxMidi ofxSVG ofxSVGTiny ofxFenster +ofxGui diff --git a/liveengine/bin/data/birds.xml b/liveengine/bin/data/birds.xml index 9326acf..0db0986 100644 --- a/liveengine/bin/data/birds.xml +++ b/liveengine/bin/data/birds.xml @@ -1,67 +1,68 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/bin/data/computers.xml b/liveengine/bin/data/computers.xml new file mode 100644 index 0000000..22ed140 --- /dev/null +++ b/liveengine/bin/data/computers.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/bin/data/food.xml b/liveengine/bin/data/food.xml new file mode 100644 index 0000000..10253cd --- /dev/null +++ b/liveengine/bin/data/food.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/bin/data/mil_historic.xml b/liveengine/bin/data/mil_historic.xml index 7845e80..3f8f9e7 100644 --- a/liveengine/bin/data/mil_historic.xml +++ b/liveengine/bin/data/mil_historic.xml @@ -1,64 +1,68 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/bin/data/panel.xml b/liveengine/bin/data/panel.xml new file mode 100644 index 0000000..ee87c83 --- /dev/null +++ b/liveengine/bin/data/panel.xml @@ -0,0 +1,4 @@ +0 +0 +1 +0 diff --git a/liveengine/bin/data/tools.xml b/liveengine/bin/data/tools.xml new file mode 100644 index 0000000..f18f439 --- /dev/null +++ b/liveengine/bin/data/tools.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/bin/data/trainers.xml b/liveengine/bin/data/trainers.xml new file mode 100644 index 0000000..624be8d --- /dev/null +++ b/liveengine/bin/data/trainers.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/liveengine.layout b/liveengine/liveengine.layout index c4d9071..aad423f 100644 --- a/liveengine/liveengine.layout +++ b/liveengine/liveengine.layout @@ -1,11 +1,11 @@ - + - - + + @@ -17,27 +17,27 @@ - + - + - + - - + + - - + + - + - + diff --git a/liveengine/src/layers.cpp b/liveengine/src/layers.cpp index e69023b..6724255 100755 --- a/liveengine/src/layers.cpp +++ b/liveengine/src/layers.cpp @@ -11,11 +11,11 @@ svglayer::svglayer(string _f) void svglayer::load(string _f){ //check if files exits svg.load(_f); - printf("%i paths\n",svg.getNumPath()); + printf("%s: %i paths\n",_f.c_str(),svg.getNumPath()); for (int i=0;i0); } @@ -26,19 +26,24 @@ void svglayer::getCentre(int cx,int cy) { } } -void svglayer::draw(float a,int cx,int cy) { +void svglayer::draw(float a,int cx,int cy,float colShift) { getCentre(cx,cy); - for (int i=0;i0.0f) { + c.setHue(fmod(c.getHue()+colShift,255.0f)); + //printf ("shift from %f to %f\n",c.getHue(),c.getHue()+colShift); + } + svg.getPathAt(i).setFillColor(c); svg.getPathAt(i).draw(xo,yo); } } -void svglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack) { +void svglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift) { getCentre(cx,cy); //draw layers tinted by controllers for (int i=0;idraw(0,0,ofGetWidth(),ofGetHeight()); +} +//-------------------------------------------------------------- +guiWindow::~guiWindow(){ + cout << "gui window destroyed" << endl; +} +void guiWindow::setup(){} +void guiWindow::setGui(ofxPanel *panel){ + gui=panel; +} +void guiWindow::draw(){ + + gui->draw(); + } //-------------------------------------------------------------- void testApp::setup(){ @@ -39,13 +52,15 @@ void testApp::setup(){ note=0; makeColours(); + + colShift=0; controlColours=false; debug=false; noteRandomiseColours=false; transparentBlack=false; reversemain=false; - + vp1.setup(768,1024,1024,0,-90,-256,-384); vp2.setup(1024,768,0,0,0,-512,-384); @@ -78,8 +93,8 @@ void testApp::setup(){ fscale=1.0f; - //window stuff - ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, 600, 800, OF_WINDOW); + //preview window stuff + win=ofxFensterManager::get()->createFenster(0, 0, 600, 800, OF_WINDOW); ofAddListener(win->events.mouseDragged, this, &testApp::mousePressedEvent); ofAddListener(win->events.mousePressed, this, &testApp::mousePressedEvent); ofAddListener(win->events.keyPressed, this, &testApp::keyPressedEvent); @@ -89,12 +104,42 @@ void testApp::setup(){ prevWin.setBuffer(&vp1.rb2); fullscreenoutput=false; + + gui.setup("","panel.xml",0,0); + gui.add(reversemain.setup("reverse main", false)); + gui.add(controlColours.setup("control colours", false)); + gui.add(noteRandomiseColours.setup("randomise note colours", false)); + gui.add(transparentBlack.setup("transparent black", false)); + gui.add(resetDrawscale.setup("reset draw scale")); + gui.add(resetFBscale.setup("reset FB scale")); + + resetDrawscale.addListener(this,&testApp::resetDrawscalePressed); + resetFBscale.addListener(this,&testApp::resetFBscalePressed); + + //gui window stuff + ofxFenster* win2=ofxFensterManager::get()->createFenster(0, 0, 200, 400, OF_WINDOW); + //ofAddListener(win2->events.mouseDragged, this, &testApp::mousePressedEvent); + //ofAddListener(win2->events.mousePressed, this, &testApp::mousePressedEvent); + //ofAddListener(win2->events.keyPressed, this, &testApp::keyPressedEvent); + win2->setWindowTitle("config"); + win2->addListener(&guiWin); + guiWin.setup(); + guiWin.setGui(&gui); + } +void testApp::resetDrawscalePressed(bool & pressed){ + scale=1.0f; +} +void testApp::resetFBscalePressed(bool & pressed){ + fscale=1.0f; +} + void testApp::makeColours() { controller_colours=new ofColor[NUM_CONTROLLERS]; for (int i=0;i0) { switch(mode) { @@ -173,7 +218,7 @@ void testApp::draw(){ rb2.end(); rb2.draw(1024,0); - + rb3.begin(); //landscape @@ -187,7 +232,7 @@ void testApp::draw(){ notewidth=rb3.getHeight()/NUM_NOTES; noteheight=rb3.getWidth()/NUM_CONTROLLERS; - + ofPushMatrix(); ofTranslate(rb3.getWidth(),rb3.getHeight()/2); ofRotate(90); @@ -218,7 +263,7 @@ void testApp::draw(){ break; } } - + ofPopMatrix(); //for (int i=0;idraw(); @@ -233,9 +278,9 @@ void testApp::draw(){ rb4.end(); rb4.draw(0,0); - + */ - + /* test screen shape ofSetColor(255,0,0); ofRect(0,0,1024,768); @@ -282,6 +327,9 @@ void testApp::keyPressed(int key){ if(key == 't'){ list.load("reptiles.xml"); } + if(key == 'T'){ + list.load("tools.xml"); + } if(key == 'y'){ list.load("miltary_ladies.xml"); } @@ -291,6 +339,9 @@ void testApp::keyPressed(int key){ if(key == 'u'){ list.load("knights.xml"); } + if(key == 'U'){ + list.load("food.xml"); + } if(key == 'i'){ list.load("mil_historic.xml"); } @@ -300,6 +351,9 @@ void testApp::keyPressed(int key){ if(key == 'o'){ list.load("yoga.xml"); } + if(key == 'O'){ + list.load("computers.xml"); + } if(key == 'p'){ list.load("dancing.xml"); } @@ -317,23 +371,19 @@ void testApp::keyPressed(int key){ mode=key-'0'; } if(key == 267){ - yshift++; + xshift--; } if(key == 268){ - yshift--; + xshift++; } if(key == 269){ - xshift--; + yshift--; } if(key == 270){ - xshift++; + yshift++; } if(key == '='){ makeColours(); - } - if(key == '-'){ - controlColours=!controlColours; - printf("%s control colours\n",controlColours?"do":"don't"); } if(key == '+'){ fadetime=min(128,fadetime+1); @@ -358,25 +408,14 @@ void testApp::keyPressed(int key){ if(key == 'd'){ debug=!debug; } - if(key == 'l'){ - noteRandomiseColours=!noteRandomiseColours; - printf("%s randomise colours\n",noteRandomiseColours?"do":"don't"); - } - if (key=='k') { - transparentBlack=!transparentBlack; - printf("%s transparent black\n",transparentBlack?"use":"don't use"); - } + if (key=='j') { fscale=1.0f; } if (key=='h') { scale=1.0f; } - if (key=='h') { - reversemain=!reversemain; - printf("%s main screen\n",reversemain?"reversing":"not reversing"); - } - + } //-------------------------------------------------------------- @@ -418,18 +457,18 @@ void testApp::dragEvent(ofDragInfo dragInfo){ } void testApp::mousePressedEvent(ofMouseEventArgs &args) { - //printf("mouse: %i,%i %i of %ix%i\n",args.x,args.y,args.button,ofGetWidth(),ofGetHeight()); + //printf("mouse: %i,%i %i of %ix%i\n",args.x,args.y,args.button,win->getWidth(),win->getHeight()); //0-2 switch (args.button) { case 0: - xshift=args.x-(ofGetWidth()/2); - yshift=args.y-(ofGetHeight()/2); + xshift=args.x-(win->getWidth()/2); + yshift=args.y-(win->getHeight()/2); break; case 1: - scale=pow(pow(args.x-(ofGetWidth()/2),2)+pow(args.y-(ofGetHeight()/2),2),0.5)/(ofGetWidth()*.1); + scale=pow(pow(args.x-(win->getWidth()/2),2)+pow(args.y-(win->getHeight()/2),2),0.5)/(win->getWidth()*.1); break; case 2: - fscale=(pow(pow(args.x-(ofGetWidth()/2),2)+pow(args.y-(ofGetHeight()/2),2),0.5)/(ofGetWidth()))+0.5; + fscale=(pow(pow(args.x-(win->getWidth()/2),2)+pow(args.y-(win->getHeight()/2),2),0.5)/(win->getWidth()))+0.5; break; } } @@ -472,7 +511,9 @@ void testApp::newMidiMessage(ofxMidiEventArgs& eventArgs){ if (debug) printf("note: %i %i\n",eventArgs.byteOne,eventArgs.byteTwo); note=eventArgs.byteOne; lastnoteTime=ofGetElapsedTimef(); - if (noteRandomiseColours) makeColours(); + if (noteRandomiseColours) { + makeColours(); // + } break; case 176: //control change channel 0 //for (int i=0;idraw(a,controllers,w,h,transparentBlack); - else list.layers[note]->draw(a,w,h); + if (controlColours) list.layers[note]->draw(a,controllers,w,h,transparentBlack,colShift); + else list.layers[note]->draw(a,w,h,colShift); ofPopMatrix(); } list.unlock(); diff --git a/liveengine/src/viewport.h b/liveengine/src/viewport.h index 5d990a0..4f29a5b 100755 --- a/liveengine/src/viewport.h +++ b/liveengine/src/viewport.h @@ -20,7 +20,7 @@ class viewport public: viewport(); void setup(int w,int h,int x, int y,float r,int _ox,int _oy); - void draw(float a,unsigned char* controllers,int xshift,int yshift,playlist &list,bool transparentBlack,int note,int mode,ofColor* controller_colours,bool controlColours,float scale,float fscale); + void draw(float a,unsigned char* controllers,int xshift,int yshift,playlist &list,bool transparentBlack,int note,int mode,ofColor* controller_colours,bool controlColours,float scale,float fscale,float colShift); virtual ~viewport(); ofFbo rb1,rb2; float r; -- cgit v1.2.3