diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/testApp.cpp | 18 | ||||
| -rwxr-xr-x | src/testApp.h | 13 | ||||
| -rwxr-xr-x | src/viewport.h | 19 |
3 files changed, 48 insertions, 2 deletions
diff --git a/src/testApp.cpp b/src/testApp.cpp index bc2fe0e..c7bf35a 100755 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -11,6 +11,9 @@ void previewWindow::draw(){ for (auto i:parent->viewports) i.draw(parent->brightSlider); } +void previewWindow::dragEvent(ofDragInfo dragInfo, ofxFenster* win){ + parent->dragEvent(dragInfo); +} //-------------------------------------------------------------- guiWindow::~guiWindow(){ cout << "gui window destroyed" << endl; @@ -24,6 +27,9 @@ void guiWindow::draw(){ parent->gui.draw(); } +void guiWindow::dragEvent(ofDragInfo dragInfo, ofxFenster* win){ + parent->dragEvent(dragInfo); +} //-------------------------------------------------------------- void testApp::create1port(bool & pressed){ if (!pressed) return; @@ -220,6 +226,18 @@ void testApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- +void testApp::dragEvent(ofDragInfo dragInfo, ofxFenster* win){ + dragEvent(dragInfo); +} +void testApp::dragEvent(ofDragInfo dragInfo){ + printf("got draginfo: %s\n",dragInfo.files[0].c_str()); + int sta=dragInfo.files[0].find_last_of("\\/")+1; + int len=(dragInfo.files[0].find_last_of(".")+4)-sta; + string filename=dragInfo.files[0].substr(sta,len); + printf("loading %s\n",filename.c_str()); + + if (filename.length()) control.loadpalette(filename); +} void testApp::mousePressedEvent(ofMouseEventArgs &args) { diff --git a/src/testApp.h b/src/testApp.h index cc46dfc..376cdee 100755 --- a/src/testApp.h +++ b/src/testApp.h @@ -12,7 +12,10 @@ class previewWindow; class guiWindow; -//#define GRAB_TEXTURE +//load palettes and interpolate them with phase +//some audio drawing +//some actual drawing +//transitions class testApp : public ofxFensterListener { @@ -35,6 +38,8 @@ class testApp : public ofxFensterListener { void mousePressedEvent(ofMouseEventArgs &args); void keyPressedEvent(ofKeyEventArgs &args); void windowEvent(ofResizeEventArgs &args); + void dragEvent(ofDragInfo dragInfo); + void dragEvent(ofDragInfo dragInfo,ofxFenster* win); void toggleFPS(); bool showFPS; @@ -72,6 +77,10 @@ class testApp : public ofxFensterListener { vector<viewport> viewports; vpcontrol control; int windowsize; + + vector<ofColor> palette; + + void loadfilepalette(string &palette); }; @@ -82,6 +91,7 @@ public: void setup(); void setParent(testApp *p); void draw(); + void dragEvent(ofDragInfo dragInfo,ofxFenster* win); }; class guiWindow: public ofxFensterListener{ @@ -91,6 +101,7 @@ public: void setup(); void setParent(testApp *p); void draw(); + void dragEvent(ofDragInfo dragInfo,ofxFenster* win); }; diff --git a/src/viewport.h b/src/viewport.h index 9d2b72c..7ab1477 100755 --- a/src/viewport.h +++ b/src/viewport.h @@ -2,6 +2,7 @@ #define VIEWPORT_H
#include "ofMain.h"
+#include "ofxXmlSettings.h"
class vpcontrol {
public:
@@ -12,11 +13,27 @@ class vpcontrol { yshift=0;
fscale=1.0f;
}
+ void loadpalette(string &filename){
+ ofxXmlSettings XML;
+ if( !XML.loadFile(filename) ){
+ printf("unable to load palette file\n");
+ }else{
+ palette.clear();
+ palettename=XML.getAttribute("palette","name","",0);
+ if(XML.pushTag("palette")) {
+ int numCols=XML.getNumTags("colour");
+ for (int i=0;i<numCols;i++) {
+ palette.push_back(ofColor.fromHex(ofFromHex(XML.getAttribute("colour","hex",0x00,0))));
+ }
+ }
+ }
+ }
bool fillgrey;
float fillgreyfreq;
int xshift,yshift;
float fscale,scale;
-
+ vector<ofColor> palette;
+ string palettename;
};
class viewport
|
