From 4aa44a0b9159300c24db4786a3cf2e4198f168f1 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 28 May 2013 16:41:00 +0100 Subject: adding palete manipulation --- bin/data/bw.xml | 5 +++++ config.make | 2 +- src/testApp.cpp | 18 ++++++++++++++++++ src/testApp.h | 13 ++++++++++++- src/viewport.h | 19 ++++++++++++++++++- 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 bin/data/bw.xml diff --git a/bin/data/bw.xml b/bin/data/bw.xml new file mode 100644 index 0000000..f8fd527 --- /dev/null +++ b/bin/data/bw.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/config.make b/config.make index 5bfa48a..85e8c5d 100755 --- a/config.make +++ b/config.make @@ -17,7 +17,7 @@ USER_CFLAGS = -std=c++11 # for example libraries like: # USER_LDFLAGS = libs/libawesomelib.a -USER_LDFLAGS = +USER_LDFLAGS = -lX11 EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj" 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 viewports; vpcontrol control; int windowsize; + + vector 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 palette; + string palettename; }; class viewport -- cgit v1.2.3